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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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("دریافت اطلاعات کاربر ناموفق بود. دوباره تلاش کنید.");
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user