gseps-front/src/stores/useAuthStore.ts

39 lines
670 B
TypeScript
Raw Normal View History

2023-08-23 08:12:52 +00:00
import { create } from 'zustand';
import { devtools } from 'zustand/middleware';
/**
* Auth State Type
*/
export interface AuthStateType {
loggedIn: boolean;
}
/**
* Auth Action Type
*/
export interface AuthActionType {
2023-09-06 05:00:01 +00:00
setSignIn: () => void;
2023-08-23 08:12:52 +00:00
setSignOut: () => void;
}
export type AuthStoreType = AuthStateType & AuthActionType;
export const useAuthStore = create<AuthStoreType>()(
devtools(
(set): AuthStoreType => ({
loggedIn: false,
2023-09-06 05:00:01 +00:00
setSignIn: () =>
2023-08-23 08:12:52 +00:00
set(() => ({
loggedIn: true,
})),
setSignOut: () =>
set(() => ({
loggedIn: false,
})),
}),
{ name: 'auth' },
),
);