'use client'; import { useState, useEffect, Suspense } from 'react'; import { useSearchParams } from 'next/navigation'; import { Link, useRouter } from '@/i18n/navigation'; import Image from 'next/image'; import { useTranslations } from 'next-intl'; import { resetPassword } from '@/lib/api/auth'; function ResetPasswordContent() { const t = useTranslations('auth.resetPassword'); const tFooter = useTranslations('auth.footerLinks'); const searchParams = useSearchParams(); const router = useRouter(); const [token, setToken] = useState(''); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [success, setSuccess] = useState(false); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const [tokenError, setTokenError] = useState(false); useEffect(() => { const tokenFromUrl = searchParams.get('token'); if (tokenFromUrl) { setToken(tokenFromUrl); } else { setTokenError(true); } }, [searchParams]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); if (password !== confirmPassword) { setError(t('errors.passwordsMismatch')); return; } if (password.length < 12) { setError(t('errors.passwordMin')); return; } setLoading(true); try { await resetPassword(token, password); setSuccess(true); setTimeout(() => router.push('/login'), 3000); } catch (err: any) { setError(err.message || t('errors.generic')); } finally { setLoading(false); } }; const tips = t.raw('sidePanel.tips') as string[]; return (
Xpeditis
{tokenError ? ( <>

{t('invalidTokenTitle')}

{t('invalidTokenMessage')}

{t('requestNew')} ) : success ? ( <>

{t('successTitle')}

{t('successMessage')}

{t('goToLogin')} ) : ( <>

{t('title')}

{t('subtitle')}

{error && (

{error}

)}
setPassword(e.target.value)} className="input w-full" placeholder="••••••••••••" autoComplete="new-password" disabled={loading} />

{t('passwordHint')}

setConfirmPassword(e.target.value)} className="input w-full" placeholder="••••••••••••" autoComplete="new-password" disabled={loading} />
{t('backToLogin')}
)}
{tFooter('contact')} {tFooter('privacy')} {tFooter('terms')}

{t('sidePanel.title')}

{t('sidePanel.description')}

{tips.map(tip => (

{tip}

))}
); } export default function ResetPasswordPage() { return ( ); }