"use client"; import React, { useState, useEffect } from "react"; import axios from "axios"; import authAxios from "@/utils/axios"; import { useRouter } from "next/navigation"; import Image from "next/image"; export default function ProfilePage() { const [profileData, setProfileData] = useState(null); const [isLoading, setIsLoading] = useState(true); const [isError, setIsError] = useState(false); const router = useRouter(); useEffect(() => { const fetchProfileData = async () => { try { const response = await authAxios.get("/account/profile/"); setProfileData(response.data); setIsLoading(false); } catch (error) { console.error("Error fetching profile data", error); setIsError(true); setIsLoading(false); } }; fetchProfileData(); }, []); const getDisplayValue = (value) => { return value ? value : "Not set up"; }; if (isLoading) { return
Loading...
; } if (isError) { return
Error loading profile data. Please try again later.
; } return (
All Orders{" "}

{profileData.orders || 0}

Addresses{" "}

{profileData.addresses || 0}

Profile information

{getDisplayValue(profileData.first_name)}

{getDisplayValue(profileData.last_name)}

{getDisplayValue(profileData.birth_day)}

{getDisplayValue(profileData.gender)}

Contact methods

{getDisplayValue(profileData.email)}

{getDisplayValue(profileData.phone)}

Other Info

{profileData.profile_pic ? ( Profile Picture ) : (

Not set up

)}

Other Info

{getDisplayValue(profileData.accepts_marketing)}

); }