From 44f163e073b55009b7974eb5b99149164c93021f Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Wed, 11 May 2022 21:48:21 +0430 Subject: [PATCH] reza fixed ar list and mybooks --- src/screens/AR/components/Book.js | 13 ++++++---- src/screens/AR/index.js | 32 ++++++++++++------------- src/screens/Home/components/MyBooks.js | 20 +++++++++------- src/screens/Home/index.js | 2 +- src/screens/Product/components/Rates.js | 9 ++++--- 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/src/screens/AR/components/Book.js b/src/screens/AR/components/Book.js index a46cce0..61606b2 100644 --- a/src/screens/AR/components/Book.js +++ b/src/screens/AR/components/Book.js @@ -14,13 +14,17 @@ const Book = ({ book, mobile, theme }) => { return ( Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book?.id}`)} + onPress={() => + Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book?.product?.ARId}`) + } > { marginTop: 10, color: theme === "light" ? Colors.theme1.green79 : Colors.theme1.white, + textAlign: "right", }, ]} > - {book?.title} + {book?.name} ); diff --git a/src/screens/AR/index.js b/src/screens/AR/index.js index 866241c..21ea9ac 100644 --- a/src/screens/AR/index.js +++ b/src/screens/AR/index.js @@ -23,11 +23,11 @@ import tw from "tailwind-rn"; const { height } = Dimensions.get("window"); const ios = Platform.OS === "ios"; -function AR({ getArList, arList, mobile, theme }) { +function AR({ getUserProducts, userProducts, mobile, theme }) { const [position, setPosition] = useState("100%"); useEffect(() => { - getArList(); + getUserProducts(); StatusBar.setBarStyle( `${theme === "light" ? "dark" : "light"}-content`, true @@ -67,7 +67,7 @@ function AR({ getArList, arList, mobile, theme }) { }} /> - {arList?.length ? ( + {userProducts?.length ? ( - - {arList?.map((book, index) => ( - - ))} + + {userProducts + ?.filter( + (product) => + (product?.productType === 2 || product?.productType === 3) && + product?.condition >= 2 + ) + ?.map((book, index) => ( + + ))} ) : ( @@ -99,13 +99,13 @@ function AR({ getArList, arList, mobile, theme }) { } const mapStateToProps = (state) => ({ - arList: state.userProduct.arList, + userProducts: state.userProduct.list, mobile: state.publicApi.mobile, - theme: state.publicApi.theme + theme: state.publicApi.theme, }); const mapDispatchToProps = { - getArList: userProduct.arList, + getUserProducts: userProduct.list, }; export default connect(mapStateToProps, mapDispatchToProps)(AR); diff --git a/src/screens/Home/components/MyBooks.js b/src/screens/Home/components/MyBooks.js index 62b3fa6..7048432 100644 --- a/src/screens/Home/components/MyBooks.js +++ b/src/screens/Home/components/MyBooks.js @@ -20,7 +20,11 @@ import fontSize from "../../../constants/fontSize"; const ios = Platform.OS === "ios"; function MyBooks({ books, grades, theme }) { - return books?.filter((book) => book?.condition >= 2).length ? ( + return books?.filter( + (book) => + (book?.productType === 2 || book?.productType === 3) && + book?.condition >= 2 + ).length ? ( { const actions = { 3: () => - Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book.product.book.id}`), + Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book?.product?.ARId}`), 2: () => - Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book.product.book.id}`), + Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book?.product?.ARId}`), 4: () => {}, }; return ( { color: theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white, fontFamily: "bold", - fontSize: fontSize.sm, + fontSize: fontSize.tiny, }, ]} > - {book.product.book.name} + {book?.name} { }, ]} > - {"پایه" + " " + grades[book.product.book.gradeId]} + {"پایه" + " " + grades[book?.product?.book?.gradeId]} diff --git a/src/screens/Home/index.js b/src/screens/Home/index.js index 053840e..b435053 100644 --- a/src/screens/Home/index.js +++ b/src/screens/Home/index.js @@ -55,7 +55,7 @@ const Home = ({ getUserProducts(); } }, [books, userProducts, blogs]); - + return ( addVote({ productId, vote: rating })} readonly={!isBuyed} /> - {`از بین ${1150} نفر`} - + */} {[