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