);
diff --git a/src/components/profile/About.tsx b/src/components/profile/About.tsx
index c6f2a26..89ae285 100644
--- a/src/components/profile/About.tsx
+++ b/src/components/profile/About.tsx
@@ -1,11 +1,12 @@
"use client";
import React, { useEffect } from 'react';
-import { User, Cake } from 'lucide-react';
+import { User, Cake, Award } from 'lucide-react';
import { FaUser, FaEnvelope } from "react-icons/fa";
import { FaLocationDot, FaPhone } from "react-icons/fa6";
import { useDispatch, useSelector } from 'react-redux';
import { AppDispatch, RootState } from '@/redux/store';
import { getUserProfile } from '@/redux/slices/profileSlice';
+import request from '@/utils/axios';
function About() {
const dispatch = useDispatch
();
@@ -18,6 +19,8 @@ function About() {
fetchData();
}, [dispatch]);
+
+
if (loading) return Loading...
;
if (error) return Error: {error}
;
if (!user) return No user found
;
diff --git a/src/components/profile/Order.tsx b/src/components/profile/Order.tsx
index a4bbb49..b5c4e3a 100644
--- a/src/components/profile/Order.tsx
+++ b/src/components/profile/Order.tsx
@@ -1,5 +1,19 @@
-import React from 'react'
+"use client";
+import React, { useEffect, useState } from 'react'
+import request from '@/utils/axios';
+
+
+
+
function Order() {
+ // const [orderss, setOrders] = useState([]);
+ // useEffect(() => {
+ // const fetchData = async () => {
+ // const response: any = await request.get('/orders');
+ // setOrders(response.orders);
+ // };
+ // fetchData();
+ // }, [])
const orders: any = [
{
name: "Sneakers N12",
@@ -14,6 +28,9 @@ function Order() {
desc: "tkacheanton dress"
}
]
+ useEffect(() => {
+
+ }, [])
return (
diff --git a/src/components/profile/wishlist.tsx b/src/components/profile/wishlist.tsx
index 31f0fc9..9ed272e 100644
--- a/src/components/profile/wishlist.tsx
+++ b/src/components/profile/wishlist.tsx
@@ -1,15 +1,40 @@
-"use client"
-import React, { useEffect } from 'react';
+'use client';
+
+import React, { useEffect, useState } from 'react';
import { HiDotsHorizontal } from "react-icons/hi";
-import { FaRegHeart } from "react-icons/fa";
import { VscTag } from "react-icons/vsc";
import { useDispatch, useSelector } from 'react-redux';
import { AppDispatch, RootState } from '@/redux/store';
import { getUserProfile } from '@/redux/slices/profileSlice';
+import request from '@/utils/axios';
+import { Cylinder, Trash, Loader } from 'lucide-react';
+import { ToastContainer, toast } from 'react-toastify';
+import 'react-toastify/dist/ReactToastify.css';
+import Link from 'next/link';
+
+interface Product {
+ id: string;
+ productThumbnail: string;
+ stockLevel: number;
+ productName: string;
+ productPrice: number;
+ productCurrency: string;
+}
+
+interface Wish {
+ id: string;
+ userId: string;
+ productId: string;
+ createdAt: string;
+ updatedAt: string;
+ product: Product;
+}
-function Wishlist() {
+const Wishlist: React.FC = () => {
const dispatch = useDispatch
();
const { user, loading, error } = useSelector((state: RootState) => state.userProfile);
+ const [wishlist, setWishlist] = useState([]);
+ const [loadingWishId, setLoadingWishId] = useState(null);
useEffect(() => {
const fetchData = async () => {
@@ -18,78 +43,89 @@ function Wishlist() {
fetchData();
}, [dispatch]);
+ const getWishlist = async () => {
+ try {
+ const response: any = await request.get('/wishes');
+ setWishlist(response.wishes);
+ } catch (err) {
+ console.error(err);
+ }
+ };
+
+ useEffect(() => {
+ getWishlist();
+ }, []);
+
+ const removeWish = async (wishId: string) => {
+ setLoadingWishId(wishId);
+ try {
+ await request.post('/wishes', { productId: wishId });
+ toast.success('Wishlist item removed successfully');
+ getWishlist();
+ } catch (err) {
+ console.error(err);
+ toast.error('Failed to remove wishlist item');
+ } finally {
+ setLoadingWishId(null);
+ }
+ }
+
if (loading) return Loading...
;
if (error) return Error: {error}
;
if (!user) return No user found
;
- const wishlist = [
- {
- productName: "Snakers 270",
- image: "https://i5.walmartimages.com/seo/LEEy-world-Toddler-Shoes-Children-Mesh-Shoes-Spring-and-Autumn-New-Boys-Korean-Casual-Girls-Breathable-Sneakers-Sports-Shoes-for-Girls-Blue_31b4bad2-f738-45e3-87e5-884066b97e9a.3da4fe17d1b33554816beee33dd674f9.jpeg",
- seller: "Kayigamba Blair",
- wishes: "1,489",
- price: "100",
- currency: "$"
- },
- {
- productName: "Snakers 270",
- image: "https://www.campusshoes.com/cdn/shop/products/FIRST_11G-787_WHT-SIL-B.ORG.jpg?v=1705644651",
- seller: "Kayigamba Blair",
- wishes: "1,489",
- price: "100",
- currency: "$"
- },
- {
- productName: "Snakers 270",
- image: "https://cdn.thewirecutter.com/wp-content/media/2023/09/running-shoes-2048px-5946.jpg?auto=webp&quality=75&width=1024",
- seller: "Kayigamba Blair",
- wishes: "1,489",
- price: "100",
- currency: "$"
- }
- ];
-
return (
-
+
Wished Products
- {wishlist.map((item, index) => (
-
-
-
- {user.User && (
-
- )}
-
- {user.User?.firstName} {user.User?.lastName}
- Your Wishes
-
+ {wishlist.length === 0 ? (
+
+ Your wishlist will appear here
+
+ ) : (
+ wishlist.map((wish) => (
+
+
+ {/* */}
+
-
-
-
-
- {item.productName}
- Seller: {item.seller}
- {item.price}{item.currency}
-
-
-
-
-
{item.wishes}
+
+
+
+
-
-
-
{item.price}{item.currency}
+
+
{wish.product.productName}
+
+
+
+ {wish.product.stockLevel}
+
+
+
+ {wish.product.productPrice} {wish.product.productCurrency}
+
+
-
- ))}
+ ))
+ )}
+
);
}
-export default Wishlist;
\ No newline at end of file
+export default Wishlist;