From 3e338c6c3cee315875180cf06d34bb0c4eb0c2d4 Mon Sep 17 00:00:00 2001 From: mahdi andalib Date: Sat, 2 Jul 2022 14:05:55 +0430 Subject: [PATCH] =?UTF-8?q?=DA=A9=D8=A7=D8=B1=20=D8=A8=D8=B1=20=D8=B1?= =?UTF-8?q?=D9=88=DB=8C=20=D8=AF=DA=A9=D9=85=D9=87=20=D8=A7=D8=B6=D8=A7?= =?UTF-8?q?=D9=81=D9=87=20=DA=A9=D8=B1=D8=AF=D9=86=20=D8=A8=D9=87=20=D8=B3?= =?UTF-8?q?=D8=A8=D8=AF=20=D8=AE=D8=B1=DB=8C=D8=AF=20=D8=AF=D8=B1=20=D9=82?= =?UTF-8?q?=D8=B3=D9=85=D8=AA=20=D9=BE=DB=8C=D8=B4=D9=86=D9=87=D8=A7=D8=AF?= =?UTF-8?q?=20=DA=A9=D8=AA=D8=A7=D8=A8=20|18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ProductSuggestion/index.js | 28 +++++++++++++++++-- .../Product/Desktop/ProductOverAll/index.js | 2 +- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/components/ProductSuggestion/index.js b/src/components/ProductSuggestion/index.js index 78e4e02..e858eaf 100644 --- a/src/components/ProductSuggestion/index.js +++ b/src/components/ProductSuggestion/index.js @@ -1,13 +1,24 @@ import React, { useState, useEffect } from "react"; -import { product } from "../../redux/actions"; +import { product, userProduct } from "../../redux/actions"; import { connect } from "react-redux"; import separate from "../../utils/separate"; import Button from "../Button"; +import { toast } from "react-toastify"; import productImg from "./product-chair.svg"; import plus from "./plus.svg"; -const ProductSuggestion = ({ isDark, getSimilar, book, similarList }) => { +const ProductSuggestion = ({ + isDark, + getSimilar, + book, + similarList, + loading, + isLogin, + pushToCart, + id, + userId, +}) => { // const [selectedProduct, setSelectedProduct] = useState(null); const [selectedProduct, setSelectedProduct] = useState([]); @@ -111,7 +122,16 @@ const ProductSuggestion = ({ isDark, getSimilar, book, similarList }) => { width="calc(100% / 5)" color={"text-white"} selectable={true} - onClick={() => {}} + loading={loading} + onClick={() => + isLogin + ? pushToCart({ + productId: id, + userId: userId, + count: 1, + }) + : toast.info(window.t("ابتدا وارد حساب کاربری خود شوید.")) + } /> @@ -122,10 +142,12 @@ const mapStateToProps = (state) => ({ book: state.book.info, isDark: state.publicApi.isDark, similarList: state.product.similarList, + isLogin: state.user.status, }); const mapDispatchToProps = { getSimilar: product.getSimilar, + pushToCart: userProduct.add, }; export default connect(mapStateToProps, mapDispatchToProps)(ProductSuggestion); diff --git a/src/views/Product/Desktop/ProductOverAll/index.js b/src/views/Product/Desktop/ProductOverAll/index.js index 410f2aa..09c3946 100644 --- a/src/views/Product/Desktop/ProductOverAll/index.js +++ b/src/views/Product/Desktop/ProductOverAll/index.js @@ -113,7 +113,7 @@ export const ProductOverAll = ({ book, grades, isDark, loading }) => { -
+