Files
juwan-frontend/store/auth.ts
T
2026-02-20 20:02:29 +08:00

21 lines
581 B
TypeScript

import { create } from "zustand"
import type { UserRole } from "@/lib/types"
interface AuthState {
isAuthenticated: boolean
currentRole: UserRole
verifiedRoles: UserRole[]
switchRole: (role: UserRole) => void
login: () => void
logout: () => void
}
export const useAuthStore = create<AuthState>((set) => ({
isAuthenticated: false,
currentRole: "consumer",
verifiedRoles: ["consumer"],
switchRole: (role) => set({ currentRole: role }),
login: () => set({ isAuthenticated: true }),
logout: () => set({ isAuthenticated: false, currentRole: "consumer" }),
}))