mirror of
https://github.com/lorsanstand/Aether.git
synced 2026-06-19 12:05:16 +03:00
26 lines
624 B
TypeScript
26 lines
624 B
TypeScript
import { create } from 'zustand';
|
|
|
|
interface User {
|
|
id: string;
|
|
email: string;
|
|
username: string;
|
|
}
|
|
|
|
interface AuthStore {
|
|
user: User | null;
|
|
isAuthenticated: boolean;
|
|
isLoading: boolean;
|
|
setUser: (user: User | null) => void;
|
|
setLoading: (loading: boolean) => void;
|
|
logout: () => void;
|
|
}
|
|
|
|
export const useAuthStore = create<AuthStore>((set) => ({
|
|
user: null,
|
|
isAuthenticated: false,
|
|
isLoading: true,
|
|
setUser: (user) => set({ user, isAuthenticated: !!user, isLoading: false }),
|
|
setLoading: (loading) => set({ isLoading: loading }),
|
|
logout: () => set({ user: null, isAuthenticated: false }),
|
|
}));
|