import { useState, useEffect } from "react"; import { getApiBase } from "../api"; function ResetPassword({ token, onSuccess, onBack }) { const [password, setPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const handleSubmit = async (e) => { e.preventDefault(); setError(""); if (password !== confirmPassword) { setError("הסיסמאות אינן תואמות"); return; } if (password.length < 6) { setError("הסיסמה חייבת להכיל לפחות 6 תווים"); return; } setLoading(true); try { const response = await fetch(`${getApiBase()}/reset-password`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ token: token, new_password: password, }), }); const data = await response.json(); if (response.ok) { onSuccess(); } else { setError(data.detail || "שגיאה באיפוס הסיסמה"); } } catch (err) { setError("שגיאה באיפוס הסיסמה"); } finally { setLoading(false); } }; return (

איפוס סיסמה

הזן את הסיסמה החדשה שלך

{error &&
{error}
}
setPassword(e.target.value)} required placeholder="הזן סיסמה חדשה" autoComplete="new-password" minLength={6} />
setConfirmPassword(e.target.value)} required placeholder="הזן שוב את הסיסמה" autoComplete="new-password" minLength={6} />

); } export default ResetPassword;