chore(build): refactor codebase for production
This commit is contained in:
@ -16,6 +16,7 @@ interface AuthState {
|
||||
registrationMessage: string | null;
|
||||
login: (credentials: LoginRequest) => Promise<boolean>;
|
||||
register: (credentials: RegistrationRequest) => Promise<boolean>;
|
||||
fetchUser: () => Promise<void>;
|
||||
logout: () => void;
|
||||
clearError: () => void;
|
||||
}
|
||||
@ -85,6 +86,18 @@ export const useAuthStore = create<AuthState>()(
|
||||
}
|
||||
},
|
||||
|
||||
fetchUser: async () => {
|
||||
const token = useAuthStore.getState().token;
|
||||
if (!token) return;
|
||||
|
||||
try {
|
||||
const user = await api.fetchUser(token);
|
||||
set({ user });
|
||||
} catch (error) {
|
||||
console.error("Failed to refresh user:", error);
|
||||
}
|
||||
},
|
||||
|
||||
logout: () => {
|
||||
set({
|
||||
user: null,
|
||||
|
||||
Reference in New Issue
Block a user