import { useState } from 'react' import { Network, Loader2 } from 'lucide-react' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { authApi } from '@/api/client' import { useAuthStore } from '@/stores/authStore' export function LoginPage() { const [username, setUsername] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState('') const [loading, setLoading] = useState(false) const login = useAuthStore((s) => s.login) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError('') setLoading(true) try { const res = await authApi.login(username, password) login(res.data.access_token) } catch (err: unknown) { const hasResponse = err && typeof err === 'object' && 'response' in err setError(hasResponse ? 'Invalid username or password' : 'Could not reach the server — check your CORS_ORIGINS setting') } finally { setLoading(false) } } return (
HomeLab Visualizer
Credentials configured in .env