update 7 files

master
Reza_ashrafi 3 years ago
parent 2b3e58cd67
commit 8931e08769
  1. 5
      src/redux/actions/file.js
  2. 6
      src/redux/proxy.js
  3. 3
      src/redux/reducers/file.js
  4. 1
      src/screens/DeliveryForm/index.js
  5. 4
      src/screens/Product/components/Book.js
  6. 67
      src/screens/Product/components/Rates.js
  7. 2
      src/screens/ShoppingCart/index.js

@ -4,7 +4,8 @@ const file = {
(data = {}) =>
async (dispatch) => {
var formData = new FormData();
for (let key in data) formData.append(key, data[key]);
const myData = { ...data, file: { ...data.file, type: "image/jpg" } }
for (let key in myData) formData.append(key, myData[key]);
return await proxy.post(
"file/upload",
formData,
@ -14,7 +15,7 @@ const file = {
"Content-Type": "multipart/form-data",
},
},
data
formData
);
},
};

@ -57,15 +57,9 @@ class Proxy {
check = async (url, { dispatch }, fetch, params) => {
try {
console.log(url.split("/")[0] === 'file');
dispatch = dispatch || (() => {});
dispatch({ type: url.split("/")[0] + "/" + "loading" });
let response = await fetch();
if(url.split("/")[0] === 'file'){
console.log('response');
console.log(response);
}
// console.log(response);
switch (response.status) {
case 200:
dispatch({ type: url, data: response.data.data, params });

@ -7,7 +7,6 @@ export default function file(state = initialState, action) {
let { type, data, params } = action;
switch (type) {
case "file/upload":
console.log(data);
return {
...state,
loading: false,
@ -16,7 +15,7 @@ export default function file(state = initialState, action) {
case "file/loading":
return { ...state, loading: true };
case "file/error":
console.log(error);
console.log(data.message);
return { ...state, loading: false, error: data.message };
default:
return state;

@ -115,7 +115,6 @@ const DeliveryForm = ({
flex: 1,
}}
>
{console.log(factorInfo)}
<Navbar
headerOptions={{
logo: false,

@ -501,7 +501,7 @@ function Book({
})
}
/>
{product?.rate || 4 ? (
{book?.rate || 4 ? (
<>
<View
style={tw(
@ -521,7 +521,7 @@ function Book({
امتیازات و نظرات
</Text>
</View>
<Rates rate={book?.rate || 4} productId={book?.product[1]?.id} />
<Rates productId={physicalProduct?.id} rateDetail={physicalProduct?.rateDetail} />
<Comments
comments={book?.comments}
productId={book?.product[1]?.id}

@ -12,7 +12,39 @@ import Colors from "../../../constants/Colors";
const width = Dimensions.get("window").width;
function Rates({ rate, productId, addVote, isBuyed = null, theme }) {
function Rates({ productId, addVote, isBuyed = null, theme, rateDetail }) {
const fiveCount = React.useMemo(() => {
return rateDetail?.filter((rate) => rate?.rate === 5)[0];
}, [rateDetail]);
const fourCount = React.useMemo(() => {
return rateDetail?.filter((rate) => rate?.rate === 4)[0];
}, [rateDetail]);
const threeCount = React.useMemo(() => {
return rateDetail?.filter((rate) => rate?.rate === 3)[0];
}, [rateDetail]);
const twoCount = React.useMemo(() => {
return rateDetail?.filter((rate) => rate?.rate === 2)[0];
}, [rateDetail]);
const oneCount = React.useMemo(() => {
return rateDetail?.filter((rate) => rate?.rate === 1)[0];
}, [rateDetail]);
const allCount = React.useMemo(() => {
return rateDetail?.reduce((a, b) => a + b?.count, 0);
}, [rateDetail]);
const rate = React.useMemo(() => {
return ((oneCount?.count || 0) * 1 +
(twoCount?.count || 0) * 2 +
(threeCount?.count || 0) * 3 +
(fourCount?.count || 0) * 4 +
(fiveCount?.count || 0) * 5) / rateDetail?.length;
}, [rateDetail]);
return (
<View style={tw("flex flex-row-reverse")}>
<Pressable
@ -28,7 +60,7 @@ function Rates({ rate, productId, addVote, isBuyed = null, theme }) {
},
]}
>
{rate}
{rate || 4}
</Text>
<Rating
type="star"
@ -42,7 +74,7 @@ function Rates({ rate, productId, addVote, isBuyed = null, theme }) {
onFinishRating={(rating) => addVote({ productId, vote: rating })}
readonly={!isBuyed}
/>
{/* <Text
<Text
style={{
fontSize: fontSize.sm,
color: theme === "light" ? "#707070" : Colors.theme1.white,
@ -50,16 +82,31 @@ function Rates({ rate, productId, addVote, isBuyed = null, theme }) {
marginTop: 5,
}}
>
{`از بین ${1150} نفر`}
</Text> */}
{`از بین ${allCount} نفر`}
</Text>
</Pressable>
<View style={[tw("flex flex-1"), { width: "60%" }]}>
{[
{ name: "یک ستاره", value: 40 },
{ name: "دو ستاره", value: 10 },
{ name: "سه ستاره", value: 10 },
{ name: "چهار ستاره", value: 30 },
{ name: "پنج ستاره", value: 10 },
{
name: "یک ستاره",
value: ((oneCount?.count || 0) / allCount) * 100,
},
{
name: "دو ستاره",
value: ((twoCount?.count || 0) / allCount) * 100,
},
{
name: "سه ستاره",
value: ((threeCount?.count || 0) / allCount) * 100,
},
{
name: "چهار ستاره",
value: ((fourCount?.count || 0) / allCount) * 100,
},
{
name: "پنج ستاره",
value: ((fiveCount?.count || 0) / allCount) * 100,
},
].map((field, index) => (
<Progress key={index} data={field} theme={theme} />
))}

@ -187,7 +187,6 @@ function ShoppingCart({
type="error"
theme={theme}
/>
</View>
<View
style={tw(
@ -221,7 +220,6 @@ function ShoppingCart({
},
]}
>
{console.log(factorInfo?.transportPrice)}
{isEmpty ? 0 : separate(factorInfo?.payPrice)}
</Text>

Loading…
Cancel
Save