fix(auth): surface real OTP error on verification step
The booking login step showed only a generic error when /api/auth/token returned 400, so an invalid or expired OTP looked like a broken page. The backend returns the reason (ERR_AUTH_002 invalid / ERR_AUTH_003 expired) in errors[].message, forwarded by the route; show it via toast. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Button, CircularProgress } from "@mui/material";
|
||||
import { request } from "@/services/response";
|
||||
import Cookies from "js-cookie";
|
||||
import { toast } from "react-toastify";
|
||||
import { handleTimeExpiresToken } from "@/helper";
|
||||
|
||||
function SendReq({
|
||||
@@ -26,10 +27,13 @@ function SendReq({
|
||||
} else {
|
||||
setLoading(false);
|
||||
setIsError(true);
|
||||
const message = response?.errors?.[0]?.message || "کد تأیید نادرست یا منقضی شده است.";
|
||||
toast.error(message);
|
||||
}
|
||||
} catch {
|
||||
setLoading(false);
|
||||
setIsError(true);
|
||||
toast.error("خطا در برقراری ارتباط. دوباره تلاش کنید.");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user