|
|
@ -1,13 +1,24 @@ |
|
|
|
import React, { useState, useEffect } from "react"; |
|
|
|
import React, { useState, useEffect } from "react"; |
|
|
|
import { product } from "../../redux/actions"; |
|
|
|
import { product, userProduct } from "../../redux/actions"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import separate from "../../utils/separate"; |
|
|
|
import separate from "../../utils/separate"; |
|
|
|
import Button from "../Button"; |
|
|
|
import Button from "../Button"; |
|
|
|
|
|
|
|
import { toast } from "react-toastify"; |
|
|
|
|
|
|
|
|
|
|
|
import productImg from "./product-chair.svg"; |
|
|
|
import productImg from "./product-chair.svg"; |
|
|
|
import plus from "./plus.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(null);
|
|
|
|
const [selectedProduct, setSelectedProduct] = useState([]); |
|
|
|
const [selectedProduct, setSelectedProduct] = useState([]); |
|
|
|
|
|
|
|
|
|
|
@ -111,7 +122,16 @@ const ProductSuggestion = ({ isDark, getSimilar, book, similarList }) => { |
|
|
|
width="calc(100% / 5)" |
|
|
|
width="calc(100% / 5)" |
|
|
|
color={"text-white"} |
|
|
|
color={"text-white"} |
|
|
|
selectable={true} |
|
|
|
selectable={true} |
|
|
|
onClick={() => {}} |
|
|
|
loading={loading} |
|
|
|
|
|
|
|
onClick={() => |
|
|
|
|
|
|
|
isLogin |
|
|
|
|
|
|
|
? pushToCart({ |
|
|
|
|
|
|
|
productId: id, |
|
|
|
|
|
|
|
userId: userId, |
|
|
|
|
|
|
|
count: 1, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
: toast.info(window.t("ابتدا وارد حساب کاربری خود شوید.")) |
|
|
|
|
|
|
|
} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</section> |
|
|
|
</section> |
|
|
@ -122,10 +142,12 @@ const mapStateToProps = (state) => ({ |
|
|
|
book: state.book.info, |
|
|
|
book: state.book.info, |
|
|
|
isDark: state.publicApi.isDark, |
|
|
|
isDark: state.publicApi.isDark, |
|
|
|
similarList: state.product.similarList, |
|
|
|
similarList: state.product.similarList, |
|
|
|
|
|
|
|
isLogin: state.user.status, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
const mapDispatchToProps = { |
|
|
|
getSimilar: product.getSimilar, |
|
|
|
getSimilar: product.getSimilar, |
|
|
|
|
|
|
|
pushToCart: userProduct.add, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ProductSuggestion); |
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ProductSuggestion); |
|
|
|