Skip to content

Commit

Permalink
improved error message for resend otp
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar committed Dec 14, 2023
1 parent 3348268 commit 1bb99f0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Components/ABDM/LinkABHANumberModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -427,6 +428,7 @@ const VerifyAadhaarSection = ({
body: {
txnId: txnId,
},
silent: true,
});
setIsSendingOtp(false);

Expand All @@ -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",
});
}
};

Expand Down
9 changes: 9 additions & 0 deletions src/Components/ABDM/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1bb99f0

Please sign in to comment.