"use client"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { api } from "@/lib/api/client"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; export default function LoginPage() { const router = useRouter(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); async function onSubmit(e: React.FormEvent) { e.preventDefault(); setLoading(true); setError(null); const { error } = await api.POST("/api/v1/auth/login", { body: { email, password } }); setLoading(false); if (error) { setError("Invalid email or password."); return; } router.push("/trees"); } return ( Sign in
setEmail(e.target.value)} required />
setPassword(e.target.value)} required />
{error &&

{error}

}

No account?{" "} Create one

); }