This commit is contained in:
Mikan
2026-06-19 11:28:04 +03:00
commit 53c89829a8
80 changed files with 12482 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import { create } from "zustand";
import { persist } from "zustand/middleware";
import type { User } from "@/types";
interface AuthState {
token: string | null;
user: User | null;
setAuth: (token: string, user: User) => void;
logout: () => void;
isAdmin: () => boolean;
}
export const useAuthStore = create<AuthState>()(
persist(
(set, get) => ({
token: null,
user: null,
setAuth: (token, user) => set({ token, user }),
logout: () => set({ token: null, user: null }),
isAdmin: () => !!get().user?.is_admin,
}),
{ name: "ai-rpg-auth" }
)
);