From 75b33697d53bfe32e7a60455207585d9532df07c Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Tue, 10 May 2022 13:49:44 +0430 Subject: [PATCH] reza fixed and build app --- src/components/Drawer.js | 4 +- src/screens/Address/index.js | 41 +- src/screens/Blog/index.js | 55 +- src/screens/Blogs/layouts/Header.js | 3 +- src/screens/DeliveryForm/Address/index.js | 17 +- src/screens/Home/components/MyBooks.js | 1 + src/screens/Home/index.js | 2 +- src/screens/Product/components/Book.js | 626 ++++++++++-------- src/screens/Products/components/Header.js | 6 +- src/screens/Products/components/Main.js | 350 +++++----- .../components/ProfileAddress/index.js | 61 +- src/screens/Profile/components/User.js | 8 +- src/screens/Profile/index.js | 2 +- src/screens/QR/layouts/Scan/index.js | 10 +- 14 files changed, 662 insertions(+), 524 deletions(-) diff --git a/src/components/Drawer.js b/src/components/Drawer.js index bce7118..850c02e 100644 --- a/src/components/Drawer.js +++ b/src/components/Drawer.js @@ -270,8 +270,10 @@ const Drawer = ({ {}, ]} onPress={() => { - navigation.navigate(route.route); setBoxPosition(); + setTimeout(() => { + navigation.navigate(route.route); + }, 300); }} > {route.icon} diff --git a/src/screens/Address/index.js b/src/screens/Address/index.js index 61a1b17..4f4dbe8 100644 --- a/src/screens/Address/index.js +++ b/src/screens/Address/index.js @@ -9,6 +9,7 @@ import { Dimensions, Appearance, KeyboardAvoidingView, + TextInput, TouchableWithoutFeedback, } from "react-native"; import React, { useEffect, useState } from "react"; @@ -151,7 +152,7 @@ const Address = ({ } ); } - if (cel.length !== 11) { + if (cellphone.length !== 11) { return asyncAwesomeAlert( "خطا", "شماره موبایل میبایست یازده رقم باشد.", @@ -361,7 +362,6 @@ const Address = ({ title="اطلاعات هویتی" text="( لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید )" /> - onInput.numberOnly(text)} - editable={false} /> province.id === profileFields.provinceId )[0]?.name || province[0] - : city[0] + : province[0] } onChange={(name, value) => value === "استان" ? {} : onChange(name, value) @@ -501,6 +500,40 @@ const Address = ({ name="cityId" /> + {!profilePage ? ( + setMapAddress(text)} + placeholderTextColor={ + theme === "light" + ? Colors.theme1.gray2077 + : Colors.theme1.white + "aa" + } + /> + ) : null} { textAlign: ios ? "right" : "auto", }} > - {"نوشته از:" + " " + "کامران ایزدی"} + {/* {"نوشته از:" + " " + "کامران ایزدی"} */} { - { textAlign: ios ? "left" : "left", }} > - {"زمان مطالعه" + " " + "۳۰ دقیقه"} - + {"زمان مطالعه" + " " + blog?.duration + " دقیقه"} + : null + } + { textAlign: ios ? "left" : "left", }} > - {"1400/11/24"} + { + moment(blog?.createdAt).format('jYYYY/jMM/jDD') + } @@ -189,6 +195,40 @@ export const Blog = ({ getInfo, blog, getList, blogs, route, theme }) => { value={blog?.text} renderNode={renderNode} stylesheet={{ + h1 : { + color: + theme === "light" + ? Colors.theme1.gray20 + : Colors.theme1.grayF9, + textAlign: "right", + fontFamily: "bold", + lineHeight: 25, + fontSize: fontSize.xl4, + marginVertical: -15, + paddingTop: 5, + }, + h2 : { + color: + theme === "light" + ? Colors.theme1.gray20 + : Colors.theme1.grayF9, + textAlign: "right", + fontFamily: "bold", + lineHeight: 25, + fontSize: fontSize.xl, + marginVertical: -10, + }, + h3 : { + color: + theme === "light" + ? Colors.theme1.gray20 + : Colors.theme1.grayF9, + textAlign: "right", + fontFamily: "bold", + lineHeight: 25, + fontSize: fontSize.lg, + marginVertical: -10, + }, p: { color: theme === "light" @@ -197,7 +237,7 @@ export const Blog = ({ getInfo, blog, getList, blogs, route, theme }) => { textAlign: "right", fontFamily: "light", lineHeight: 25, - marginVertical: -35, + marginVertical: -20, }, strong: { color: @@ -221,6 +261,9 @@ export const Blog = ({ getInfo, blog, getList, blogs, route, theme }) => { fontFamily: "light", lineHeight: 25, }, + span : { + color : 'red' + } }} /> diff --git a/src/screens/Blogs/layouts/Header.js b/src/screens/Blogs/layouts/Header.js index 4dcfa23..0b77fa7 100644 --- a/src/screens/Blogs/layouts/Header.js +++ b/src/screens/Blogs/layouts/Header.js @@ -58,8 +58,7 @@ export const Header = ({ title, theme }) => { مشاهده بیشتر diff --git a/src/screens/DeliveryForm/Address/index.js b/src/screens/DeliveryForm/Address/index.js index cc73ebe..afbfd76 100644 --- a/src/screens/DeliveryForm/Address/index.js +++ b/src/screens/DeliveryForm/Address/index.js @@ -58,18 +58,13 @@ const Address = ({ > {loading ? ( userAddressId !== address?.id ? ( - + ) : ( { - return theme === 'light'; - },[theme]); + return theme === "light"; + }, [theme]); return ( @@ -117,7 +112,9 @@ const Address = ({ style={[ { backgroundColor: light ? Colors.theme1.grayE3 + "44" : null, - borderColor: light ? Colors.theme1.gray2077 + "55" : Colors.theme1.grayE3, + borderColor: light + ? Colors.theme1.gray2077 + "55" + : Colors.theme1.grayE3, borderWidth: 1.5, }, tw( diff --git a/src/screens/Home/components/MyBooks.js b/src/screens/Home/components/MyBooks.js index b5250b9..873f64a 100644 --- a/src/screens/Home/components/MyBooks.js +++ b/src/screens/Home/components/MyBooks.js @@ -20,6 +20,7 @@ import fontSize from "../../../constants/fontSize"; const ios = Platform.OS === "ios"; function MyBooks({ books, grades, theme }) { + console.log(books); return books?.filter((book) => book.condition >= 2).length ? ( - + {/* */} diff --git a/src/screens/Product/components/Book.js b/src/screens/Product/components/Book.js index 5d2535d..13c8dfc 100644 --- a/src/screens/Product/components/Book.js +++ b/src/screens/Product/components/Book.js @@ -53,6 +53,18 @@ function Book({ }, 500); }, [type]); + const physicalProduct = React.useMemo(() => { + return book?.product?.filter((product) => product?.productType === 2)[0]; + }); + + const digitalProduct = React.useMemo(() => { + return book?.product?.filter((product) => product?.productType === 1)[0]; + }); + + const videoProduct = React.useMemo(() => { + return book?.product?.filter((product) => product?.productType === 4)[0]; + }); + const physicalAvailabileInCart = React.useMemo(() => { return userProducts?.filter( (product) => product?.productId === book?.product[1]?.id @@ -206,7 +218,15 @@ function Book({ }} > {" "} - {"فیزیکی- دیجیتالی - ویدئو" + "\n" + "در دسترس"} + {`${ + videoProduct + ? "ویدئو" + : "" + physicalProduct + ? "فیزیکی" + : "" + digitalProduct + ? "دیجیتال" + : "" + } \n در دسترس`} - - 1 ? ( + + - نسخه محصول را انتخاب کنید - - - + fontSize: mobile ? fontSize.tiny : fontSize.lg, + fontFamily: "demi", + }, + ]} + > + نسخه محصول را انتخاب کنید + + + + ) : null} - - physicalAvailabileInCart - ? asyncAwesomeAlert( - "", - "این محصول قبلا به سبد خرید شما اضافه شده است.", - { - showCancelButton: true, - onConfirm: () => - navigation.navigate("Root", { - screen: "ShoppingCartTab", - }), - confirmText: "مشاهده سبد خرید", - cancelText: "باشه", + {physicalProduct ? ( + + physicalAvailabileInCart + ? asyncAwesomeAlert( + "", + "این محصول قبلا به سبد خرید شما اضافه شده است.", + { + showCancelButton: true, + onConfirm: () => + navigation.navigate("Root", { + screen: "ShoppingCartTab", + }), + confirmText: "مشاهده سبد خرید", + cancelText: "باشه", + } + ) + : addToCart( + pushToCart({ + productId: physicalProduct?.id, + userId: userId, + count: 1, + }), + "physical" + ) + } + > + <> + {whichTypeAdded === "physical" && userProductsLoading ? ( + - <> - {whichTypeAdded === "physical" && userProductsLoading ? ( - + ) : ( + + خرید نسخه فیزیکی کتاب + + )} + + + + + + {(separate(physicalProduct?.price) || " ") + " " + "تومان"} + + + + + + ) : null} + {physicalProduct ? ( + + navigation.push("Sample", { id: book?.sampleFileId }) + } + > + - ) : ( - + مشاهده نمونه + + + ) : null} + + {digitalProduct ? ( + + digitalAvailabileInCart + ? asyncAwesomeAlert( + "", + "این محصول قبلا به سبد خرید شما اضافه شده است.", + { + showCancelButton: true, + onConfirm: () => + navigation.navigate("Root", { + screen: "ShoppingCartTab", + }), + confirmText: "مشاهده سبد خرید", + cancelText: "باشه", + } + ) + : addToCart( + pushToCart({ + productId: digitalProduct?.id, + userId: userId, + count: 1, + }), + "digital" + ) + } + > + <> + {whichTypeAdded === "digital" && userProductsLoading ? ( + - خرید نسخه فیزیکی کتاب - - )} + : Colors.theme1.greenCF + } + size={fontSize.sm} + /> + ) : ( + - + paddingVertical: 4, + }} + > + خرید نسخه دیجیتال کتاب + + )} - {(separate(book?.product[1]?.price) || " ") + " " + "تومان"} + {(separate(digitalProduct?.price) || " ") + " " + "تومان"} - - - - - digitalAvailabileInCart - ? asyncAwesomeAlert( - "", - "این محصول قبلا به سبد خرید شما اضافه شده است.", - { - showCancelButton: true, - onConfirm: () => - navigation.navigate("Root", { - screen: "ShoppingCartTab", - }), - confirmText: "مشاهده سبد خرید", - cancelText: "باشه", - } - ) - : addToCart( - pushToCart({ - productId: book?.product[0]?.id, - userId: userId, - count: 1, - }), - "digital" - ) - } - > - <> - {whichTypeAdded === "digital" && userProductsLoading ? ( - + + ) : null} + {digitalProduct ? ( + navigation.navigate("Video", { id: book?.id })} + > + - ) : ( - - خرید نسخه دیجیتال کتاب - - )} - - - {(separate(book?.product[0]?.price) || " ") + " " + "تومان"} - - - - - navigation.push("Sample", { id: book?.sampleFileId })} - > - + پیش نمایش + + + ) : null} - paddingVertical: 4, - }} + {videoProduct ? ( + + videoAvailabileInCart + ? asyncAwesomeAlert( + "", + "این محصول قبلا به سبد خرید شما اضافه شده است.", + { + showCancelButton: true, + onConfirm: () => + navigation.navigate("Root", { + screen: "ShoppingCartTab", + }), + confirmText: "مشاهده سبد خرید", + cancelText: "باشه", + } + ) + : addToCart( + pushToCart({ + productId: videoProduct?.id, + userId: userId, + count: 1, + }), + "video" + ) + } > - مشاهده نمونه - - - - videoAvailabileInCart - ? asyncAwesomeAlert( - "", - "این محصول قبلا به سبد خرید شما اضافه شده است.", - { - showCancelButton: true, - onConfirm: () => - navigation.navigate("Root", { - screen: "ShoppingCartTab", - }), - confirmText: "مشاهده سبد خرید", - cancelText: "باشه", - } - ) - : addToCart( - pushToCart({ - productId: book?.product[2]?.id, - userId: userId, - count: 1, - }), - "video" - ) - } - > - <> - {whichTypeAdded === "video" && userProductsLoading ? ( - - ) : ( - + {whichTypeAdded === "video" && userProductsLoading ? ( + - خرید دوره ویدئویی کتاب - - )} - - - + ) : ( + - {(separate(book?.product[2]?.price) || " ") + " " + "تومان"} - - - - - navigation.navigate("Video", { id: book?.id })} - > - + خرید دوره ویدئویی کتاب + + )} + + + - پیش نمایش - - + fontSize: fontSize.sm, + }, + ]} + > + {(separate(videoProduct?.price) || " ") + " " + "تومان"} + + + + + ) : null} - {console.log(book?.text)} {book?.text ? ( { value={filterOptions.search} /> - @@ -38,7 +38,7 @@ const Header = ({ setFilterOptions, filterOptions, levels, productTypes }) => { : setFilterOptions({ ...filterOptions, [name]: null }) } options={Object.values(levels)} - width={"48%"} + width={"100%"} name="grade" /> diff --git a/src/screens/Products/components/Main.js b/src/screens/Products/components/Main.js index e7938df..6c35bae 100644 --- a/src/screens/Products/components/Main.js +++ b/src/screens/Products/components/Main.js @@ -70,77 +70,82 @@ const Main = ({ books, filterOptions, grades, mobile, theme }) => { return filterOptions.productType === "دوره ویدئویی" ? bySearchFilter?.map((product, index) => ( - navigation.navigate("Video", { id: product.id })} - > - - - + // navigation.navigate("Video", { id: product.id })} + // > + // + // + // - - {"دوره ویدئویی" + " " + product?.name} - - - {"پایه" + " " + grades[product?.gradeId]} - - - {separate(product?.product[2]?.price)}{" "} - تومان - - + // + // {"دوره ویدئویی" + " " + product?.name} + // + // + // {"پایه" + " " + grades[product?.gradeId]} + // + // + // {separate( + // product?.product?.filter( + // (product) => product?.productType === 4 + // )[0].price + // )}{" "} + // تومان + // + // + <> )) : bySearchFilter?.map((product, index) => ( @@ -149,103 +154,108 @@ const Main = ({ books, filterOptions, grades, mobile, theme }) => { ? productType === ("کتاب دیجیتال" || "همه محصولات") : true ) ? ( - - navigation.navigate("Product", { - id: product?.id, - type: "book", - }) - } - > - - - - {"کتاب دیجیتال" + " " + product?.name} - - - {"پایه" + " " + grades[product?.gradeId]} - - - - - {separate(product?.product[0].price)} - - - تومان - - - + // + // navigation.navigate("Product", { + // id: product?.id, + // type: "book", + // }) + // } + // > + // + // + // + // {"کتاب دیجیتال" + " " + product?.name} + // + // + // {"پایه" + " " + grades[product?.gradeId]} + // + // + // + // + // {separate( + // product?.product?.filter( + // (product) => product?.productType === 1 + // )[0]?.price + // )} + // + // + // تومان + // + // + // + <> ) : null} {( productType @@ -333,7 +343,7 @@ const Main = ({ books, filterOptions, grades, mobile, theme }) => { }, ]} > - {separate(product?.product[1].price)} + {separate(product?.product[0].price)} { ), ]} > - {filterOptions?.productType === "دوره ویدئویی" ? Items(2) : null} - {filterOptions?.productType === "کتاب دیجیتال" ? Items(0) : null} + {/* {filterOptions?.productType === "دوره ویدئویی" ? Items(2) : null} */} + {/* {filterOptions?.productType === "کتاب دیجیتال" ? Items(0) : null} */} {filterOptions?.productType === "کتاب فیزیکی" ? Items(1) : null} {!filterOptions?.productType ? Items(0) : null} {/* {filterLoading && ( diff --git a/src/screens/Profile/components/ProfileAddress/index.js b/src/screens/Profile/components/ProfileAddress/index.js index 0ccb167..4c366a7 100644 --- a/src/screens/Profile/components/ProfileAddress/index.js +++ b/src/screens/Profile/components/ProfileAddress/index.js @@ -12,7 +12,9 @@ import { } from "react-native"; import React from "react"; import { connect } from "react-redux"; +import { asyncAwesomeAlert } from "../../../../utils/AsyncWrappers"; import { useNavigation } from "@react-navigation/native"; +import { Ionicons, Entypo } from "@expo/vector-icons"; import { userAddress, userFactor } from "../../../../redux/actions"; import Svg, { G, Path } from "react-native-svg"; @@ -36,7 +38,9 @@ const ProfileAddress = ({ userAddressId, getFactorInfo, mobile, - theme + loading, + theme, + deleteItem, }) => { const navigation = useNavigation(); const [height, setHeight] = React.useState(Dimensions.get("window").height); @@ -91,15 +95,11 @@ const ProfileAddress = ({ فعال - - - - - - + ) : null} @@ -157,22 +157,35 @@ const ProfileAddress = ({ {!active ? ( - - + + + + + asyncAwesomeAlert("", "آدرس مورد نظر حذف شود؟", { + showCancelButton: true, + confirmText: "بله", + cancelText: "لغو", + onConfirm: () => deleteItem({ id: address.id }), + }) + } > - - - - + + ) : null} - {}} - /> + /> */} ); @@ -281,13 +294,14 @@ const mapStateToProps = (state) => ({ loading: state.userFactor.loading, addresses: state.userAddress.list, mobile: state.publicApi.mobile, - theme: state.publicApi.theme + theme: state.publicApi.theme, }); const mapDispatchToProps = { getFactorInfo: userFactor.info, update: userFactor.update, getList: userAddress.list, + deleteItem: userAddress.del, }; export default connect(mapStateToProps, mapDispatchToProps)(ProfileAddress); @@ -298,7 +312,6 @@ const styles = StyleSheet.create({ position: "relative", }, container: { - backgroundColor: "white", flexDirection: "column", paddingVertical: 0, paddingHorizontal: 0, diff --git a/src/screens/Profile/components/User.js b/src/screens/Profile/components/User.js index 9872840..8ec2954 100644 --- a/src/screens/Profile/components/User.js +++ b/src/screens/Profile/components/User.js @@ -67,7 +67,7 @@ const User = ({ user, mobile, theme }) => { - { fill="#c6c6c6" data-name="vuesax/bold/arrow-down" /> - + */} - {dropdown ? ( + {/* {dropdown ? ( { - ) : null} + ) : null} */} ); }; diff --git a/src/screens/Profile/index.js b/src/screens/Profile/index.js index 0a6a14d..420d39f 100644 --- a/src/screens/Profile/index.js +++ b/src/screens/Profile/index.js @@ -65,7 +65,7 @@ function Profile({ mobile, theme, logout, loading }) { style={styles.container} > - + {/* */} - + {hasPermission ? ( + + ) : null} {/* {scanned && ( */}