reza fixed product add to cart

master
Reza_ashrafi 2 years ago
parent 44f163e073
commit de907b9453
  1. 23
      src/screens/Product/components/Book.js
  2. 2
      src/screens/Product/components/Rates.js
  3. 2
      src/screens/Product/index.js

@ -55,31 +55,31 @@ function Book({
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];
}); },[book]);
const digitalProduct = React.useMemo(() => { const digitalProduct = React.useMemo(() => {
return book?.product?.filter((product) => product?.productType === 1)[0]; return book?.product?.filter((product) => product?.productType === 1)[0];
}); },[book]);
const videoProduct = React.useMemo(() => { const videoProduct = React.useMemo(() => {
return book?.product?.filter((product) => product?.productType === 4)[0]; return book?.product?.filter((product) => product?.productType === 4)[0];
}); },[book]);
const physicalAvailabileInCart = React.useMemo(() => { const physicalAvailabileInCart = React.useMemo(() => {
return userProducts?.filter( return userProducts?.filter(
(product) => product?.productId === book?.product[1]?.id (product) => product?.productId === physicalProduct?.id
)[0]; )[0];
}, [userProducts, book]); }, [userProducts, book]);
const digitalAvailabileInCart = React.useMemo(() => { const digitalAvailabileInCart = React.useMemo(() => {
return userProducts?.filter( return userProducts?.filter(
(product) => product?.productId === book?.product[0]?.id (product) => product?.productId === digitalProduct?.id
)[0]; )[0];
}, [userProducts, book]); }, [userProducts, book]);
const videoAvailabileInCart = React.useMemo(() => { const videoAvailabileInCart = React.useMemo(() => {
return userProducts?.filter( return userProducts?.filter(
(product) => product?.productId === book?.product[2]?.id (product) => product?.productId === videoProduct?.id
)[0]; )[0];
}, [userProducts, book]); }, [userProducts, book]);
@ -131,9 +131,9 @@ function Book({
}, [userProducts]); }, [userProducts]);
return ( return (
<ScrollView style={[tw("flex flex-1 relative")]}> <View style={[tw("flex flex-1 relative")]}>
{!mobile ? <View style={tw("mt-5")}></View> : null} {!mobile ? <View style={tw("mt-5")}></View> : null}
{imageSlider ? <ImageSlider /> : null} {/* {imageSlider ? <ImageSlider /> : null} */}
<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}` }}
@ -180,7 +180,6 @@ function Book({
{"پایه" + " " + (grades[book?.gradeId] || " ")} {"پایه" + " " + (grades[book?.gradeId] || " ")}
</Text> </Text>
</View> </View>
</View> </View>
</View> </View>
<View <View
@ -609,7 +608,7 @@ function Book({
onPress={() => onPress={() =>
navigation.push("Info", { navigation.push("Info", {
type: { name: "توضیحات", value: "productDescription" }, type: { name: "توضیحات", value: "productDescription" },
data : book?.text data: book?.text,
}) })
} }
/> />
@ -640,7 +639,7 @@ function Book({
onPress={() => onPress={() =>
navigation.push("Info", { navigation.push("Info", {
type: { name: "پرسش و پاسخ", value: "productQuestion" }, type: { name: "پرسش و پاسخ", value: "productQuestion" },
data: [] data: [],
}) })
} }
/> />
@ -671,7 +670,7 @@ function Book({
/> />
</> </>
) : null} ) : null}
</ScrollView> </View>
); );
} }

@ -43,7 +43,7 @@ function Rates({ rate, productId, addVote, isBuyed = null, theme }) {
tintColor={ tintColor={
theme === "light" ? Colors.theme1.white : Colors.theme1.dark theme === "light" ? Colors.theme1.white : Colors.theme1.dark
} }
value={4} startingValue={rate}
onFinishRating={(rating) => addVote({ productId, vote: rating })} onFinishRating={(rating) => addVote({ productId, vote: rating })}
readonly={!isBuyed} readonly={!isBuyed}
/> />

@ -6,6 +6,7 @@ import {
ScrollView, ScrollView,
SafeAreaView, SafeAreaView,
StatusBar, StatusBar,
KeyboardAvoidingView,
} from "react-native"; } from "react-native";
import Book from "./components/Book"; import Book from "./components/Book";
import { book } from "../../redux/actions"; import { book } from "../../redux/actions";
@ -22,6 +23,7 @@ function Product({ route, book, getBook, grades }) {
style={{ style={{
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0, paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0,
position: "relative", position: "relative",
flex: 1,
}} }}
> >
<Navbar <Navbar

Loading…
Cancel
Save