Cleanup
This commit is contained in:
@ -3,10 +3,10 @@ import { TOKEN_AUTH_KEY, TOKEN_EXPIRY_DURATION, TOKEN_ISSUED_DATE_KEY, USER_DATA
|
||||
import { AuthState } from '../interfaces/auth';
|
||||
import AuthService from '../services/AuthService';
|
||||
|
||||
export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
export const useAuthStore = create<AuthState>(() => ({
|
||||
isAuthenticated: false,
|
||||
token: null,
|
||||
userData: {},
|
||||
userData: null,
|
||||
}));
|
||||
|
||||
const login = (token: string) => {
|
||||
@ -20,7 +20,7 @@ const logout = () => {
|
||||
localStorage.removeItem(TOKEN_AUTH_KEY);
|
||||
localStorage.removeItem(USER_DATA_KEY);
|
||||
localStorage.removeItem(TOKEN_ISSUED_DATE_KEY);
|
||||
useAuthStore.setState(() => ({ isAuthenticated: false, token: null, userData: {} }));
|
||||
useAuthStore.setState(() => ({ isAuthenticated: false, token: null, userData: null }));
|
||||
}
|
||||
|
||||
const initAuth = async () => {
|
||||
|
@ -1,12 +1,13 @@
|
||||
import { create } from 'zustand';
|
||||
import { PreferencesState } from '../interfaces/preferences';
|
||||
|
||||
export const usePrefStore = create<PreferencesState>((set, get) => ({
|
||||
export const usePrefStore = create<PreferencesState>(() => ({
|
||||
darkMode: false
|
||||
}));
|
||||
|
||||
const getDarkMode = () => {
|
||||
const darkMode = localStorage.getItem('darkMode')
|
||||
usePrefStore.setState(() => ({ darkMode: darkMode?.toLowerCase() === "true" ? true : false }))
|
||||
return darkMode
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user