feat : add beneficiary api for inside bank
This commit is contained in:
@@ -145,20 +145,18 @@ export default function AddBeneficiaryOthers() {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const trimmedIfsc = ifsccode.trim().toUpperCase();
|
const trimmedIfsc = ifsccode.trim().toUpperCase();
|
||||||
const isValidIfscCode = (code: string) => {
|
// const isValidIfscCode = (code: string) => {
|
||||||
return /^[A-Z]{4}0[0-9]{6}$/.test(code);
|
// return /^[A-Z]{4}0[0-9]{6}$/.test(code);
|
||||||
};
|
// };
|
||||||
|
// if (!isValidIfscCode(trimmedIfsc)) {
|
||||||
if (!isValidIfscCode(trimmedIfsc)) {
|
// notifications.show({
|
||||||
notifications.show({
|
// title: "Invalid IFSC Code",
|
||||||
title: "Invalid IFSC Code",
|
// message: "Must be 11 characters: 4 uppercase letters, 0, then 6 digits (e.g., HDFC0123456)",
|
||||||
message: "Must be 11 characters: 4 uppercase letters, 0, then 6 digits (e.g., HDFC0123456)",
|
// color: "red",
|
||||||
color: "red",
|
// });
|
||||||
});
|
// return;
|
||||||
return;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
if (accountNo.length < 10 || accountNo.length > 17) {
|
if (accountNo.length < 10 || accountNo.length > 17) {
|
||||||
notifications.show({
|
notifications.show({
|
||||||
@@ -185,23 +183,46 @@ export default function AddBeneficiaryOthers() {
|
|||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const token = localStorage.getItem("access_token");
|
const token = localStorage.getItem("access_token");
|
||||||
const response = await fetch(`/api/beneficiary/validate/outside-bank?accountNo=${accountNo}&ifscCode=${ifsccode}&remitterName=""`,
|
let response;
|
||||||
{
|
// IF IFSC starts with "KACE" (within bank)
|
||||||
method: "GET",
|
if (ifsccode.startsWith("KACE")) {
|
||||||
headers: {
|
response = await fetch(
|
||||||
"Content-Type": "application/json",
|
`/api/beneficiary/validate/within-bank?accountNumber=${accountNo}`,
|
||||||
"X-Login-Type": "IB",
|
{
|
||||||
Authorization: `Bearer ${token}`,
|
method: "GET",
|
||||||
},
|
headers: {
|
||||||
}
|
"Content-Type": "application/json",
|
||||||
);
|
"X-Login-Type": "IB",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// ELSE: other banks → keep your old API
|
||||||
|
else {
|
||||||
|
response = await fetch(
|
||||||
|
`/api/beneficiary/validate/outside-bank?accountNo=${accountNo}&ifscCode=${ifsccode}&remitterName=""`,
|
||||||
|
{
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-Login-Type": "IB",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (response.ok && data?.name) {
|
if (response.ok && data?.name) {
|
||||||
setBeneficiaryName(data.name);
|
setBeneficiaryName(data.name);
|
||||||
setValidationStatus("success");
|
setValidationStatus("success");
|
||||||
setIsVisibilityLocked(true);
|
setIsVisibilityLocked(true);
|
||||||
setOtpSent(true);
|
setOtpSent(true);
|
||||||
const otp = await handleSendOtp();
|
|
||||||
|
await handleSendOtp();
|
||||||
|
|
||||||
notifications.show({
|
notifications.show({
|
||||||
withBorder: true,
|
withBorder: true,
|
||||||
color: "green",
|
color: "green",
|
||||||
|
|||||||
Reference in New Issue
Block a user