Initial commit

This commit is contained in:
Pit Friedrich
2025-11-15 14:58:44 +01:00
commit 84c9e3f855
38 changed files with 14052 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import { create } from "zustand";
import { persist } from "zustand/middleware";
interface User {
id: string;
username: string;
}
interface AuthState {
token: string | null;
user: User | null;
isAuthenticated: boolean;
login: (token: string, user: User) => void;
logout: () => void;
}
export const useAuthStore = create<AuthState>()(
persist(
(set) => ({
token: null,
user: null,
isAuthenticated: false,
login: (token: string, user: User) =>
set({ token, user, isAuthenticated: true }),
logout: () =>
set({ token: null, user: null, isAuthenticated: false }),
}),
{
name: 'auth-storage',
}
)
);