import { useState, type FormEvent } from "react"; import { useNavigate } from "react-router-dom"; import { Wallet, ArrowRight, AlertCircle } from "lucide-react"; import { login } from "@/lib/api"; import { useAuth } from "@/AuthContext"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; export default function LoginPage() { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const navigate = useNavigate(); const { setAuthenticated } = useAuth(); const handleSubmit = async (e: FormEvent) => { e.preventDefault(); setLoading(true); setError(""); try { await login(username, password); setAuthenticated(true); navigate("/", { replace: true }); } catch { setError("Invalid credentials"); } finally { setLoading(false); } }; return (