/* eslint-disable jsx-a11y/anchor-is-valid */ import React from "react"; import { Link, useHistory } from "react-router-dom"; import { toast } from "react-toastify"; import proxy from "~/Redux/proxy"; // import basket from "../../../assets/icons/basket.png"; import basket2 from "../../../assets/icons/basket2.png"; import { connect } from "react-redux"; import { userProduct } from "~/Redux/actions"; import "./index.scss"; 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("دوازدهم"), ]; function Product(props) { let history = useHistory(); function Navigate({ path }) { history.push(path); } const { product } = props; let productId = localStorage.getItem("pushToCart"); if (productId) { localStorage.removeItem("pushToCart"); props.pushToCart({ productId, userId: props.id, count: 1, }); setTimeout(() => history.push("/cart"), 2000); } return ( <> {window.innerWidth < 1000 ? (
{window.t("عکس

{`${product.name} پایه ${grades[product.gradeId]}`}

{window.t("نسخه چاپی")}

{product.product[0].price} {window.t("تومان")}
{ if (proxy.status()) props.pushToCart({ productId: product.product[0].id, userId: props.id, count: 1, }); else { localStorage.setItem( "afterLogin", window.location.pathname ); localStorage.setItem("pushToCart", product.product[0].id); Navigate({ path: "/auth" }); } }} >
{/*

الکترونیکی")}

{/* {product.product[0].price} تومان")} به زودی")}
{ // proxy.status() // ? this.props.pushToCart({ // productId: product.product[0].id, // userId: this.props.id, // count: 1, // }) // : toast.info("ابتدا وارد حساب کاربری خود شوید."); // }} >
*/}
) : null} {window.innerWidth > 1000 ? (
{product.name}

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

{window.t("نسخه چاپی")}

{product.product[0].price} {window.t("تومان")}
{ if (proxy.status()) props.pushToCart({ productId: product.product[0].id, userId: props.id, count: 1, }); else { toast.info( window.t("جهت ادامه فرآیند خرید وارد حساب خود شوید") ); localStorage.setItem("afterLogin", window.location.pathname); localStorage.setItem("pushToCart", product.product[0].id); Navigate({ path: "/auth" }); } }} >
{/*

{window.t("نسخه الکترونیک

{/* {product.product[0].price} تومان به زودی")}
{ // proxy.status() // ? this.props.pushToCart({ // productId: product.product[0].id, // userId: this.props.id, // count: 1, // }) // : toast.info("ابتدا وارد حساب کاربری خود شوید."); // }} >
*/}
) : null} ); } export default connect((state) => ({}), { pushToCart: userProduct.add, })(Product);