feat(api): surface backend error messages globally via toast

Show the backend's Persian error (errors[0].message, e.g. rate-limit
'درخواست‌های زیاد') as a toast for any failed request.* call, from the
axios response interceptor — so failures are no longer silent. 401 still
logs out/redirects without a toast; callers can opt out with
config.skipErrorToast. Drop now-redundant per-caller alerts/toasts in
the booking submit, payment, and OTP userinfo paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-15 18:25:11 +03:30
co-authored by Claude Opus 4.8
parent 08f5829a22
commit 9912ae06ca
4 changed files with 26 additions and 13 deletions
@@ -127,7 +127,6 @@ function SubmitData({ setStep, data, prevData, setErrors, doctor, isForAnother,
} catch (error) {
setLoading(false);
if (error?.response?.status === 409) {
alert("این زمان همین لحظه توسط کاربر دیگری رزرو شد. لطفاً ساعت دیگری انتخاب کنید.");
setStep(0);
return;
}
-1
View File
@@ -63,7 +63,6 @@ function Paying({ setStep, appointmentId, expiresAt, doctor, selectedSlot, selec
}
} catch (error) {
console.error("Payment error:", error);
alert("خطا در پرداخت");
setLoading(false);
}
};
@@ -103,7 +103,6 @@ function SendReq({
.catch(() => {
setLoading(false);
setIsError(true);
toast.error("دریافت اطلاعات کاربر ناموفق بود. دوباره تلاش کنید.");
});
};