import React, { useState } from "react"; // import { useNavigate } from "react-router-dom"; // Removed unused import import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; interface AuthFormProps { view: "login" | "signup"; setView: React.Dispatch>; } const AuthForm: React.FC = ({ view, setView }) => { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(false); const [err, setErr] = useState(null); const handleAuth = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setErr(null); if (!email || !password) { setErr("Please enter email and password"); setLoading(false); return; } // Removed Supabase authentication logic for UI review // if (view === "login") { // const { error } = await supabase.auth.signInWithPassword({ email, password }); // if (error) { // setErr( // error.message === "Invalid login credentials" // ? "Invalid email or password." // : error.message // ); // } else { // navigate("/"); // } // } else { // const { error } = await supabase.auth.signUp({ // email, // password, // options: { emailRedirectTo: window.location.origin + "/" }, // }); // if (error) { // setErr(error.message); // } else { // setErr("Check your email for a confirmation link!"); // } // } setLoading(false); }; return ( <>
) => setEmail(e.target.value)} disabled={loading} className="focus:ring-2 focus:ring-[#7f7fd5] focus:border-[#38f9d7] bg-gradient-to-tr from-[#fff] via-[#38f9d7]/20 to-[#ffd200]/20 border-2 border-[#38f9d7]/50 text-[#19142a] dark:text-white placeholder:text-muted-foreground font-semibold transition-all shadow-lg shadow-[#38f9d7]/10 " /> ) => setPassword(e.target.value)} disabled={loading} className="focus:ring-2 focus:ring-[#ffd200] focus:border-[#f7971e] bg-gradient-to-br from-[#fff] via-[#38f9d7]/10 to-[#f7971e]/20 border-2 border-[#ffd200]/60 text-[#19142a] dark:text-white placeholder:text-muted-foreground font-semibold transition-all shadow-lg shadow-[#ffd200]/10 " /> {err && (

{err}

)}
{view === "login" ? ( <> New here? { setView("signup"); setErr(null); }} tabIndex={0} role="button" aria-label="Create an account" onKeyDown={e => { if (e.key === "Enter" || e.key === " ") { setView("signup"); setErr(null); } }} > Create an account ) : ( <> Already have an account? { setView("login"); setErr(null); }} tabIndex={0} role="button" aria-label="Sign in" onKeyDown={e => { if (e.key === "Enter" || e.key === " ") { setView("login"); setErr(null); } }} > Sign in )}
); }; export default AuthForm;