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'; import PublicLayout from '../components/layout/PublicLayout'; 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 (

Password Reset Successfully! 🎉

Your password has been updated. You can now log in with your new password.

); } // Invalid token state if (!token) { return (

Invalid Reset Link

This password reset link is invalid or has expired. Please request a new one.

Request New Link
); } // Reset password form return (
{error && (

{error}

)}
{/* New Password */}
setNewPassword(e.target.value)} className="pl-10 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary-500 focus:border-primary-500" placeholder="••••••••" required disabled={loading} />
{/* Confirm Password */}
setConfirmPassword(e.target.value)} className="pl-10 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary-500 focus:border-primary-500" placeholder="••••••••" required disabled={loading} />
{confirmPassword && newPassword !== confirmPassword && (

Passwords do not match

)}
Back to Login
); }; export default ResetPasswordPage;