diff --git a/modules/ProfilePageModules/sections/DetailProfile.tsx b/modules/ProfilePageModules/sections/DetailProfile.tsx index a12a64e..dafe2f1 100644 --- a/modules/ProfilePageModules/sections/DetailProfile.tsx +++ b/modules/ProfilePageModules/sections/DetailProfile.tsx @@ -1,23 +1,17 @@ 'use client' import { Avatar, AvatarImage } from '@/components/ui/Avatar' -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from '@/components/ui/Tooltip' +import { toast } from '@/components/ui/Toast' import { Popover, PopoverContent, PopoverTrigger, } from '@/components/ui/popover' import { useUserData } from '@/hooks/user' +import { updateMyPersonalData } from '@/lib/api/user' import { Pencil } from 'lucide-react' +import { useEffect, useState } from 'react' import { PandaImages } from '../constant' -import { toast } from '@/components/ui/Toast' -import { useState } from 'react' -import { updateMyPersonalData } from '@/lib/api/user' interface FieldProps { label: string @@ -35,12 +29,13 @@ const Field = ({ label, value = '' }: FieldProps) => { export const DetailProfile = () => { const { userData, isLoading } = useUserData({ personal: true }) + const [profilePict, setProfilePictSrc] = useState(0) + const [popOpen, popClose] = useState(false) - if (isLoading) { - return toast.loading("Loading...") // TODO: change this - } + useEffect(() => { + setProfilePictSrc(userData?.personal.profilePic ?? 0) + }, [userData]) - const [profilePict, setProfilePictSrc] = useState(0) const handleProfileChange = async (id: number) => { setProfilePictSrc(id) @@ -56,6 +51,10 @@ export const DetailProfile = () => { toast.success('Berhasil mengganti foto profil') } + if (isLoading) { + return toast.loading("Loading...") // TODO: change this + } + return (

@@ -68,40 +67,38 @@ export const DetailProfile = () => { PandaImages[profilePict].src } /> - - - - - - -

- Choose Your Panda! -

-
- {PandaImages.map((item, index) => ( - handleProfileChange(index)} - key={item.alt} - className="w-[108px] h-[108px] cursor-pointer" - > - - - ))} -
-
-
-
+ + + + + +

+ Choose Your Panda! +

+
+ {PandaImages.map((item, index) => ( + { + handleProfileChange(index) + popClose(false) + }} + key={item.alt} + className="w-[108px] h-[108px] cursor-pointer" + > + + + ))} +
+
+
- +

Choose Your Panda!