"use client" import { useState } from "react" import { useRouter } from "next/navigation" import Link from "next/link" export default function LoginPage() { const router = useRouter() const [form, setForm] = useState({ email: "", password: "" }) const [loading, setLoading] = useState(false) const [error, setError] = useState("") const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setLoading(true) setError("") try { const res = await fetch("/api/auth/login", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(form) }) if (res.ok) { router.push("/autojobs/dashboard") } else { setError("Invalid email or password") } } catch { setError("Network error") } setLoading(false) } return (
Welcome back
Don't have an account? Sign up free