|
|
|
@ -12,8 +12,43 @@ import Table from "../../../Video/components/Desktop/Table"; |
|
|
|
|
//assets
|
|
|
|
|
import arrow from "../../../../assets/icons/dropdown-blue.svg"; |
|
|
|
|
|
|
|
|
|
export const ProductOverAll = ({ book, grades, isDark, loading }) => { |
|
|
|
|
const [type, setType] = useState("1"); |
|
|
|
|
export const ProductOverAll = ({ |
|
|
|
|
book, |
|
|
|
|
grades, |
|
|
|
|
isDark, |
|
|
|
|
loading, |
|
|
|
|
availableForSell, |
|
|
|
|
}) => { |
|
|
|
|
const [activeProduct, setActiveProduct] = useState(null); |
|
|
|
|
|
|
|
|
|
const physicalAvailableForSell = React.useMemo(() => { |
|
|
|
|
return availableForSell?.find((product) => product === 2); |
|
|
|
|
}, [availableForSell]); |
|
|
|
|
|
|
|
|
|
const digitalAvailableForSell = React.useMemo(() => { |
|
|
|
|
return availableForSell?.find((product) => product === 1); |
|
|
|
|
}, [availableForSell]); |
|
|
|
|
|
|
|
|
|
const videoAvailableForSell = React.useMemo(() => { |
|
|
|
|
return availableForSell?.find((product) => product === 4); |
|
|
|
|
}, [availableForSell]); |
|
|
|
|
|
|
|
|
|
const physicalProduct = React.useMemo(() => { |
|
|
|
|
return book?.product?.find((product) => product?.productType === 2); |
|
|
|
|
}, [book]); |
|
|
|
|
|
|
|
|
|
const digitalProduct = React.useMemo(() => { |
|
|
|
|
return book?.product?.find((product) => product?.productType === 1); |
|
|
|
|
}, [book]); |
|
|
|
|
|
|
|
|
|
const videoProduct = React.useMemo(() => { |
|
|
|
|
return book?.product?.find((product) => product?.productType === 4); |
|
|
|
|
}, [book]); |
|
|
|
|
|
|
|
|
|
React.useEffect(() => { |
|
|
|
|
setActiveProduct(physicalProduct); |
|
|
|
|
}, [book]); |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<div className="w-full flex flex-col"> |
|
|
|
|
<header className={`w-full flex justify-between gap-5`}> |
|
|
|
@ -21,19 +56,23 @@ export const ProductOverAll = ({ book, grades, isDark, loading }) => { |
|
|
|
|
<div className="flex flex-col w-1/2 divide-y divide-solid divide-gray-200"> |
|
|
|
|
<div className="w-full flex flex-col pr-2 py-2 border-0"> |
|
|
|
|
<h1 className="text-blue5F mb-3 font-semibold text-lg dark:text-white leading-7"> |
|
|
|
|
{book?.product[type]?.name} |
|
|
|
|
{activeProduct?.name ? activeProduct.name : " "} |
|
|
|
|
</h1> |
|
|
|
|
<div className="text-blueC0 text-tiny dark:text-greenBA"> |
|
|
|
|
{"پایه" + " " + grades[book?.gradeId]} |
|
|
|
|
</div> |
|
|
|
|
{book?.gradeId ? ( |
|
|
|
|
<div className="text-blueC0 text-tiny dark:text-greenBA"> |
|
|
|
|
{"پایه" + " " + grades[book?.gradeId]} |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
|
|
|
|
|
<div className="flex justify-end items-center"> |
|
|
|
|
<div className="p-2"> |
|
|
|
|
<StarRating value={book?.rate || 4} /> |
|
|
|
|
</div> |
|
|
|
|
<div className="p-2 border-0 border-solid border-r border-gray-100 text-sm text-gray-400"> |
|
|
|
|
بیش از {book?.product[type]?.suggestedCounter} نفر امتیاز داده |
|
|
|
|
اند |
|
|
|
|
</div> |
|
|
|
|
{activeProduct?.suggestedCounter ? ( |
|
|
|
|
<div className="p-2 border-0 border-solid border-r border-gray-100 text-sm text-gray-400"> |
|
|
|
|
بیش از {activeProduct?.suggestedCounter} نفر امتیاز داده اند |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div className="py-4"> |
|
|
|
@ -53,9 +92,9 @@ export const ProductOverAll = ({ book, grades, isDark, loading }) => { |
|
|
|
|
}} |
|
|
|
|
width="38%" |
|
|
|
|
color={isDark ? "text-white" : "text-green7B"} |
|
|
|
|
active={type === "1"} |
|
|
|
|
active={activeProduct === physicalProduct} |
|
|
|
|
selectable={true} |
|
|
|
|
onClick={() => setType("1")} |
|
|
|
|
onClick={() => setActiveProduct(physicalProduct)} |
|
|
|
|
borderType="dashed" |
|
|
|
|
customStyle="" |
|
|
|
|
twPaddings="py-4 px-12" |
|
|
|
@ -70,9 +109,9 @@ export const ProductOverAll = ({ book, grades, isDark, loading }) => { |
|
|
|
|
}} |
|
|
|
|
width="38%" |
|
|
|
|
selectable={true} |
|
|
|
|
active={type === "0"} |
|
|
|
|
active={activeProduct === digitalProduct} |
|
|
|
|
color={isDark ? "text-white" : "text-green7B"} |
|
|
|
|
onClick={() => setType("0")} |
|
|
|
|
onClick={() => setActiveProduct(digitalProduct)} |
|
|
|
|
borderType="dashed" |
|
|
|
|
radius={false} |
|
|
|
|
twPaddings="py-4 px-12" |
|
|
|
@ -115,25 +154,23 @@ export const ProductOverAll = ({ book, grades, isDark, loading }) => { |
|
|
|
|
</div> |
|
|
|
|
<div className="flex flex-col w-1/3 "> |
|
|
|
|
<ProductStatusCard |
|
|
|
|
price={book?.product[type]?.price} |
|
|
|
|
garanty={book?.product[type]?.garantyText} |
|
|
|
|
suggestedCounter={book?.product[type]?.suggestedCounter} |
|
|
|
|
seller={book?.product[type]?.seller} |
|
|
|
|
offerPrice={book?.product[type]?.offerPrice} |
|
|
|
|
id={book?.product[type]?.id} |
|
|
|
|
shippingTime={book?.product[type]?.shippingTime} |
|
|
|
|
price={activeProduct?.price} |
|
|
|
|
garanty={activeProduct?.garantyText} |
|
|
|
|
suggestedCounter={activeProduct?.suggestedCounter} |
|
|
|
|
seller={activeProduct?.seller} |
|
|
|
|
offerPrice={activeProduct?.offerPrice} |
|
|
|
|
id={activeProduct?.id} |
|
|
|
|
shippingTime={activeProduct?.shippingTime} |
|
|
|
|
loading={loading} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
</header> |
|
|
|
|
{book?.product[type]?.properties?.length > 0 && ( |
|
|
|
|
{activeProduct?.properties?.length && ( |
|
|
|
|
<ProductTab |
|
|
|
|
tabs={[ |
|
|
|
|
{ |
|
|
|
|
title: "مشخصات", |
|
|
|
|
components: ( |
|
|
|
|
<Table specifications={book?.product[type]?.properties} /> |
|
|
|
|
), |
|
|
|
|
components: <Table specifications={activeProduct?.properties} />, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: "نقد و بررسی", |
|
|
|
@ -164,6 +201,7 @@ const mapStateToProps = (state) => ({ |
|
|
|
|
isDark: state.publicApi.isDark, |
|
|
|
|
userId: state.user.status.id, |
|
|
|
|
loading: state.userProduct.loading, |
|
|
|
|
availableForSell: state.config.availableForSell, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
|