diff --git a/src/Components/ABDM/LinkABHANumberModal.tsx b/src/Components/ABDM/LinkABHANumberModal.tsx index 367c9815db1..f5da5fedfb9 100644 --- a/src/Components/ABDM/LinkABHANumberModal.tsx +++ b/src/Components/ABDM/LinkABHANumberModal.tsx @@ -13,6 +13,7 @@ import TextFormField from "../Form/FormFields/TextFormField"; import { classNames } from "../../Utils/utils"; import request from "../../Utils/request/request"; import routes from "../../Redux/api"; +import { ABDMError } from "./models"; export const validateRule = ( condition: boolean, @@ -423,10 +424,11 @@ const VerifyAadhaarSection = ({ if (!validateAadhaar() || !txnId) return; setIsSendingOtp(true); - const { res, data } = await request(routes.abha.generateAadhaarOtp, { + const { res, data } = await request(routes.abha.resendAadhaarOtp, { body: { txnId: txnId, }, + silent: true, }); setIsSendingOtp(false); @@ -436,7 +438,15 @@ const VerifyAadhaarSection = ({ msg: "OTP has been resent to the mobile number registered with the Aadhar number.", }); } else { - Notify.Error({ msg: JSON.stringify(data) }); + Notify.Error({ + msg: + (data as unknown as ABDMError).details + ?.map((detail) => detail.message) + .join(", ") + .trim() || + (data as unknown as ABDMError).message || + "OTP resend failed", + }); } }; diff --git a/src/Components/ABDM/models.ts b/src/Components/ABDM/models.ts index f992cc9df4f..b85445fa6cd 100644 --- a/src/Components/ABDM/models.ts +++ b/src/Components/ABDM/models.ts @@ -48,6 +48,15 @@ export interface IHealthId { authMethods?: string[]; } +export interface ABDMError { + code: string; + details?: { + code: string; + message: string; + }[]; + message: string; +} + export interface IAadhaarOtp { txnId: string; }