From 6818979e049e81dfa5ce6107b8122806f0ab8772 Mon Sep 17 00:00:00 2001 From: mohammadpy8 Date: Mon, 28 Aug 2023 08:18:54 +0330 Subject: [PATCH] show-rate-products --- src/Pages/home/Home.tsx | 50 +++++++----------------------------- src/components/cart/Card.tsx | 33 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 41 deletions(-) create mode 100644 src/components/cart/Card.tsx diff --git a/src/Pages/home/Home.tsx b/src/Pages/home/Home.tsx index 34de71a..456994c 100644 --- a/src/Pages/home/Home.tsx +++ b/src/Pages/home/Home.tsx @@ -1,7 +1,12 @@ -import React from 'react' +import React, { useContext } from 'react' import { AiFillStar, AiOutlineStar } from 'react-icons/ai' +import { CartContext } from '../../context/CartContextProvider' +import Card from '../../components/cart/Card'; const Home = () => { + + const productContext = useContext(CartContext); + return ( <>
@@ -9,46 +14,9 @@ const Home = () => {
-
- -
-

Test Title ...

-
-
- - - - - -
-

231$

-
- -
-
-
- -
-

Test Title ...

-
-
- - - - - -
-

231$

-
- -
-
+ { + productContext.shop.map(products => ) + }
) diff --git a/src/components/cart/Card.tsx b/src/components/cart/Card.tsx new file mode 100644 index 0000000..ffa00a4 --- /dev/null +++ b/src/components/cart/Card.tsx @@ -0,0 +1,33 @@ +import React from 'react' + +import { AiFillStar, AiOutlineStar } from 'react-icons/ai' +import { Produts } from '../../types/products.types' + +const Card = ({ id, title, image, price, rating: { rate } }: Produts) => { + return ( +
+ products +
+

{title.slice(0, 10)}

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

{price}$

+
+ +
+
+ ) +} + +export default Card