"use client"; import { useState } from "react"; import Link from "next/link"; import { useRouter } from "next/navigation"; import AuthShell, { Field } from "@/components/AuthShell"; import { GoogleButton, OrDivider } from "@/components/GoogleAuth"; import { api, setToken } from "@/lib/api"; import { useLanguage } from "@/contexts/LanguageContext"; export default function Login() { const r = useRouter(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [err, setErr] = useState(""); const [loading, setLoading] = useState(false); const { setLang } = useLanguage(); async function submit(e: React.FormEvent) { e.preventDefault(); setErr(""); setLoading(true); try { const res = await api("/auth/login", { method: "POST", body: JSON.stringify({ email, password }), }); r.push(`/login-otp?email=${encodeURIComponent(email)}`); return; } catch (e: any) { setErr( typeof e.detail === "string" ? e.detail : "Invalid email or password" ); } finally { setLoading(false); } } return (
setEmail(e.target.value)} required /> setPassword(e.target.value)} required /> {err &&

{err}

}
Forgot password? Create account
); }