import React from "react"; import { connect } from "react-redux"; import { userProduct } from "~/Redux/actions"; import { makeStyles } from "@material-ui/core/styles"; import Table from "@material-ui/core/Table"; import TableBody from "@material-ui/core/TableBody"; import TableCell from "@material-ui/core/TableCell"; import TableContainer from "@material-ui/core/TableContainer"; import TableHead from "@material-ui/core/TableHead"; import TableRow from "@material-ui/core/TableRow"; import Paper from "@material-ui/core/Paper"; import "./index.scss"; const useStyles = makeStyles({ table: {}, }); const grades = [ window.t("پیش دبستان"), window.t("اول"), window.t("دوم"), window.t("سوم"), window.t("چهارم"), window.t("پنجم"), window.t("ششم"), window.t("هفتم"), window.t("هشتم"), window.t("نهم"), window.t("دهم"), window.t("یازدهم"), window.t("دوازدهم"), ]; const maxMobileSize = 550; const maxDesktopSize = 1250; const fontSize = { mobile: { info: { strong: window.innerWidth > maxMobileSize ? 15 : window.innerWidth / 28, p: window.innerWidth > maxMobileSize ? 12 : window.innerWidth / 36, span: window.innerWidth > maxMobileSize ? 12 : window.innerWidth / 36, }, price: { strong: window.innerWidth > maxMobileSize ? 16 : window.innerWidth / 22, span: window.innerWidth > maxMobileSize ? 13 : window.innerWidth / 40, }, counter: { button: window.innerWidth > maxMobileSize ? 20 : window.innerWidth / 25, span: window.innerWidth > maxMobileSize ? 15 : window.innerWidth / 25, }, delete: { span: window.innerWidth > maxMobileSize ? 13 : window.innerWidth / 28, }, }, desktop: { info: { strong: window.innerWidth > maxDesktopSize ? 15 : window.innerWidth / 75, p: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 95, span: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 95, }, price: { strong: window.innerWidth > maxDesktopSize ? 18 : window.innerWidth / 60, span: window.innerWidth > maxDesktopSize ? 13 : window.innerWidth / 95, }, counter: { button: window.innerWidth > maxDesktopSize ? 20 : window.innerWidth / 65, span: window.innerWidth > maxDesktopSize ? 15 : window.innerWidth / 65, }, delete: { span: window.innerWidth > maxDesktopSize ? 15 : window.innerWidth / 75, }, }, }; function BasicTable(props) { const classes = useStyles(); const { list, handleDelete, route, factorInfo } = props; return ( <> {window.innerWidth < 1000 ? ( {window.t("محصولات")} {window.t("قیمت")} {route === "callback" ? ( {window.t("تعداد")} ) : null} {list.map((row, i) => ( ))}
) : null} {window.innerWidth > 1000 ? ( {window.t("محصولات")} {window.t("تعداد")} {window.t("قیمت")} {list.map((row, i) => ( ))}
) : null} ); } const Item = (props) => { const { data, route } = props; if (!data.product) return null; return ( <> {window.innerWidth < 1000 ? (
{data.product.book.name}
{`نسخه ${ +data.product.productType === 1 ? window.t("الکترونیکی") : window.t("چاپی") } ${data.product.book.name} `}

{window.t("پایه") + ` ${grades[data.product.book.gradeId]}`}

{window.t("همراه با")} : {data.product.book.items || window.t("کد فعالسازی محتوای الکترونیک")}
{window.tr(data.product.price * data.count) || "1000"}{" "} {window.t("تومان")}
{route === "cart" ? (
{data.count} {window.t("عدد")}
) : null}
{route === "callback" ? ( {data.count} {window.t("عدد")}{" "} ) : null}
) : null} {window.innerWidth > 1000 ? (
{data.product.book.name}
{`${data.product.book.name} `} {" "} {`نسخه ${ +data.product.productType === 1 ? window.t("الکترونیکی") : window.t("چاپی") }`}

{window.t("پایه") + ` ${grades[data.product.book.gradeId]}`}

{data.count}
{data.product.price * data.count || "1000"}
) : null} ); }; export default connect( (state) => ({ loading: state.userProduct.loading, info: state.book.info, id: state.user.status.id, factorInfo: state.userFactor.info, }), { pushToCart: userProduct.add } )(BasicTable);