From 1bb99f0ed301b907072b9b38a1a5ffd1e7a90b4a Mon Sep 17 00:00:00 2001 From: khavinshankar Date: Thu, 14 Dec 2023 18:00:33 +0530 Subject: [PATCH] improved error message for resend otp --- src/Components/ABDM/LinkABHANumberModal.tsx | 12 +++++++++++- src/Components/ABDM/models.ts | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Components/ABDM/LinkABHANumberModal.tsx b/src/Components/ABDM/LinkABHANumberModal.tsx index b17865b119a..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, @@ -427,6 +428,7 @@ const VerifyAadhaarSection = ({ 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; }