diff --git a/web/src/pages/Verify/Review/index.tsx b/web/src/pages/Verify/Review/index.tsx index 5f849ed..2b1038b 100644 --- a/web/src/pages/Verify/Review/index.tsx +++ b/web/src/pages/Verify/Review/index.tsx @@ -2,7 +2,7 @@ import { Button } from "@/components/ui/button"; import Avatar from "@/feature/Avatar"; import { useAuth } from "@/store/auth"; import { useVerify } from "@/store/verify"; -import type { FC } from "react"; +import { type FC } from "react"; const VerifyReviewPage: FC = () => { const profile = useAuth((s) => s.profile); @@ -38,7 +38,7 @@ const VerifyReviewPage: FC = () => { disabled={verifying} onClick={finishVerify} > - Back Home + Finish ); diff --git a/web/src/store/verify.ts b/web/src/store/verify.ts index a573359..0ab3e6b 100644 --- a/web/src/store/verify.ts +++ b/web/src/store/verify.ts @@ -13,28 +13,25 @@ export type VerifyStep = "email" | "avatar" | "review"; export interface IVerifyState { step: VerifyStep | null | false; - redirect: string | null; - - loadStep: (profile: UserProfile) => void; - requesting: boolean; requested: boolean; - requestOTP: () => Promise; - confirming: boolean; - confirmOTP: (req: ConfirmEmailRequest) => Promise; - uploading: boolean; - uploadAvatar: (image: File) => Promise; - verifying: boolean; - verify: () => Promise; - - setRedirect: (redirect: string) => void; } -export const useVerify = create((set) => ({ +export interface IVerifyActions { + loadStep: (profile: UserProfile) => void; + requestOTP: () => Promise; + confirmOTP: (req: ConfirmEmailRequest) => Promise; + uploadAvatar: (image: File) => Promise; + verify: () => Promise; + setRedirect: (redirect: string) => void; + reset: () => void; +} + +const initialState: IVerifyState = { step: null, redirect: null, @@ -43,6 +40,12 @@ export const useVerify = create((set) => ({ confirming: false, uploading: false, verifying: false, +}; + +export const useVerify = create((set, get) => ({ + ...initialState, + + reset: () => set(initialState), loadStep: (profile) => { if (!profile.email_verified) { @@ -116,6 +119,7 @@ export const useVerify = create((set) => ({ console.log("ERR: Failed to finish verification:", err); } finally { set({ verifying: false }); + get().reset(); } }, }));