"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { createClient } from "@/lib/supabase/client"; export function AuthForm({ mode }: { mode: "login" | "signup" }) { const router = useRouter(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [info, setInfo] = useState(""); const [loading, setLoading] = useState(false); async function handleSubmit() { setError(""); setInfo(""); setLoading(true); const supabase = createClient(); if (mode === "signup") { const { error } = await supabase.auth.signUp({ email, password }); if (error) { setError(error.message); setLoading(false); return; } setInfo("Account created — check your email to confirm, then sign in."); setLoading(false); return; } const { error } = await supabase.auth.signInWithPassword({ email, password }); if (error) { setError(error.message); setLoading(false); return; } router.push("/dashboard"); router.refresh(); } return ( <> {error &&