diff --git a/web/src/pages/Verify/Avatar/index.tsx b/web/src/pages/Verify/Avatar/index.tsx index 45b94f0..cecb27b 100644 --- a/web/src/pages/Verify/Avatar/index.tsx +++ b/web/src/pages/Verify/Avatar/index.tsx @@ -1,5 +1,6 @@ import { Button } from "@/components/ui/button"; import { useAuth } from "@/store/auth"; +import { useVerify } from "@/store/verify"; import { User } from "lucide-react"; import { useCallback, useEffect, useRef, useState, type FC } from "react"; import { Link } from "react-router"; @@ -16,6 +17,9 @@ const VerifyAvatarPage: FC = () => { const fileInputRef = useRef(null); + const uploadAvatar = useVerify((s) => s.uploadAvatar); + const uploading = useVerify((s) => s.uploading); + useEffect(() => { if (profile?.profile_picture) setAvatar(profile.profile_picture); }, [profile?.profile_picture]); @@ -97,6 +101,17 @@ const VerifyAvatarPage: FC = () => { setTakingPicture(false); }, []); + const handleUpload = useCallback(async () => { + if (!avatar) return; + + const res = await fetch(avatar); + const blob = await res.blob(); + + const file = new File([blob], "avatar.png", { type: blob.type }); + + uploadAvatar(file); + }, [avatar, uploadAvatar]); + return (
@@ -161,7 +176,14 @@ const VerifyAvatarPage: FC = () => { {avatar && ( <> - +