gseps-front/src/stores/useAuthStore.ts

39 lines
670 B
TypeScript

import { create } from 'zustand';
import { devtools } from 'zustand/middleware';
/**
* Auth State Type
*/
export interface AuthStateType {
loggedIn: boolean;
}
/**
* Auth Action Type
*/
export interface AuthActionType {
setSignIn: () => void;
setSignOut: () => void;
}
export type AuthStoreType = AuthStateType & AuthActionType;
export const useAuthStore = create<AuthStoreType>()(
devtools(
(set): AuthStoreType => ({
loggedIn: false,
setSignIn: () =>
set(() => ({
loggedIn: true,
})),
setSignOut: () =>
set(() => ({
loggedIn: false,
})),
}),
{ name: 'auth' },
),
);