|
|
@ -1,5 +1,4 @@ |
|
|
|
import { t } from "i18next"; |
|
|
|
import React, { useState } from "react"; |
|
|
|
import React from "react"; |
|
|
|
|
|
|
|
import { |
|
|
|
import { |
|
|
|
View, |
|
|
|
View, |
|
|
|
Text, |
|
|
|
Text, |
|
|
@ -8,24 +7,28 @@ import { |
|
|
|
ScrollView, |
|
|
|
ScrollView, |
|
|
|
Pressable, |
|
|
|
Pressable, |
|
|
|
} from "react-native"; |
|
|
|
} from "react-native"; |
|
|
|
import { Entypo } from '@expo/vector-icons'; |
|
|
|
import { Entypo } from "@expo/vector-icons"; |
|
|
|
import CustomPressable from "../../../components/Pressable"; |
|
|
|
import CustomPressable from "../../../components/Pressable"; |
|
|
|
import Description from "./Description"; |
|
|
|
import Description from "./Description"; |
|
|
|
import LinkBox from "./LinkBox"; |
|
|
|
import LinkBox from "./LinkBox"; |
|
|
|
import Comments from "./Comments"; |
|
|
|
import Comments from "./Comments"; |
|
|
|
import Rates from "./Rates"; |
|
|
|
import Rates from "./Rates"; |
|
|
|
import tw from "tailwind-react-native-classnames"; |
|
|
|
import tw from "tailwind-react-native-classnames"; |
|
|
|
|
|
|
|
import fontSize from "../../../constants/fontSize"; |
|
|
|
|
|
|
|
import { product, userProduct } from "../../../redux/actions"; |
|
|
|
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
|
|
|
|
|
|
|
const width = Dimensions.get("window").width; |
|
|
|
const width = Dimensions.get("window").width; |
|
|
|
const height = Dimensions.get("window").height; |
|
|
|
const height = Dimensions.get("window").height; |
|
|
|
|
|
|
|
|
|
|
|
export default function Book({ product }) { |
|
|
|
function Book({ book, grades, pushToCart, userId }) { |
|
|
|
|
|
|
|
const [type, setType] = useState(1); |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<ScrollView style={[tw.style("flex flex-col flex-1")]}> |
|
|
|
<ScrollView style={[tw.style("flex flex-col flex-1")]}> |
|
|
|
<View style={tw.style("flex flex-row-reverse")}> |
|
|
|
<View style={tw.style("flex flex-row-reverse")}> |
|
|
|
<View style={[tw.style("rounded-md"), { height: 160, width: 110 }]}> |
|
|
|
<View style={[tw.style("rounded-md"), { height: 160, width: 110 }]}> |
|
|
|
<Image |
|
|
|
<Image |
|
|
|
source={{ uri: product.imageUrl }} |
|
|
|
source={{ uri: `https://dnvn.ir/api/v1/file/${book.fileIds}` }} |
|
|
|
style={[tw.style("rounded-md h-full w-full")]} |
|
|
|
style={[tw.style("rounded-md h-full w-full")]} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</View> |
|
|
|
</View> |
|
|
@ -42,30 +45,30 @@ export default function Book({ product }) { |
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
color: "#05335F", |
|
|
|
color: "#05335F", |
|
|
|
fontSize: width / 18, |
|
|
|
fontSize: fontSize.xl2, |
|
|
|
marginBottom: 5, |
|
|
|
marginBottom: 5, |
|
|
|
fontFamily: "bold", |
|
|
|
fontFamily: "bold", |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
{product.name} |
|
|
|
{book.product[type].name} |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
color: "#196EC0", |
|
|
|
color: "#196EC0", |
|
|
|
fontSize: width / 37, |
|
|
|
fontSize: fontSize.sm, |
|
|
|
fontFamily: "light", |
|
|
|
fontFamily: "light", |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
{product.grade} |
|
|
|
{"پایه" + " " + grades[book.gradeId]} |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={[ |
|
|
|
style={[ |
|
|
|
tw.style("text-right w-full"), |
|
|
|
tw.style("text-right w-full"), |
|
|
|
{ color: "#323232", fontSize: width / 38, fontFamily: "light" }, |
|
|
|
{ color: "#323232", fontSize: fontSize.sm, fontFamily: "light" }, |
|
|
|
]} |
|
|
|
]} |
|
|
|
> |
|
|
|
> |
|
|
|
{product.text} |
|
|
|
{book.text} |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
@ -79,12 +82,12 @@ export default function Book({ product }) { |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
color: "#196EC0", |
|
|
|
color: "#196EC0", |
|
|
|
textAlign: "center", |
|
|
|
textAlign: "center", |
|
|
|
fontSize: width / 37, |
|
|
|
fontSize: fontSize.sm, |
|
|
|
fontFamily: "light", |
|
|
|
fontFamily: "light", |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
{" "} |
|
|
|
{" "} |
|
|
|
{473 + "\n" + "صفحه"} |
|
|
|
{book.pagesNum + "\n" + "صفحه"} |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
<View |
|
|
|
<View |
|
|
@ -95,7 +98,7 @@ export default function Book({ product }) { |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
color: "#196EC0", |
|
|
|
color: "#196EC0", |
|
|
|
textAlign: "center", |
|
|
|
textAlign: "center", |
|
|
|
fontSize: width / 37, |
|
|
|
fontSize: fontSize.sm, |
|
|
|
fontFamily: "light", |
|
|
|
fontFamily: "light", |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
@ -111,7 +114,7 @@ export default function Book({ product }) { |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
color: "#196EC0", |
|
|
|
color: "#196EC0", |
|
|
|
textAlign: "center", |
|
|
|
textAlign: "center", |
|
|
|
fontSize: width / 37, |
|
|
|
fontSize: fontSize.sm, |
|
|
|
fontFamily: "light", |
|
|
|
fontFamily: "light", |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
@ -124,7 +127,7 @@ export default function Book({ product }) { |
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={[ |
|
|
|
style={[ |
|
|
|
tw.style("w-full text-right font-medium"), |
|
|
|
tw.style("w-full text-right font-medium"), |
|
|
|
{ color: "#196EC0", fontSize: width / 36, fontFamily: "regular" }, |
|
|
|
{ color: "#196EC0", fontSize: fontSize.sm, fontFamily: "regular" }, |
|
|
|
]} |
|
|
|
]} |
|
|
|
> |
|
|
|
> |
|
|
|
نسخه محصول را انتخاب کنید |
|
|
|
نسخه محصول را انتخاب کنید |
|
|
@ -136,24 +139,33 @@ export default function Book({ product }) { |
|
|
|
> |
|
|
|
> |
|
|
|
<CustomPressable |
|
|
|
<CustomPressable |
|
|
|
title={"نسخه فیزیکی"} |
|
|
|
title={"نسخه فیزیکی"} |
|
|
|
backgroundColor="transparent" |
|
|
|
onPress={() => setType(1)} |
|
|
|
color={"#196EC0"} |
|
|
|
backgroundColor={type === 0 ? "transparent" : "#196EC0"} |
|
|
|
|
|
|
|
color={type === 0 ? "#196EC0" : "white"} |
|
|
|
border={{ color: "#196EC0", width: 1 }} |
|
|
|
border={{ color: "#196EC0", width: 1 }} |
|
|
|
width={"49%"} |
|
|
|
width={"49%"} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<CustomPressable |
|
|
|
<CustomPressable |
|
|
|
|
|
|
|
onPress={() => setType(0)} |
|
|
|
title={"نسخه دیجیتال"} |
|
|
|
title={"نسخه دیجیتال"} |
|
|
|
backgroundColor="transparent" |
|
|
|
backgroundColor={type === 1 ? "transparent" : "#196EC0"} |
|
|
|
color={"#196EC0"} |
|
|
|
color={type === 1 ? "#196EC0" : "white"} |
|
|
|
border={{ color: "#196EC0", width: 1 }} |
|
|
|
border={{ color: "#196EC0", width: 1 }} |
|
|
|
width={"49%"} |
|
|
|
width={"49%"} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<CustomPressable |
|
|
|
<CustomPressable |
|
|
|
title={"خرید با قیمت 245.000 تومان"} |
|
|
|
title={`خرید با قیمت ${book.product[type].price} تومان`} |
|
|
|
backgroundColor="#196EC0" |
|
|
|
backgroundColor="#196EC0" |
|
|
|
color={"white"} |
|
|
|
color={"white"} |
|
|
|
border={{ color: "#196EC0", width: 0 }} |
|
|
|
border={{ color: "#196EC0", width: 0 }} |
|
|
|
width={"65%"} |
|
|
|
width={"65%"} |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
pushToCart({ |
|
|
|
|
|
|
|
productId: book?.product[type]?.id, |
|
|
|
|
|
|
|
userId: userId, |
|
|
|
|
|
|
|
count: 1, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<CustomPressable |
|
|
|
<CustomPressable |
|
|
|
title={"مشاهده نمونه"} |
|
|
|
title={"مشاهده نمونه"} |
|
|
@ -174,31 +186,53 @@ export default function Book({ product }) { |
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={[ |
|
|
|
style={[ |
|
|
|
tw.style(""), |
|
|
|
tw.style(""), |
|
|
|
{ color: "#275077", fontSize: width / 36, fontFamily: "light" }, |
|
|
|
{ color: "#275077", fontSize: fontSize.sm, fontFamily: "light" }, |
|
|
|
]} |
|
|
|
]} |
|
|
|
> |
|
|
|
> |
|
|
|
مشاهده دوره ویدئویی این محصول |
|
|
|
مشاهده دوره ویدئویی این محصول |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
</Pressable> |
|
|
|
</Pressable> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
<Description description={product.description} /> |
|
|
|
{book.product[type].description && ( |
|
|
|
|
|
|
|
<Description description={book.description} /> |
|
|
|
|
|
|
|
)} |
|
|
|
<LinkBox title="مشخصات محصول" path="" /> |
|
|
|
<LinkBox title="مشخصات محصول" path="" /> |
|
|
|
<LinkBox title="نقد بررسی و توضیحات تکمیلی محصول" path="" /> |
|
|
|
<LinkBox title="نقد بررسی و توضیحات تکمیلی محصول" path="" /> |
|
|
|
<LinkBox title="پرسش و پاسخ" path="" /> |
|
|
|
<LinkBox title="پرسش و پاسخ" path="" /> |
|
|
|
|
|
|
|
{product.rates && ( |
|
|
|
<View |
|
|
|
<View |
|
|
|
style={tw.style( |
|
|
|
style={tw.style( |
|
|
|
"flex flex-row-reverse justify-between items-center my-6" |
|
|
|
"flex flex-row-reverse justify-between items-center my-6" |
|
|
|
)} |
|
|
|
)} |
|
|
|
> |
|
|
|
> |
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={[{ fontSize: width / 36, color: "#275077", fontFamily: "regular"}, tw.style("")]} |
|
|
|
style={[ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
|
|
|
color: "#275077", |
|
|
|
|
|
|
|
fontFamily: "regular", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
tw.style(""), |
|
|
|
|
|
|
|
]} |
|
|
|
> |
|
|
|
> |
|
|
|
امتیازات و نظرات |
|
|
|
امتیازات و نظرات |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
<Entypo name="chevron-small-left" size={20} color="#196EC0" /> |
|
|
|
<Entypo name="chevron-small-left" size={20} color="#196EC0" /> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
<Rates rates={product.rates} /> |
|
|
|
)} |
|
|
|
<Comments comments={product.comments} /> |
|
|
|
|
|
|
|
|
|
|
|
{/* <Rates rates={book.rates} /> */} |
|
|
|
|
|
|
|
<Comments comments={book.comments} /> |
|
|
|
</ScrollView> |
|
|
|
</ScrollView> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
|
|
|
|
userId: state.user.status.id, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
|
|
|
|
pushToCart: userProduct.add, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Book); |
|
|
|