reza fixed ar list and mybooks

master
Reza_ashrafi 2 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 (
<Pressable
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 },
]}
onPress={() => Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book?.id}`)}
onPress={() =>
Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book?.product?.ARId}`)
}
>
<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"
style={[
tw("rounded-sm w-full"),
@ -38,10 +42,11 @@ const Book = ({ book, mobile, theme }) => {
marginTop: 10,
color:
theme === "light" ? Colors.theme1.green79 : Colors.theme1.white,
textAlign: "right",
},
]}
>
{book?.title}
{book?.name}
</Text>
</Pressable>
);

@ -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 }) {
}}
/>
<Drawer setBoxPosition={setBoxPosition} position={position} />
{arList?.length ? (
{userProducts?.length ? (
<ScrollView
style={{
paddingHorizontal: 16,
@ -75,14 +75,14 @@ function AR({ getArList, arList, mobile, theme }) {
}}
contentContainerStyle={{ paddingBottom: 60 }}
>
<View
style={tw(
`flex justify-between flex-wrap ${
ios ? "flex-row-reverse" : "flex-row"
}`
)}
>
{arList?.map((book, index) => (
<View style={tw(`flex justify-between flex-wrap flex-row-reverse`)}>
{userProducts
?.filter(
(product) =>
(product?.productType === 2 || product?.productType === 3) &&
product?.condition >= 2
)
?.map((book, index) => (
<Book book={book} key={index} />
))}
</View>
@ -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);

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

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

Loading…
Cancel
Save