'use client'; import { useState } from 'react'; import { Button } from './ui/button'; import { Input } from './ui/input'; import { useAuth } from './AuthProvider'; import { Lock, User, AlertCircle } from 'lucide-react'; import { useRegisterModal } from './modal/ModalStackProvider'; interface AuthModalProps { isOpen: boolean; } export function AuthModal({ isOpen }: AuthModalProps) { useRegisterModal(isOpen, { id: 'auth-modal', allowEscape: false, onClose: () => null }); const { login } = useAuth(); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); setError(null); const success = await login(username, password); if (!success) { setError('Invalid username or password'); } setIsLoading(false); }; if (!isOpen) return null; return (
{/* Header */}

Authentication Required

{/* Content */}

Please enter your credentials to access the application.

setUsername(e.target.value)} disabled={isLoading} className="pl-10" required />
setPassword(e.target.value)} disabled={isLoading} className="pl-10" required />
{error && (
{error}
)}
); }