|
|
@ -18,7 +18,6 @@ import separate from "../../../utils/separate"; |
|
|
|
//components
|
|
|
|
//components
|
|
|
|
import LinkBox from "./LinkBox"; |
|
|
|
import LinkBox from "./LinkBox"; |
|
|
|
import Comments from "./Comments"; |
|
|
|
import Comments from "./Comments"; |
|
|
|
import ImageSlider from "../../../components/ImageSlider"; |
|
|
|
|
|
|
|
import Rates from "./Rates"; |
|
|
|
import Rates from "./Rates"; |
|
|
|
|
|
|
|
|
|
|
|
//style
|
|
|
|
//style
|
|
|
@ -39,20 +38,23 @@ function Book({ |
|
|
|
userProducts, |
|
|
|
userProducts, |
|
|
|
theme, |
|
|
|
theme, |
|
|
|
orientation, |
|
|
|
orientation, |
|
|
|
|
|
|
|
availableForSell, |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
const [width, setWidth] = React.useState(Dimensions.get("window").width); |
|
|
|
const [width, setWidth] = React.useState(Dimensions.get("window").width); |
|
|
|
const navigation = useNavigation(); |
|
|
|
const navigation = useNavigation(); |
|
|
|
const [type, setType] = useState(1); |
|
|
|
|
|
|
|
const [whichTypeAdded, setWhichTypeAdded] = React.useState(null); |
|
|
|
const [whichTypeAdded, setWhichTypeAdded] = React.useState(null); |
|
|
|
const [pageLoading, setPageLoading] = useState(false); |
|
|
|
|
|
|
|
const [imageSlider, setImageSlider] = useState(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
const physicalAvailableForSell = React.useMemo(() => { |
|
|
|
setPageLoading(true); |
|
|
|
return availableForSell?.filter((product) => product === 2)?.length; |
|
|
|
setTimeout(() => { |
|
|
|
}, [availableForSell]); |
|
|
|
setPageLoading(false); |
|
|
|
|
|
|
|
}, 500); |
|
|
|
const digitalAvailableForSell = React.useMemo(() => { |
|
|
|
}, [type]); |
|
|
|
return availableForSell?.filter((product) => product === 1)?.length; |
|
|
|
|
|
|
|
}, [availableForSell]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const videoAvailableForSell = React.useMemo(() => { |
|
|
|
|
|
|
|
return availableForSell?.filter((product) => product === 4)?.length; |
|
|
|
|
|
|
|
}, [availableForSell]); |
|
|
|
|
|
|
|
|
|
|
|
const physicalProduct = React.useMemo(() => { |
|
|
|
const physicalProduct = React.useMemo(() => { |
|
|
|
return book?.product?.filter((product) => product?.productType === 2)[0]; |
|
|
|
return book?.product?.filter((product) => product?.productType === 2)[0]; |
|
|
@ -134,6 +136,144 @@ function Book({ |
|
|
|
} |
|
|
|
} |
|
|
|
}, [userProducts]); |
|
|
|
}, [userProducts]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ProductButton = ({ |
|
|
|
|
|
|
|
availableInCart, |
|
|
|
|
|
|
|
availableForSell, |
|
|
|
|
|
|
|
product, |
|
|
|
|
|
|
|
type, |
|
|
|
|
|
|
|
onLoad, |
|
|
|
|
|
|
|
title, |
|
|
|
|
|
|
|
sample, |
|
|
|
|
|
|
|
sampleAction, |
|
|
|
|
|
|
|
}) => { |
|
|
|
|
|
|
|
return product ? ( |
|
|
|
|
|
|
|
<View style={tw("w-full flex flex-row-reverse justify-between")}> |
|
|
|
|
|
|
|
<TouchableHighlight |
|
|
|
|
|
|
|
underlayColor={Colors.theme1.greenFF + "22"} |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("flex flex-row-reverse justify-between px-2 py-3 mb-4"), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
borderWidth: 1, |
|
|
|
|
|
|
|
borderColor: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
backgroundColor: |
|
|
|
|
|
|
|
theme === "light" ? Colors.theme1.greenFF + "0a" : null, |
|
|
|
|
|
|
|
width: width - 32 - 8 - (fontSize.sm * 6 + 18), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
availableInCart |
|
|
|
|
|
|
|
? asyncAwesomeAlert( |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
"این محصول قبلا به سبد خرید شما اضافه شده است.", |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
showCancelButton: true, |
|
|
|
|
|
|
|
onConfirm: () => |
|
|
|
|
|
|
|
navigation.navigate("Root", { |
|
|
|
|
|
|
|
screen: "ShoppingCartTab", |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
confirmText: "مشاهده سبد خرید", |
|
|
|
|
|
|
|
cancelText: "باشه", |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
: availableForSell |
|
|
|
|
|
|
|
? addToCart( |
|
|
|
|
|
|
|
pushToCart({ |
|
|
|
|
|
|
|
productId: product?.id, |
|
|
|
|
|
|
|
userId: userId, |
|
|
|
|
|
|
|
count: 1, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
type |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
: null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<> |
|
|
|
|
|
|
|
{onLoad ? ( |
|
|
|
|
|
|
|
<ActivityIndicator |
|
|
|
|
|
|
|
color={ |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
size={fontSize.sm} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
|
|
|
color: |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paddingVertical: 4, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{title} |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<View style={tw("flex flex-row-reverse items-center")}> |
|
|
|
|
|
|
|
<View style={tw("w-px h-full bg-green-300")}></View> |
|
|
|
|
|
|
|
<View style={tw("flex")}> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("py-1 pr-2"), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
color: |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{availableForSell |
|
|
|
|
|
|
|
? (separate(product?.price) || " ") + " " + "تومان" |
|
|
|
|
|
|
|
: "ناموجود"} |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
</TouchableHighlight> |
|
|
|
|
|
|
|
{sample ? ( |
|
|
|
|
|
|
|
<TouchableHighlight |
|
|
|
|
|
|
|
underlayColor={Colors.theme1.greenFF + "22"} |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("flex flex-row-reverse justify-center px-2 py-3 mb-4"), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
borderWidth: 1, |
|
|
|
|
|
|
|
borderColor: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
backgroundColor: |
|
|
|
|
|
|
|
theme === "light" ? Colors.theme1.greenFF + "0a" : null, |
|
|
|
|
|
|
|
width: fontSize.sm * 6 + 18, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
onPress={() => sampleAction()} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
fontSize: fontSize.xs, |
|
|
|
|
|
|
|
color: |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paddingVertical: 4, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
مشاهده نمونه |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</TouchableHighlight> |
|
|
|
|
|
|
|
) : null} |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
) : null; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<View |
|
|
|
<View |
|
|
|
style={[tw("flex flex-1 relative")]} |
|
|
|
style={[tw("flex flex-1 relative")]} |
|
|
@ -263,360 +403,61 @@ function Book({ |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
{" "} |
|
|
|
{" "} |
|
|
|
{4.8 + "\n" + "امتیاز"} |
|
|
|
{book?.rate || 4 + "\n" + "امتیاز"} |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
{book?.product?.length > 1 ? ( |
|
|
|
{book?.product?.length > 1 ? ( |
|
|
|
<View style={"flex mt-8"}> |
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={[ |
|
|
|
style={[ |
|
|
|
tw("w-full text-right"), |
|
|
|
tw("w-full text-right"), |
|
|
|
{ |
|
|
|
{ |
|
|
|
color: |
|
|
|
color: |
|
|
|
theme === "light" ? Colors.theme1.green79 : Colors.theme1.white, |
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.white, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fontSize: mobile ? fontSize.tiny : fontSize.base, |
|
|
|
fontSize: mobile ? fontSize.tiny : fontSize.base, |
|
|
|
fontFamily: "demi", |
|
|
|
fontFamily: "demi", |
|
|
|
}, |
|
|
|
}, |
|
|
|
]} |
|
|
|
]} |
|
|
|
> |
|
|
|
> |
|
|
|
نسخه محصول را انتخاب کنید |
|
|
|
نسخه محصول را انتخاب کنید |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
<View style={tw("flex justify-between")}></View> |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
) : null} |
|
|
|
) : null} |
|
|
|
<View style={tw("flex flex-row-reverse justify-between flex-wrap py-3")}> |
|
|
|
<View style={tw("mt-4")}> |
|
|
|
{physicalProduct ? ( |
|
|
|
<ProductButton |
|
|
|
<TouchableHighlight |
|
|
|
product={physicalProduct} |
|
|
|
underlayColor={Colors.theme1.greenFF + "22"} |
|
|
|
availableForSell={physicalAvailableForSell} |
|
|
|
style={[ |
|
|
|
availableInCart={physicalAvailabileInCart} |
|
|
|
tw("flex flex-row-reverse justify-between px-2 py-3 mb-4"), |
|
|
|
type="physical" |
|
|
|
{ |
|
|
|
onLoad={whichTypeAdded === "physical" && userProductsLoading} |
|
|
|
borderWidth: 1, |
|
|
|
title="خرید نسخه فیزیکی کتاب" |
|
|
|
borderColor: Colors.theme1.greenCF, |
|
|
|
sample={true} |
|
|
|
backgroundColor: |
|
|
|
sampleAction={() => |
|
|
|
theme === "light" ? Colors.theme1.greenFF + "0a" : null, |
|
|
|
navigation.push("Sample", { id: book?.sampleFileId }) |
|
|
|
width: width - 32 - 8 - (fontSize.sm * 6 + 18), |
|
|
|
} |
|
|
|
}, |
|
|
|
/> |
|
|
|
]} |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
physicalAvailabileInCart |
|
|
|
|
|
|
|
? asyncAwesomeAlert( |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
"این محصول قبلا به سبد خرید شما اضافه شده است.", |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
showCancelButton: true, |
|
|
|
|
|
|
|
onConfirm: () => |
|
|
|
|
|
|
|
navigation.navigate("Root", { |
|
|
|
|
|
|
|
screen: "ShoppingCartTab", |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
confirmText: "مشاهده سبد خرید", |
|
|
|
|
|
|
|
cancelText: "باشه", |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
: addToCart( |
|
|
|
|
|
|
|
pushToCart({ |
|
|
|
|
|
|
|
productId: physicalProduct?.id, |
|
|
|
|
|
|
|
userId: userId, |
|
|
|
|
|
|
|
count: 1, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
"physical" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<> |
|
|
|
|
|
|
|
{whichTypeAdded === "physical" && userProductsLoading ? ( |
|
|
|
|
|
|
|
<ActivityIndicator |
|
|
|
|
|
|
|
color={ |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
size={fontSize.sm} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
|
|
|
color: |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paddingVertical: 4, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
خرید نسخه فیزیکی کتاب |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<View style={tw("flex flex-row-reverse items-center")}> |
|
|
|
|
|
|
|
<View style={tw("w-px h-full bg-green-300")}></View> |
|
|
|
|
|
|
|
<View style={tw("flex")}> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("py-1 pr-2"), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
color: |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{(separate(physicalProduct?.price) || " ") + " " + "تومان"} |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
</TouchableHighlight> |
|
|
|
|
|
|
|
) : null} |
|
|
|
|
|
|
|
{physicalProduct ? ( |
|
|
|
|
|
|
|
<TouchableHighlight |
|
|
|
|
|
|
|
underlayColor={Colors.theme1.greenFF + "22"} |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("flex flex-row-reverse justify-center px-2 py-3 mb-4"), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
borderWidth: 1, |
|
|
|
|
|
|
|
borderColor: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
backgroundColor: |
|
|
|
|
|
|
|
theme === "light" ? Colors.theme1.greenFF + "0a" : null, |
|
|
|
|
|
|
|
width: fontSize.sm * 6 + 18, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
navigation.push("Sample", { id: book?.sampleFileId }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
fontSize: fontSize.xs, |
|
|
|
|
|
|
|
color: |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paddingVertical: 4, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
مشاهده نمونه |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</TouchableHighlight> |
|
|
|
|
|
|
|
) : null} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{digitalProduct ? ( |
|
|
|
|
|
|
|
<TouchableHighlight |
|
|
|
|
|
|
|
underlayColor={Colors.theme1.greenFF + "22"} |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("flex flex-row-reverse justify-between px-2 py-3 mb-4"), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
borderWidth: 1, |
|
|
|
|
|
|
|
borderColor: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
backgroundColor: |
|
|
|
|
|
|
|
theme === "light" ? Colors.theme1.greenFF + "0a" : null, |
|
|
|
|
|
|
|
width: width - 32 - 8 - (fontSize.sm * 6 + 18), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
digitalAvailabileInCart |
|
|
|
|
|
|
|
? asyncAwesomeAlert( |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
"این محصول قبلا به سبد خرید شما اضافه شده است.", |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
showCancelButton: true, |
|
|
|
|
|
|
|
onConfirm: () => |
|
|
|
|
|
|
|
navigation.navigate("Root", { |
|
|
|
|
|
|
|
screen: "ShoppingCartTab", |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
confirmText: "مشاهده سبد خرید", |
|
|
|
|
|
|
|
cancelText: "باشه", |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
: addToCart( |
|
|
|
|
|
|
|
pushToCart({ |
|
|
|
|
|
|
|
productId: digitalProduct?.id, |
|
|
|
|
|
|
|
userId: userId, |
|
|
|
|
|
|
|
count: 1, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
"digital" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<> |
|
|
|
|
|
|
|
{whichTypeAdded === "digital" && userProductsLoading ? ( |
|
|
|
|
|
|
|
<ActivityIndicator |
|
|
|
|
|
|
|
color={ |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
size={fontSize.sm} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
|
|
|
color: |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paddingVertical: 4, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
خرید نسخه دیجیتال کتاب |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
<View style={tw("flex")}> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("py-1 pr-2"), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
borderRightWidth: 1, |
|
|
|
|
|
|
|
borderColor: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
color: |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{(separate(digitalProduct?.price) || " ") + " " + "تومان"} |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
</TouchableHighlight> |
|
|
|
|
|
|
|
) : null} |
|
|
|
|
|
|
|
{digitalProduct ? ( |
|
|
|
|
|
|
|
<TouchableHighlight |
|
|
|
|
|
|
|
underlayColor={Colors.theme1.greenFF + "22"} |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("flex flex-row-reverse justify-center px-2 py-3 mb-4"), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
borderWidth: 1, |
|
|
|
|
|
|
|
borderColor: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
backgroundColor: |
|
|
|
|
|
|
|
theme === "light" ? Colors.theme1.greenFF + "0a" : null, |
|
|
|
|
|
|
|
width: fontSize.sm * 6 + 18, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
onPress={() => navigation.navigate("Video", { id: book?.id })} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
fontSize: fontSize.xs, |
|
|
|
|
|
|
|
color: |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paddingVertical: 4, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
پیش نمایش |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</TouchableHighlight> |
|
|
|
|
|
|
|
) : null} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{videoProduct ? ( |
|
|
|
|
|
|
|
<TouchableHighlight |
|
|
|
|
|
|
|
underlayColor={Colors.theme1.greenFF + "22"} |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("flex flex-row-reverse justify-between px-2 py-3 mb-4"), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
borderWidth: 1, |
|
|
|
|
|
|
|
borderColor: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
backgroundColor: |
|
|
|
|
|
|
|
theme === "light" ? Colors.theme1.greenFF + "0a" : null, |
|
|
|
|
|
|
|
width: width - 32 - 8 - (fontSize.sm * 6 + 18), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
videoAvailabileInCart |
|
|
|
|
|
|
|
? asyncAwesomeAlert( |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
"این محصول قبلا به سبد خرید شما اضافه شده است.", |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
showCancelButton: true, |
|
|
|
|
|
|
|
onConfirm: () => |
|
|
|
|
|
|
|
navigation.navigate("Root", { |
|
|
|
|
|
|
|
screen: "ShoppingCartTab", |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
confirmText: "مشاهده سبد خرید", |
|
|
|
|
|
|
|
cancelText: "باشه", |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
: addToCart( |
|
|
|
|
|
|
|
pushToCart({ |
|
|
|
|
|
|
|
productId: videoProduct?.id, |
|
|
|
|
|
|
|
userId: userId, |
|
|
|
|
|
|
|
count: 1, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
"video" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<> |
|
|
|
|
|
|
|
{whichTypeAdded === "video" && userProductsLoading ? ( |
|
|
|
|
|
|
|
<ActivityIndicator |
|
|
|
|
|
|
|
color={ |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
size={fontSize.sm} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
|
|
|
color: |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paddingVertical: 4, |
|
|
|
<ProductButton |
|
|
|
}} |
|
|
|
product={videoProduct} |
|
|
|
> |
|
|
|
availableInCart={videoAvailabileInCart} |
|
|
|
خرید دوره ویدئویی کتاب |
|
|
|
availableForSell={videoAvailableForSell} |
|
|
|
</Text> |
|
|
|
type="video" |
|
|
|
)} |
|
|
|
onLoad={whichTypeAdded === "video" && userProductsLoading} |
|
|
|
<View style={tw("flex flex-row-reverse")}> |
|
|
|
title="خرید نسخه ویدئویی کتاب" |
|
|
|
<View style={tw("w-px h-full bg-green-500")}></View> |
|
|
|
sample={true} |
|
|
|
<Text |
|
|
|
sampleAction={() => navigation.navigate("Video", { id: book?.id })} |
|
|
|
style={[ |
|
|
|
/> |
|
|
|
tw("py-1 pr-2"), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
color: |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
|
|
|
: Colors.theme1.greenCF, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
<ProductButton |
|
|
|
}, |
|
|
|
product={digitalProduct} |
|
|
|
]} |
|
|
|
availableInCart={digitalAvailabileInCart} |
|
|
|
> |
|
|
|
availableForSell={digitalAvailableForSell} |
|
|
|
{(separate(videoProduct?.price) || " ") + " " + "تومان"} |
|
|
|
type="digital" |
|
|
|
</Text> |
|
|
|
onLoad={whichTypeAdded === "digital" && userProductsLoading} |
|
|
|
</View> |
|
|
|
title="خرید نسخه دیجیتال کتاب" |
|
|
|
</> |
|
|
|
sample={false} |
|
|
|
</TouchableHighlight> |
|
|
|
sampleAction={() => {}} |
|
|
|
) : null} |
|
|
|
/> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
{book?.text ? ( |
|
|
|
{book?.text ? ( |
|
|
|
<LinkBox |
|
|
|
<LinkBox |
|
|
@ -699,6 +540,7 @@ const mapStateToProps = (state) => ({ |
|
|
|
mobile: state.publicApi.mobile, |
|
|
|
mobile: state.publicApi.mobile, |
|
|
|
orientation: state.publicApi.orientation, |
|
|
|
orientation: state.publicApi.orientation, |
|
|
|
theme: state.publicApi.theme, |
|
|
|
theme: state.publicApi.theme, |
|
|
|
|
|
|
|
availableForSell: state.config.availableForSell, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
const mapDispatchToProps = { |
|
|
|