Initial scaffold: full-stack RackMapper application
Complete project scaffold with working auth, REST API, Prisma/SQLite schema, Docker config, and React frontend for both Rack Planner and Service Mapper modules. Both server and client pass TypeScript strict mode with zero errors. Initial migration applied. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { create } from 'zustand';
|
||||
import { apiClient } from '../api/client';
|
||||
|
||||
interface AuthState {
|
||||
isAuthenticated: boolean;
|
||||
loading: boolean;
|
||||
checkAuth: () => Promise<void>;
|
||||
login: (username: string, password: string) => Promise<void>;
|
||||
logout: () => Promise<void>;
|
||||
}
|
||||
|
||||
export const useAuthStore = create<AuthState>((set) => ({
|
||||
isAuthenticated: false,
|
||||
loading: true,
|
||||
|
||||
checkAuth: async () => {
|
||||
try {
|
||||
await apiClient.auth.me();
|
||||
set({ isAuthenticated: true, loading: false });
|
||||
} catch {
|
||||
set({ isAuthenticated: false, loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
login: async (username, password) => {
|
||||
await apiClient.auth.login(username, password);
|
||||
set({ isAuthenticated: true });
|
||||
},
|
||||
|
||||
logout: async () => {
|
||||
try {
|
||||
await apiClient.auth.logout();
|
||||
} finally {
|
||||
set({ isAuthenticated: false });
|
||||
}
|
||||
},
|
||||
}));
|
||||
Reference in New Issue
Block a user