import { useState } from 'react'; import { Eye, EyeOff, LockKeyhole, Shield, User, } from 'lucide-react'; import { Button } from '@/components/ui/Button'; import { loginApi } from '@/services/loginApi'; import logoIcon from '@/assets/logo-icon.png'; type LoginScreenProps = { onLogin: (keepLoggedIn: boolean) => void; }; export function LoginScreen({ onLogin, }: LoginScreenProps) { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [keepLoggedIn, setKeepLoggedIn] = useState(false); const [showPassword, setShowPassword] = useState(false); const [submitting, setSubmitting] = useState(false); async function handleSubmit(event: React.FormEvent) { event.preventDefault(); if (submitting) { return; } setSubmitting(true); setError(''); try { console.log('LOGIN TRY', { username: username.trim(), passwordLength: password.length, }); const response = await loginApi.login( username.trim(), password, ); if (response.authenticated) { onLogin(keepLoggedIn); return; } setError('Credenciais inválidas.'); } catch (error) { setError(`Falha no login: ${String(error)}`); } finally { setSubmitting(false); } } return (
VPN Orchestrator