Add zustand, true-myth, primitive authentication state, startup getSession()

This commit is contained in:
2024-11-10 20:41:58 -06:00
parent af5e42abe7
commit f18adf0f41
8 changed files with 159 additions and 19 deletions

19
frontend/src/lib/state.ts Normal file
View File

@@ -0,0 +1,19 @@
import { create } from "zustand";
type UserState = {
user: {
// TODO: This will eventually carry more user information (name, avatar, etc.)
email: string;
} | null;
};
type UserActions = {
setUser: (user: UserState["user"]) => void;
logout: () => void;
};
export const useUserStore = create<UserState & UserActions>((set) => ({
user: null,
setUser: (user) => set({ user }),
logout: () => set({ user: null }),
}));