در این قسمت : این کالاها برای خرید به شما پیشنهام می دهیم قابلیت انتخاب چند تا کتاب رو اضافه کردم و همچنین کلاس اکتیو | 30

temp
mahdi andalib 2 years ago
parent 915304fea4
commit 5305417b11
  1. 19
      src/components/ProductSuggestion/index.js
  2. 2
      src/views/Product/Desktop/index.js

@ -8,7 +8,9 @@ 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 }) => {
const [selectedProduct, setSelectedProduct] = useState(null); // const [selectedProduct, setSelectedProduct] = useState(null);
const [selectedProduct, setSelectedProduct] = useState([]);
const [price, setPrice] = useState(0); const [price, setPrice] = useState(0);
useEffect(() => { useEffect(() => {
@ -16,6 +18,7 @@ const ProductSuggestion = ({ isDark, getSimilar, book, similarList }) => {
getSimilar({ id: book?.id }); getSimilar({ id: book?.id });
} }
}, [book]); }, [book]);
useEffect(() => { useEffect(() => {
if (similarList.length > 0) { if (similarList.length > 0) {
let allPrice = 0; let allPrice = 0;
@ -25,6 +28,7 @@ const ProductSuggestion = ({ isDark, getSimilar, book, similarList }) => {
setPrice(() => allPrice); setPrice(() => allPrice);
} }
}, [similarList]); }, [similarList]);
return ( return (
<section className="mt-10 border-2 border-gray-300 py-10 rounded-lg bg-grayF9"> <section className="mt-10 border-2 border-gray-300 py-10 rounded-lg bg-grayF9">
<h2 className="text-center text-lg font-bold text-productPrice mb-10"> <h2 className="text-center text-lg font-bold text-productPrice mb-10">
@ -39,9 +43,16 @@ const ProductSuggestion = ({ isDark, getSimilar, book, similarList }) => {
key={index} key={index}
> >
<div <div
className={`flex flex-col items-center rounded-md p-5 cursor-pointer bg-white className={`flex flex-col items-center rounded-md p-5 cursor-pointer
${selectedProduct === book ? "bg-white" : ""}`} ${selectedProduct.includes(book) ? "bg-white" : ""}
onClick={() => setSelectedProduct(book)} `}
onClick={() =>
setSelectedProduct(
selectedProduct.includes(book)
? selectedProduct.filter((item) => item != book)
: [...selectedProduct, book]
)
}
style={{ border: "solid 1px #ddd" }} style={{ border: "solid 1px #ddd" }}
> >
<img <img

@ -20,7 +20,7 @@ const DesktopProductLayout = () => {
<div className="w-2/5 my-8"> <div className="w-2/5 my-8">
<Rate desktop /> <Rate desktop />
</div> </div>
<div className="w-4/5"> <div className="w-4/5 ">
<Comments indent={false} /> <Comments indent={false} />
{/* <QandA /> */} {/* <QandA /> */}
</div> </div>

Loading…
Cancel
Save