diff --git a/frontend/src/lib/auth.ts b/frontend/src/lib/auth.ts index 9c8f0ba..ffc6f0e 100644 --- a/frontend/src/lib/auth.ts +++ b/frontend/src/lib/auth.ts @@ -15,6 +15,7 @@ interface AuthState { logout: () => void login: (username: string, password: string) => Promise checkAuth: () => Promise + setHydrated: () => void } export const useAuth = create()( @@ -23,10 +24,12 @@ export const useAuth = create()( token: null, refreshToken: null, user: null, - isLoading: false, + isLoading: true, isHydrated: false, error: null, + setHydrated: () => set({ isHydrated: true }), + setAuth: (token, refreshToken, user) => { set({ token, refreshToken, user, error: null }) }, @@ -101,6 +104,7 @@ export const useAuth = create()( onRehydrateStorage: () => (state) => { if (state) { state.isHydrated = true + state.isLoading = false } }, }