-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwishList.tsx
57 lines (52 loc) · 1.62 KB
/
wishList.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* eslint-disable */
import React, { useEffect, useState } from "react";
import { GiBroom } from "react-icons/gi";
import { useAppDispatch, useAppSelector } from '../store/store';
import Product from "../components/product/Product";
import { addProductToWishlist, removeProductFromWishlist, fetchWishlistProducts } from '../store/features/wishlist/wishlistSlice';
const WishList: React.FC = () => {
const dispatch = useAppDispatch();
const { items, isError, isSuccess, isLoading, message } = useAppSelector((state) => state.wishlist);
useEffect(() => {
dispatch(fetchWishlistProducts());
}, [dispatch]);
if(isSuccess){
console.log(items);
}
return (
<>
<div className="wishListPage">
<div className="top">
<div>
<h1>My Wishlist</h1>
</div>
<div>
<button className="delete">
<GiBroom className="deleteIcon" />
Clear WishList
</button>
</div>
</div>
<div className="wishlistProducts">
<div>
{isSuccess &&
Array.isArray(items) &&
items
.map((product: any) => (
<Product
key={product.id}
id={product.id}
images={product.images}
name={product.name}
price={product.price}
stock={Number(product.quantity)}
description={product.description}
/>
))}
</div>
</div>
</div>
</>
);
};
export default WishList;