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 { Button, CircularProgress } from "@mui/material";
|
||||||
import { request } from "@/services/response";
|
import { request } from "@/services/response";
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
|
import { toast } from "react-toastify";
|
||||||
import { handleTimeExpiresToken } from "@/helper";
|
import { handleTimeExpiresToken } from "@/helper";
|
||||||
|
|
||||||
function SendReq({
|
function SendReq({
|
||||||
@@ -26,10 +27,13 @@ function SendReq({
|
|||||||
} else {
|
} else {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setIsError(true);
|
setIsError(true);
|
||||||
|
const message = response?.errors?.[0]?.message || "کد تأیید نادرست یا منقضی شده است.";
|
||||||
|
toast.error(message);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setIsError(true);
|
setIsError(true);
|
||||||
|
toast.error("خطا در برقراری ارتباط. دوباره تلاش کنید.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user