import React, { useState } from 'react'; import { resetPassword } from '../graphService'; interface ResetPasswordProps { token: string; onSuccess: () => void; } const ResetPassword: React.FC = ({ token, onSuccess }) => { const [password, setPassword] = useState(''); const [confirm, setConfirm] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (password !== confirm) { setError("Passwords do not match."); return; } if (password.length < 6) { setError("Password must be at least 6 characters."); return; } setLoading(true); setError(''); try { await resetPassword(token, password); alert("Password reset successfully. You can now login."); onSuccess(); } catch (e: any) { setError(e.message); } finally { setLoading(false); } }; return (

Set New Password

{error &&
{error}
}
setPassword(e.target.value)} className="w-full bg-slate-900 border border-slate-600 rounded-md p-2.5 text-gray-200 focus:outline-none focus:border-cyan-500" />
setConfirm(e.target.value)} className="w-full bg-slate-900 border border-slate-600 rounded-md p-2.5 text-gray-200 focus:outline-none focus:border-cyan-500" />
); }; export default ResetPassword;