update 7 files

master
Reza_ashrafi 2 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 = {}) => (data = {}) =>
async (dispatch) => { async (dispatch) => {
var formData = new FormData(); 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( return await proxy.post(
"file/upload", "file/upload",
formData, formData,
@ -14,7 +15,7 @@ const file = {
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",
}, },
}, },
data formData
); );
}, },
}; };

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

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

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

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

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

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

Loading…
Cancel
Save