|
|
|
@ -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("ابتدا وارد حساب کاربری خود شوید.")) |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
</section> |
|
|
|
@ -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); |
|
|
|
|