diff --git a/src/Pages/Cart.tsx b/src/Pages/Cart.tsx index cc9d66e..5480049 100644 --- a/src/Pages/Cart.tsx +++ b/src/Pages/Cart.tsx @@ -1,47 +1,59 @@ -import React, { useContext } from "react"; -import "./Cart.css"; -import { AiFillStar, AiOutlineDelete, AiOutlineStar } from "react-icons/ai"; -export default function Cart() { +import React, { useContext } from 'react' +import './Cart.css' +import { AiFillStar, AiOutlineDelete, AiOutlineStar } from 'react-icons/ai' +import { CartContext } from '../context/CartContextProvider' +import { Produts } from '../types/products.types' + +const Cart: React.FC = () => { + const CartShop = useContext(CartContext) + + const { removeAll, removeProduts } = CartShop + return ( <> - {true ? ( // if shoppping cart is not empty + {CartShop.userCart.length !== 0 ? ( // if shoppping cart is not empty <>

All Products In Basket:

-
-
- -
-

Test Title ...

-
-
- - - - - - - - - - - -
-

111$

-
-
-

Count: 22

+ { + CartShop.userCart.map(product => { + const { id, image, title, rating: { rate }, count, price } = product; + return ( +
+ products +
+

{title.slice(0, 15)}

+
+
+ {Array(Math.ceil(rate)) + .fill(0) + .map(() => ( + + ))} + {Array(5 - Math.ceil(rate)) + .fill(0) + .map(() => ( + + ))} +
+

{price}$

+
+
+

Count: {count}

+
+ +
- -
-
+ ) + }) + }
) : ( @@ -51,5 +63,7 @@ export default function Cart() { )} - ); + ) } + +export default Cart diff --git a/src/components/cart/Card.tsx b/src/components/cart/Card.tsx index d2af114..54cb755 100644 --- a/src/components/cart/Card.tsx +++ b/src/components/cart/Card.tsx @@ -21,7 +21,7 @@ const Card: React.FC = ({ id, title, image, price, rating: { rate } }) icon: "success", buttons: ["اوکی", "رفتن به سبد خرید"] }) - .then(result => { + .th4en(result => { console.log(result); if (result) { navigate("/cart");