feat: authorization

This commit is contained in:
moolcoov
2025-03-01 20:24:23 +03:00
parent f74b8df791
commit 535b0c39dc
22 changed files with 560 additions and 108 deletions
@@ -0,0 +1,23 @@
import { create } from "zustand";
import { User } from "../types/user";
import { getCurrentUser } from "../api/user";
interface UserState {
user: User | null;
loading: boolean;
fetchUser: () => Promise<void>;
}
const useUserStore = create<UserState>((set) => ({
user: null,
loading: true,
fetchUser: async () => {
set({ loading: true });
const user = await getCurrentUser();
set({ user, loading: false });
},
}));
export { useUserStore };