import { useState } from "react"; import { AudioLines } from "lucide-react"; import { toast } from "sonner"; import { supabase } from "@/integrations/supabase/client"; import { lovable } from "@/integrations/lovable/index"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; export function SignIn() { const [mode, setMode] = useState<"in" | "up">("in"); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [name, setName] = useState(""); const [busy, setBusy] = useState(false); const oauth = async (provider: "google" | "lovable") => { const r = await lovable.auth.signInWithOAuth(provider, { redirect_uri: window.location.origin }); if (r.error) toast.error("Sign-in didn't work. Please try again."); }; const submit = async (e: React.FormEvent) => { e.preventDefault(); setBusy(true); if (mode === "up") { const { data, error } = await supabase.auth.signUp({ email, password, options: { emailRedirectTo: window.location.origin, data: { full_name: name.trim() } }, }); if (error) toast.error(error.message); else if (!data.session) toast.success("Check your email to confirm your account."); } else { const { error } = await supabase.auth.signInWithPassword({ email, password }); if (error) toast.error(error.message); } setBusy(false); }; return (

{mode === "in" ? "Welcome back." : "Create your account."} Sign in to Codesynux.

Your agents, calls and projects stay private to you.

or with email
{mode === "up" && setName(e.target.value)} placeholder="Your name" maxLength={40} required className="h-12 rounded-2xl" />} setEmail(e.target.value)} placeholder="Email" required className="h-12 rounded-2xl" /> setPassword(e.target.value)} placeholder="Password (6+ characters)" minLength={6} required className="h-12 rounded-2xl" />
); }