reza fixed ar list and mybooks

master
Reza_ashrafi 3 years ago
parent 9d12b042ae
commit 44f163e073
  1. 13
      src/screens/AR/components/Book.js
  2. 28
      src/screens/AR/index.js
  3. 20
      src/screens/Home/components/MyBooks.js
  4. 9
      src/screens/Product/components/Rates.js

@ -14,13 +14,17 @@ const Book = ({ book, mobile, theme }) => {
return ( return (
<Pressable <Pressable
style={[ style={[
tw("flex items-end rounded-md p-2 my-2"), tw("flex rounded-md p-2 my-2"),
{ width: mobile ? "48%" : width / 4.2 }, { width: mobile ? "48%" : width / 4.2 },
]} ]}
onPress={() => Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book?.id}`)} onPress={() =>
Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book?.product?.ARId}`)
}
> >
<Image <Image
source={{ uri: `https://dnvn.ir/api/v1/file/${book?.fileId}` }} source={{
uri: `https://dnvn.ir/api/v1/file/${book?.product?.book?.fileIds}`,
}}
resizeMode="contain" resizeMode="contain"
style={[ style={[
tw("rounded-sm w-full"), tw("rounded-sm w-full"),
@ -38,10 +42,11 @@ const Book = ({ book, mobile, theme }) => {
marginTop: 10, marginTop: 10,
color: color:
theme === "light" ? Colors.theme1.green79 : Colors.theme1.white, theme === "light" ? Colors.theme1.green79 : Colors.theme1.white,
textAlign: "right",
}, },
]} ]}
> >
{book?.title} {book?.name}
</Text> </Text>
</Pressable> </Pressable>
); );

@ -23,11 +23,11 @@ import tw from "tailwind-rn";
const { height } = Dimensions.get("window"); const { height } = Dimensions.get("window");
const ios = Platform.OS === "ios"; const ios = Platform.OS === "ios";
function AR({ getArList, arList, mobile, theme }) { function AR({ getUserProducts, userProducts, mobile, theme }) {
const [position, setPosition] = useState("100%"); const [position, setPosition] = useState("100%");
useEffect(() => { useEffect(() => {
getArList(); getUserProducts();
StatusBar.setBarStyle( StatusBar.setBarStyle(
`${theme === "light" ? "dark" : "light"}-content`, `${theme === "light" ? "dark" : "light"}-content`,
true true
@ -67,7 +67,7 @@ function AR({ getArList, arList, mobile, theme }) {
}} }}
/> />
<Drawer setBoxPosition={setBoxPosition} position={position} /> <Drawer setBoxPosition={setBoxPosition} position={position} />
{arList?.length ? ( {userProducts?.length ? (
<ScrollView <ScrollView
style={{ style={{
paddingHorizontal: 16, paddingHorizontal: 16,
@ -75,14 +75,14 @@ function AR({ getArList, arList, mobile, theme }) {
}} }}
contentContainerStyle={{ paddingBottom: 60 }} contentContainerStyle={{ paddingBottom: 60 }}
> >
<View <View style={tw(`flex justify-between flex-wrap flex-row-reverse`)}>
style={tw( {userProducts
`flex justify-between flex-wrap ${ ?.filter(
ios ? "flex-row-reverse" : "flex-row" (product) =>
}` (product?.productType === 2 || product?.productType === 3) &&
)} product?.condition >= 2
> )
{arList?.map((book, index) => ( ?.map((book, index) => (
<Book book={book} key={index} /> <Book book={book} key={index} />
))} ))}
</View> </View>
@ -99,13 +99,13 @@ function AR({ getArList, arList, mobile, theme }) {
} }
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
arList: state.userProduct.arList, userProducts: state.userProduct.list,
mobile: state.publicApi.mobile, mobile: state.publicApi.mobile,
theme: state.publicApi.theme theme: state.publicApi.theme,
}); });
const mapDispatchToProps = { const mapDispatchToProps = {
getArList: userProduct.arList, getUserProducts: userProduct.list,
}; };
export default connect(mapStateToProps, mapDispatchToProps)(AR); export default connect(mapStateToProps, mapDispatchToProps)(AR);

@ -20,7 +20,11 @@ import fontSize from "../../../constants/fontSize";
const ios = Platform.OS === "ios"; const ios = Platform.OS === "ios";
function MyBooks({ books, grades, theme }) { 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 ? (
<View style={[tw("flex w-full mb-5")]}> <View style={[tw("flex w-full mb-5")]}>
<View <View
style={[ style={[
@ -69,20 +73,20 @@ function MyBooks({ books, grades, theme }) {
const Book = ({ book, grades, theme }) => { const Book = ({ book, grades, theme }) => {
const actions = { const actions = {
3: () => 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: () => 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: () => {}, 4: () => {},
}; };
return ( return (
<Pressable <Pressable
style={tw(`flex mr-4 ${ios ? "items-end" : ""}`)} style={tw(`flex mr-4 ${ios ? "items-end" : ""}`)}
onPress={actions[book.productType]} onPress={actions[book?.productType]}
> >
<View style={{ height: 165 }}> <View style={{ height: 165 }}>
<Image <Image
source={{ source={{
uri: `https://dnvn.ir/api/v1/file/${book.product.book.fileIds}`, uri: `https://dnvn.ir/api/v1/file/${book?.product?.book?.fileIds}`,
}} }}
resizeMode="contain" resizeMode="contain"
style={[ style={[
@ -100,11 +104,11 @@ const Book = ({ book, grades, theme }) => {
color: color:
theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white, theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white,
fontFamily: "bold", fontFamily: "bold",
fontSize: fontSize.sm, fontSize: fontSize.tiny,
}, },
]} ]}
> >
{book.product.book.name} {book?.name}
</Text> </Text>
<Text <Text
style={[ style={[
@ -117,7 +121,7 @@ const Book = ({ book, grades, theme }) => {
}, },
]} ]}
> >
{"پایه" + " " + grades[book.product.book.gradeId]} {"پایه" + " " + grades[book?.product?.book?.gradeId]}
</Text> </Text>
<Progress percent={60} alignItems={"items-end"} /> <Progress percent={60} alignItems={"items-end"} />
</Pressable> </Pressable>

@ -39,12 +39,15 @@ function Rates({ rate, productId, addVote, isBuyed = null, theme }) {
<Rating <Rating
type="star" type="star"
ratingCount={5} ratingCount={5}
imageSize={15} imageSize={width / 25}
tintColor={
theme === "light" ? Colors.theme1.white : Colors.theme1.dark
}
value={4} value={4}
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,
@ -53,7 +56,7 @@ function Rates({ rate, productId, addVote, isBuyed = null, theme }) {
}} }}
> >
{`از بین ${1150} نفر`} {`از بین ${1150} نفر`}
</Text> </Text> */}
</Pressable> </Pressable>
<View style={[tw("flex flex-1"), { width: "60%" }]}> <View style={[tw("flex flex-1"), { width: "60%" }]}>
{[ {[

Loading…
Cancel
Save