"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
{getDisplayValue(profileData.first_name)}
{getDisplayValue(profileData.last_name)}
{getDisplayValue(profileData.birth_day)}
{getDisplayValue(profileData.gender)}
{getDisplayValue(profileData.email)}
{getDisplayValue(profileData.phone)}
Not set up
)}{getDisplayValue(profileData.accepts_marketing)}