import { useState } from 'react'; import { Gavel, ShieldCheck, Scale, BrainCircuit, Eye, EyeOff } from 'lucide-react'; import { login, register } from '../api'; const logo = "https://huggingface.co/spaces/JenishMakwana/RAG/resolve/main/frontend-react/public/logo.png"; export default function Auth({ onLoginSuccess }) { const [isLogin, setIsLogin] = useState(true); const [username, setUsername] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [showPassword, setShowPassword] = useState(false); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const toggleAuthMode = () => { setIsLogin(!isLogin); setUsername(''); setEmail(''); setPassword(''); setError(''); setShowPassword(false); }; const handleSubmit = async (e) => { e.preventDefault(); setError(''); setLoading(true); try { if (isLogin) { const data = await login(email, password); onLoginSuccess(data.access_token, email); } else { // Frontend validation for complexity const hasUpper = /[A-Z]/.test(password); const hasNumber = /\d/.test(password); const hasSpecial = /[@$!%*?&]/.test(password); if (!hasUpper || !hasNumber || !hasSpecial || password.length < 8) { throw new Error('Password does not meet complexity requirements.'); } await register(username, email, password); const data = await login(email, password); onLoginSuccess(data.access_token, email); } } catch (err) { setError(err.message); } finally { setLoading(false); } }; return (
{/* Left Panel: Legal Case Law Brand Info (Unique & Cinematic) */}
Logo
Legal Case Law RAG

The Supreme Intelligence for Case Law Research

An advanced, cloud-resilient legal analysis assistant powered by lightning-fast AI reranking and secure document audit guardrails.

Dual Cloud LLM Failover & Real-Time Stream responses
High-Accuracy Indian Legal Embeddings & Reranking
Secure Native Cryptography & Document Audit Guardrails
{/* Right Panel: The Interactive Sleek Glassmorphic Form Card */}
Logo

{isLogin ? 'Welcome Back' : 'Create Account'}

{isLogin ? 'Sign in to access your legal documents and case analysis.' : 'Create an account to start your legal case research.'}

{!isLogin && (
setUsername(e.target.value)} required />
)}
setEmail(e.target.value)} required />
setPassword(e.target.value)} required minLength={8} style={{ paddingRight: '2.5rem', width: '100%' }} />
{!isLogin && (

Must contain 8+ characters, 1 uppercase, 1 number, and 1 special symbol.

)}
{error && (
{error}
)}

{isLogin ? "New to Case Assistant? " : "Already have an account? "} {isLogin ? 'Create one now' : 'Sign in here'}

); }