|
|
@ -9,6 +9,7 @@ import { |
|
|
|
Appearance, |
|
|
|
Appearance, |
|
|
|
Pressable, |
|
|
|
Pressable, |
|
|
|
Platform, |
|
|
|
Platform, |
|
|
|
|
|
|
|
ActivityIndicator |
|
|
|
} from "react-native"; |
|
|
|
} from "react-native"; |
|
|
|
import { useNavigation } from "@react-navigation/native"; |
|
|
|
import { useNavigation } from "@react-navigation/native"; |
|
|
|
import { product, userProduct } from "../../../redux/actions"; |
|
|
|
import { product, userProduct } from "../../../redux/actions"; |
|
|
@ -35,7 +36,15 @@ import Colors from "../../../constants/Colors"; |
|
|
|
const { height, width } = Dimensions.get("window"); |
|
|
|
const { height, width } = Dimensions.get("window"); |
|
|
|
const ios = Platform.OS === "ios"; |
|
|
|
const ios = Platform.OS === "ios"; |
|
|
|
|
|
|
|
|
|
|
|
function Book({ book, grades, pushToCart, userId, loading, mobile }) { |
|
|
|
function Book({ |
|
|
|
|
|
|
|
book, |
|
|
|
|
|
|
|
grades, |
|
|
|
|
|
|
|
pushToCart, |
|
|
|
|
|
|
|
userId, |
|
|
|
|
|
|
|
loading, |
|
|
|
|
|
|
|
mobile, |
|
|
|
|
|
|
|
userProducts, |
|
|
|
|
|
|
|
}) { |
|
|
|
const colorScheme = Appearance.getColorScheme(); |
|
|
|
const colorScheme = Appearance.getColorScheme(); |
|
|
|
const navigation = useNavigation(); |
|
|
|
const navigation = useNavigation(); |
|
|
|
const [type, setType] = useState(1); |
|
|
|
const [type, setType] = useState(1); |
|
|
@ -49,6 +58,14 @@ function Book({ book, grades, pushToCart, userId, loading, mobile }) { |
|
|
|
}, 500); |
|
|
|
}, 500); |
|
|
|
}, [type]); |
|
|
|
}, [type]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const physicalAvailabileInCart = userProducts?.filter( |
|
|
|
|
|
|
|
(product) => product?.productId === book?.product[1]?.id |
|
|
|
|
|
|
|
)[0]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const digitalAvailabileInCart = userProducts?.filter( |
|
|
|
|
|
|
|
(product) => product?.productId === book?.product[0]?.id |
|
|
|
|
|
|
|
)[0]; |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<ScrollView style={[tw("flex flex-col flex-1 relative")]}> |
|
|
|
<ScrollView style={[tw("flex flex-col flex-1 relative")]}> |
|
|
|
{!mobile && <View style={tw("mt-5")}></View>} |
|
|
|
{!mobile && <View style={tw("mt-5")}></View>} |
|
|
@ -69,10 +86,12 @@ function Book({ book, grades, pushToCart, userId, loading, mobile }) { |
|
|
|
)} |
|
|
|
)} |
|
|
|
{imageSlider && <ImageSlider />} |
|
|
|
{imageSlider && <ImageSlider />} |
|
|
|
<View style={tw("flex flex-row-reverse")}> |
|
|
|
<View style={tw("flex flex-row-reverse")}> |
|
|
|
|
|
|
|
|
|
|
|
<Image |
|
|
|
<Image |
|
|
|
source={{ uri: `https://dnvn.ir/api/v1/file/${book?.fileIds}` }} |
|
|
|
source={{ uri: `https://dnvn.ir/api/v1/file/${book?.fileIds}` }} |
|
|
|
style={[tw("rounded-md"), { height : height / 4, width : height / 4 * 3 / 4}]} |
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("rounded-md"), |
|
|
|
|
|
|
|
{ height: height / 4, width: ((height / 4) * 3) / 4 }, |
|
|
|
|
|
|
|
]} |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<View |
|
|
|
<View |
|
|
@ -190,7 +209,9 @@ function Book({ book, grades, pushToCart, userId, loading, mobile }) { |
|
|
|
<View style={tw("flex flex-row-reverse justify-between flex-wrap py-3")}> |
|
|
|
<View style={tw("flex flex-row-reverse justify-between flex-wrap py-3")}> |
|
|
|
<Pressable |
|
|
|
<Pressable |
|
|
|
style={[ |
|
|
|
style={[ |
|
|
|
tw("flex flex-row-reverse w-full justify-between px-2 py-3 mb-4"), |
|
|
|
tw( |
|
|
|
|
|
|
|
"flex flex-row-reverse w-full justify-between px-2 py-3 mb-4" |
|
|
|
|
|
|
|
), |
|
|
|
{ |
|
|
|
{ |
|
|
|
borderWidth: 1, |
|
|
|
borderWidth: 1, |
|
|
|
borderColor: Colors.theme1[colorScheme].greenCF, |
|
|
|
borderColor: Colors.theme1[colorScheme].greenCF, |
|
|
@ -215,8 +236,9 @@ function Book({ book, grades, pushToCart, userId, loading, mobile }) { |
|
|
|
> |
|
|
|
> |
|
|
|
خرید نسخه فیزیکی کتاب |
|
|
|
خرید نسخه فیزیکی کتاب |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
<View style={tw("flex flex-row-reverse")}> |
|
|
|
<View style={tw("flex flex-row-reverse items-center")}> |
|
|
|
<View style={tw("w-px h-full bg-green-500")}></View> |
|
|
|
<View style={tw("w-px h-full bg-green-300")}></View> |
|
|
|
|
|
|
|
<View style={tw("flex")}> |
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={[ |
|
|
|
style={[ |
|
|
|
tw("py-1 pr-2"), |
|
|
|
tw("py-1 pr-2"), |
|
|
@ -231,6 +253,96 @@ function Book({ book, grades, pushToCart, userId, loading, mobile }) { |
|
|
|
> |
|
|
|
> |
|
|
|
{separate(book?.product[1]?.price) + " " + "تومان"} |
|
|
|
{separate(book?.product[1]?.price) + " " + "تومان"} |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
|
|
|
|
{physicalAvailabileInCart && ( |
|
|
|
|
|
|
|
<View |
|
|
|
|
|
|
|
style={tw( |
|
|
|
|
|
|
|
`flex items-center pl-3 ${ |
|
|
|
|
|
|
|
ios ? "flex-row-reverse" : "flex-row-reverse" |
|
|
|
|
|
|
|
}` |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Pressable |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
pushToCart({ |
|
|
|
|
|
|
|
productId: physicalAvailabileInCart?.productId, |
|
|
|
|
|
|
|
userId: physicalAvailabileInCart.userId, |
|
|
|
|
|
|
|
count: 1, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw( |
|
|
|
|
|
|
|
`rounded-md py-0 flex flex-row justify-center items-center border ${ |
|
|
|
|
|
|
|
mobile ? "px-1.5" : "px-3" |
|
|
|
|
|
|
|
}` |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
borderColor: Colors.theme1[colorScheme].green79, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontSize: mobile ? fontSize.tiny : fontSize.xl4, |
|
|
|
|
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
+ |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</Pressable> |
|
|
|
|
|
|
|
{loading ? ( |
|
|
|
|
|
|
|
<ActivityIndicator |
|
|
|
|
|
|
|
style={tw("mx-1.5 my-3")} |
|
|
|
|
|
|
|
size="small" |
|
|
|
|
|
|
|
color={Colors.theme1[colorScheme].greenBA} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("mx-1.5"), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fontSize: fontSize.xl6, |
|
|
|
|
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{physicalAvailabileInCart?.count} |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Pressable |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
pushToCart({ |
|
|
|
|
|
|
|
productId: physicalAvailabileInCart?.productId, |
|
|
|
|
|
|
|
userId: physicalAvailabileInCart?.userId, |
|
|
|
|
|
|
|
count: -1, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw( |
|
|
|
|
|
|
|
`rounded-md flex flex-row justify-center items-center border ${ |
|
|
|
|
|
|
|
mobile ? "px-2" : "px-3.5" |
|
|
|
|
|
|
|
}` |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
borderColor: Colors.theme1[colorScheme].green79, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontSize: mobile ? fontSize.tiny : fontSize.xl4, |
|
|
|
|
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
|
|
|
|
fontFamily: "demi", |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
- |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</Pressable> |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</Pressable> |
|
|
|
</Pressable> |
|
|
|
<Pressable |
|
|
|
<Pressable |
|
|
@ -261,8 +373,7 @@ function Book({ book, grades, pushToCart, userId, loading, mobile }) { |
|
|
|
> |
|
|
|
> |
|
|
|
خرید نسخه دیجیتال کتاب |
|
|
|
خرید نسخه دیجیتال کتاب |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
<View style={tw("flex flex-row-reverse")}> |
|
|
|
<View style={tw("flex")}> |
|
|
|
<View style={tw("w-px h-full bg-green-500")}></View> |
|
|
|
|
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={[ |
|
|
|
style={[ |
|
|
|
tw("py-1 pr-2"), |
|
|
|
tw("py-1 pr-2"), |
|
|
@ -277,6 +388,95 @@ function Book({ book, grades, pushToCart, userId, loading, mobile }) { |
|
|
|
> |
|
|
|
> |
|
|
|
{separate(book?.product[0]?.price) + " " + "تومان"} |
|
|
|
{separate(book?.product[0]?.price) + " " + "تومان"} |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
|
|
|
|
{digitalAvailabileInCart && ( |
|
|
|
|
|
|
|
<View |
|
|
|
|
|
|
|
style={tw( |
|
|
|
|
|
|
|
`flex items-center pl-3 ${ |
|
|
|
|
|
|
|
ios ? "flex-row-reverse" : "flex-row-reverse" |
|
|
|
|
|
|
|
}` |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Pressable |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
pushToCart({ |
|
|
|
|
|
|
|
productId: digitalAvailabileInCart?.productId, |
|
|
|
|
|
|
|
userId: digitalAvailabileInCart.userId, |
|
|
|
|
|
|
|
count: 1, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw( |
|
|
|
|
|
|
|
`rounded-md py-0 flex flex-row justify-center items-center border ${ |
|
|
|
|
|
|
|
mobile ? "px-1.5" : "px-3" |
|
|
|
|
|
|
|
}` |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
borderColor: Colors.theme1[colorScheme].green79, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontSize: mobile ? fontSize.tiny : fontSize.xl4, |
|
|
|
|
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
+ |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</Pressable> |
|
|
|
|
|
|
|
{loading ? ( |
|
|
|
|
|
|
|
<ActivityIndicator |
|
|
|
|
|
|
|
style={tw("mx-1.5 my-3")} |
|
|
|
|
|
|
|
size="small" |
|
|
|
|
|
|
|
color={Colors.theme1[colorScheme].greenBA} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("mx-1.5"), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fontSize: fontSize.xl6, |
|
|
|
|
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{digitalAvailabileInCart?.count} |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Pressable |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
pushToCart({ |
|
|
|
|
|
|
|
productId: digitalAvailabileInCart?.productId, |
|
|
|
|
|
|
|
userId: digitalAvailabileInCart?.userId, |
|
|
|
|
|
|
|
count: -1, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw( |
|
|
|
|
|
|
|
`rounded-md flex flex-row justify-center items-center border ${ |
|
|
|
|
|
|
|
mobile ? "px-2" : "px-3.5" |
|
|
|
|
|
|
|
}` |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
borderColor: Colors.theme1[colorScheme].green79, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontSize: mobile ? fontSize.tiny : fontSize.xl4, |
|
|
|
|
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
|
|
|
|
fontFamily: "demi", |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
- |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</Pressable> |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
)} |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</Pressable> |
|
|
|
</Pressable> |
|
|
|
<Pressable |
|
|
|
<Pressable |
|
|
@ -422,6 +622,7 @@ function Book({ book, grades, pushToCart, userId, loading, mobile }) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
|
|
|
|
userProducts: state.userProduct.list, |
|
|
|
userId: state.user.status?.id, |
|
|
|
userId: state.user.status?.id, |
|
|
|
loading: state.userProduct.loading, |
|
|
|
loading: state.userProduct.loading, |
|
|
|
mobile: state.publicApi.mobile, |
|
|
|
mobile: state.publicApi.mobile, |
|
|
|