'use client'; import { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Lock, X, Eye, EyeOff, ShieldCheck, ShieldAlert } from 'lucide-react'; import { useAuth } from '@/contexts/AuthContext'; import { useSettings } from '@/contexts/SettingsContext'; import { translations } from '@/lib/translations'; export default function AuthModal() { const { showAuthModal, authenticate, closeAuthModal } = useAuth(); const { settings } = useSettings(); const t = translations[settings.language]; const [password, setPassword] = useState(''); const [showPassword, setShowPassword] = useState(false); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!password.trim()) { setError(t.passwordRequired || 'Password is required'); return; } setIsLoading(true); setError(''); const success = await authenticate(password); if (!success) { setError(t.invalidPassword || 'Invalid password'); } setIsLoading(false); }; const handleClose = () => { setPassword(''); setError(''); closeAuthModal(); }; return ( {showAuthModal && ( e.stopPropagation()} > {/* Header */}

{t.authRequired || 'Authentication Required'}

{t.authDescription || 'Enter password to modify tasks'}

{/* Form */}
{ setPassword(e.target.value); setError(''); }} placeholder={t.enterPassword || 'Enter password'} className="w-full bg-slate-100 dark:bg-slate-900/50 border-none rounded-2xl px-6 py-4 pr-12 text-slate-900 dark:text-white placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-amber-500/50" autoFocus />
{/* Error Message */} {error && ( {error} )} {/* Submit Button */}
{/* Footer Hint */}

{t.authHint || 'Contact administrator if you forgot the password'}

)}
); }