import React, { useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { useAuth } from "../context/AuthContext"; export default function AuthModal({ isOpen, onClose }) { const { login, register, loginWithGoogle } = useAuth(); const [isLoginView, setIsLoginView] = useState(true); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [name, setName] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); if (!isOpen) return null; const handleSubmit = async (e) => { e.preventDefault(); setError(""); setLoading(true); let res; if (isLoginView) { res = await login(email, password); } else { res = await register(email, password, name); } setLoading(false); if (res.success) { onClose(); } else { setError(res.error || "Authentication failed"); } }; const handleGoogleClick = async () => { setError(""); setLoading(true); const res = await loginWithGoogle(); setLoading(false); if (res.success) { onClose(); } else if (res.error) { setError(res.error); } }; return (
{/* Backdrop */} {/* Modal Card */} {/* Close button */} {/* Title / Description */}

{isLoginView ? "Begin Investigation" : "Create Security Profile"}

{isLoginView ? "Sign in to deploy the Multi-Agent engine" : "Register credentials to access shared context"}

{/* Social Sign-In (Google) */} {/* Divider */}
Or Use Credentials
{/* Form */}
{!isLoginView && (
setName(e.target.value)} placeholder="Karan Shelar" className="w-full rounded-lg border border-white/10 bg-white/[0.03] px-4 py-2.5 text-sm text-white placeholder-white/30 focus:border-white/30 focus:outline-none transition-colors" />
)}
setEmail(e.target.value)} placeholder="agent@agentbond.ai" className="w-full rounded-lg border border-white/10 bg-white/[0.03] px-4 py-2.5 text-sm text-white placeholder-white/30 focus:border-white/30 focus:outline-none transition-colors" />
setPassword(e.target.value)} placeholder="••••••••••••" className="w-full rounded-lg border border-white/10 bg-white/[0.03] px-4 py-2.5 text-sm text-white placeholder-white/30 focus:border-white/30 focus:outline-none transition-colors" />
{error &&
{error}
}
{/* Toggle View Link */}
{isLoginView ? "New Investigator?" : "Already registered?"}{" "}
); }