import React, { useState } from 'react'; import { Button, Input, Label } from 'xertica-ui/ui'; import { XerticaLogo } from 'xertica-ui/brand'; import { ArrowLeft, CheckCircle2, AlertCircle } from 'lucide-react'; import { useNavigate } from 'react-router-dom'; import { AuthPageShell } from './AuthPageShell'; import { useTranslation } from 'react-i18next'; export function ResetPasswordContent() { const navigate = useNavigate(); const { t } = useTranslation(); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(''); const [passwordStrength, setPasswordStrength] = useState<'weak' | 'medium' | 'strong' | null>( null ); const checkPasswordStrength = (pwd: string) => { if (pwd.length === 0) { setPasswordStrength(null); return; } if (pwd.length < 6) setPasswordStrength('weak'); else if (pwd.length < 10) setPasswordStrength('medium'); else setPasswordStrength('strong'); }; const handlePasswordChange = (value: string) => { setPassword(value); checkPasswordStrength(value); setError(''); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); if (password.length < 6) { setError(t('resetPassword.errorMinLength')); return; } if (password !== confirmPassword) { setError(t('resetPassword.errorMismatch')); return; } setIsLoading(true); await new Promise(resolve => setTimeout(resolve, 1500)); navigate('/login', { state: { resetSuccess: true } }); setIsLoading(false); }; const getStrengthColor = () => { switch (passwordStrength) { case 'weak': return 'text-destructive'; case 'medium': return 'text-[var(--chart-3)]'; case 'strong': return 'text-[var(--chart-2)]'; default: return 'text-muted-foreground'; } }; const getStrengthText = () => { switch (passwordStrength) { case 'weak': return t('resetPassword.strengthWeak'); case 'medium': return t('resetPassword.strengthMedium'); case 'strong': return t('resetPassword.strengthStrong'); default: return ''; } }; return (

{t('resetPassword.heading')}

{t('resetPassword.subheading')}

handlePasswordChange(e.target.value)} /> {passwordStrength && (
{getStrengthText()}
)}
{ setConfirmPassword(e.target.value); setError(''); }} />

{t('resetPassword.requirements')}

= 6 ? 'text-[var(--chart-2)]' : 'text-muted-foreground'}`} /> {t('resetPassword.requirementMinChars')}
0 ? 'text-[var(--chart-2)]' : 'text-muted-foreground'}`} /> {t('resetPassword.requirementMatch')}
{error && (
{error}
)} ); }