import React, { useState } from 'react'; import { Button } from '../../ui/button'; import { Input } from '../../ui/input'; import { Label } from '../../ui/label'; import { XerticaLogo } from '../../brand/xertica-logo'; import { AuthPageShell, usePasswordStrength, PasswordStrengthMeter } from '../../blocks/auth'; import { ArrowLeft, CheckCircle2, AlertCircle } from 'lucide-react'; import { useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { useBrandColors } from '../../../contexts/BrandColorsContext'; /** * Reset Password Page component. * * @description * A screen where users can set a new password after verifying their identity. * Includes password strength validation logic and clear visual feedback for * password requirements. * * @ai-rules * 1. Validation: Uses the shared `usePasswordStrength` hook to categorize passwords as 'weak', 'medium', or 'strong'. * 2. Feedback: Uses `CheckCircle2` icons to show real-time progress on password requirements (length, matching). * 3. Navigation: Redirects to `/login` with a `resetSuccess` flag after a successful password update. */ export function ResetPasswordPage() { const navigate = useNavigate(); const { t } = useTranslation(); const { currentTheme } = useBrandColors(); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(''); const passwordStrength = usePasswordStrength(password); const handlePasswordChange = (value: string) => { setPassword(value); setError(''); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); // Validations if (password.length < 6) { setError(t('resetPassword.errorMinLength')); return; } if (password !== confirmPassword) { setError(t('resetPassword.errorMismatch')); return; } setIsLoading(true); // Simulate password reset await new Promise(resolve => setTimeout(resolve, 1500)); // Redirect to login with success message navigate('/login', { state: { resetSuccess: true } }); setIsLoading(false); }; const content = ( <>

{t('resetPassword.heading')}

{t('resetPassword.subheading')}

handlePasswordChange(e.target.value)} />
{ 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}
)}
); return currentTheme === 'xertica' ? ( {content} ) : ( {content} ); }