diff --git a/modules/ProfilePageModules/sections/DetailProfile.tsx b/modules/ProfilePageModules/sections/DetailProfile.tsx index 972a943..7fd0ded 100644 --- a/modules/ProfilePageModules/sections/DetailProfile.tsx +++ b/modules/ProfilePageModules/sections/DetailProfile.tsx @@ -38,7 +38,21 @@ export const DetailProfile = () => { return toast.loading("Loading...") // TODO: change this } - const handleProfileChange = (src: string) => {} + const [profilePict, setProfilePictSrc] = useState(0) + + const handleProfileChange = async (id: number) => { + setProfilePictSrc(id) + + const res = await updateMyPersonalData({ + profilePic: id, + }) + + if (!res.ok) { + return toast.error('Gagal mengganti foto profil') + } + + toast.success('Berhasil mengganti foto profil') + } return (
@@ -48,7 +62,9 @@ export const DetailProfile = () => {
- + @@ -64,9 +80,9 @@ export const DetailProfile = () => { Choose Your Panda!
- {PandaImages.map((item) => ( + {PandaImages.map((item, index) => ( handleProfileChange(item.src)} + onClick={() => handleProfileChange(index)} key={item.alt} className="w-[108px] h-[108px] cursor-pointer" > @@ -88,9 +104,9 @@ export const DetailProfile = () => { Choose Your Panda!
- {PandaImages.map((item) => ( + {PandaImages.map((item, index) => ( handleProfileChange(item.src)} + onClick={() => handleProfileChange(index)} key={item.alt} className="w-[108px] h-[108px] cursor-pointer" >