import { useState } from 'react'; import { useNavigate, useSearchParams, Link } from 'react-router-dom'; import { authAPI } from '../services/api'; import { Video, Lock, CheckCircle, XCircle, Loader2 } from 'lucide-react'; import PasswordStrengthIndicator from '../components/common/PasswordStrengthIndicator'; const ResetPasswordPage = () => { const [searchParams] = useSearchParams(); const navigate = useNavigate(); const token = searchParams.get('token'); const [newPassword, setNewPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [loading, setLoading] = useState(false); const [success, setSuccess] = useState(false); const [error, setError] = useState(''); const handleSubmit = async (e) => { e.preventDefault(); setError(''); // Validation if (!token) { setError('Invalid or missing reset token'); return; } if (newPassword !== confirmPassword) { setError('Passwords do not match'); return; } if (newPassword.length < 8) { setError('Password must be at least 8 characters long'); return; } setLoading(true); try { await authAPI.resetPassword(token, newPassword); setSuccess(true); } catch (err) { setError(err.data?.error || 'Failed to reset password. The link may have expired.'); } finally { setLoading(false); } }; // Success state if (success) { return (
Your password has been updated. You can now log in with your new password.
This password reset link is invalid or has expired. Please request a new one.
Request New LinkEnter your new password below
{error}