This commit is contained in:
ValdiANS
2025-09-26 11:06:31 +07:00
parent a5524686a6
commit 2e1b0fef2b
36 changed files with 8716 additions and 79 deletions
+25
View File
@@ -0,0 +1,25 @@
import { create } from 'zustand';
import { UserWithRoles } from '@/types/api';
type AuthStore = {
user?: UserWithRoles;
isLoadingUser?: boolean;
setUser: (newUserData?: UserWithRoles) => void;
setIsLoadingUser: (isLoading?: boolean) => void;
};
const useAuthStore = create<AuthStore>()((set) => ({
user: undefined,
isLoadingUser: false,
setUser: (newUserData) => set({ user: newUserData }),
setIsLoadingUser: (isLoading) => set({ isLoadingUser: Boolean(isLoading) }),
}));
export const useAuth = () => {
const { user, setUser } = useAuthStore();
return {
user,
setUser,
};
};