|
|
@ -55,32 +55,37 @@ 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]); |
|
|
|
}, [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]); |
|
|
|
}, [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]); |
|
|
|
}, [book]); |
|
|
|
|
|
|
|
|
|
|
|
const physicalAvailabileInCart = React.useMemo(() => { |
|
|
|
const physicalAvailabileInCart = React.useMemo(() => { |
|
|
|
return userProducts?.filter( |
|
|
|
return userProducts?.filter( |
|
|
|
(product) => product?.productId === physicalProduct?.id |
|
|
|
(product) => |
|
|
|
)[0]; |
|
|
|
product?.productId === physicalProduct?.id && product?.condition < 2 |
|
|
|
|
|
|
|
)?.length; |
|
|
|
}, [userProducts, book]); |
|
|
|
}, [userProducts, book]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(physicalAvailabileInCart); |
|
|
|
|
|
|
|
|
|
|
|
const digitalAvailabileInCart = React.useMemo(() => { |
|
|
|
const digitalAvailabileInCart = React.useMemo(() => { |
|
|
|
return userProducts?.filter( |
|
|
|
return userProducts?.filter( |
|
|
|
(product) => product?.productId === digitalProduct?.id |
|
|
|
(product) => |
|
|
|
)[0]; |
|
|
|
product?.productId === digitalProduct?.id && product?.condition < 2 |
|
|
|
|
|
|
|
)?.length; |
|
|
|
}, [userProducts, book]); |
|
|
|
}, [userProducts, book]); |
|
|
|
|
|
|
|
|
|
|
|
const videoAvailabileInCart = React.useMemo(() => { |
|
|
|
const videoAvailabileInCart = React.useMemo(() => { |
|
|
|
return userProducts?.filter( |
|
|
|
return userProducts?.filter( |
|
|
|
(product) => product?.productId === videoProduct?.id |
|
|
|
(product) => |
|
|
|
)[0]; |
|
|
|
product?.productId === videoProduct?.id && product?.condition < 2 |
|
|
|
|
|
|
|
)?.length; |
|
|
|
}, [userProducts, book]); |
|
|
|
}, [userProducts, book]); |
|
|
|
|
|
|
|
|
|
|
|
const addToCart = React.useCallback( |
|
|
|
const addToCart = React.useCallback( |
|
|
|