mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-22 06:15:47 +00:00
init
This commit is contained in:
@@ -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,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user