Frontend: React+Vite+Tailwind, Login, Dashboard, Agents, Customers, Settings, Dark Theme, Nginx auf .20

This commit is contained in:
cynfo3000
2026-02-28 15:40:07 +01:00
parent c6c8257cf0
commit c56fded7d7
24 changed files with 5548 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
import { create } from 'zustand'
import api from '../api/client'
export const useAuthStore = create((set) => ({
user: null,
isAuthenticated: !!api.getToken(),
loading: true,
login: async (username, password) => {
const data = await api.login(username, password)
set({ user: data.user, isAuthenticated: true })
return data
},
logout: () => {
api.logout()
set({ user: null, isAuthenticated: false })
},
checkAuth: async () => {
if (!api.getToken()) {
set({ loading: false, isAuthenticated: false })
return
}
try {
const data = await api.me()
set({ user: data.user || data, isAuthenticated: true, loading: false })
} catch {
api.logout()
set({ user: null, isAuthenticated: false, loading: false })
}
},
}))