feat: verify state
This commit is contained in:
34
web/src/store/verify.ts
Normal file
34
web/src/store/verify.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { create } from "zustand";
|
||||
import { useAuth } from "./auth";
|
||||
import type { UserProfile } from "@/types";
|
||||
|
||||
export type VerifyStep = "email" | "avatar" | "review";
|
||||
|
||||
export interface IVerifyState {
|
||||
step: VerifyStep | null;
|
||||
|
||||
loadStep: (profile: UserProfile) => void;
|
||||
}
|
||||
|
||||
export const useVerify = create<IVerifyState>((set) => ({
|
||||
step: null,
|
||||
|
||||
loadStep: (profile) => {
|
||||
if (!profile.email_verified) {
|
||||
set({ step: "email" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!profile.avatar_verified) {
|
||||
set({ step: "avatar" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!profile.verified) {
|
||||
set({ step: "review" });
|
||||
return;
|
||||
}
|
||||
|
||||
set({ step: null });
|
||||
},
|
||||
}));
|
Reference in New Issue
Block a user