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 (
An advanced, cloud-resilient legal analysis assistant powered by lightning-fast AI reranking and secure document audit guardrails.
{isLogin ? 'Sign in to access your legal documents and case analysis.' : 'Create an account to start your legal case research.'}
{isLogin ? "New to Case Assistant? " : "Already have an account? "} {isLogin ? 'Create one now' : 'Sign in here'}