loancre_check api added before sendOTP api
This commit is contained in:
parent
569672ff03
commit
4d0cf293b6
|
|
@ -52,6 +52,58 @@ const AcceptStage = ({
|
|||
},
|
||||
});
|
||||
|
||||
const loanCreateCheck = async () => {
|
||||
try {
|
||||
const response = fetch(
|
||||
'https://shahsyotag.halkbank.gov.tm/onlineloancre-services/api/loancre/check',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'aplication/json' },
|
||||
body: JSON.stringify({
|
||||
clientRecipient: {
|
||||
idSeria: borrowerData.idSeria,
|
||||
idNo: borrowerData.idNo,
|
||||
accountNo: borrowerData.accountNo,
|
||||
name: borrowerData.name,
|
||||
surname: borrowerData.surname,
|
||||
availableAmount: borrowerData.availableAmount,
|
||||
clientType: 'recipient',
|
||||
signRecipient: borrowerData.signRecipient,
|
||||
},
|
||||
clientGuarantor: isGuranter
|
||||
? {
|
||||
idSeria: guaranterData.idSeria,
|
||||
idNo: guaranterData.idNo,
|
||||
accountNo: guaranterData.accountNo,
|
||||
name: guaranterData.name,
|
||||
surname: guaranterData.surname,
|
||||
availableAmount: guaranterData.availableAmount,
|
||||
clientType: 'guarantor',
|
||||
signGuarantor: guaranterData.signGuarantor,
|
||||
}
|
||||
: null,
|
||||
availableAmount: recepientAmount,
|
||||
creditCardAccountNumber: cardDetails,
|
||||
mrtIsInsuarance: isGuranter ? 0 : 1,
|
||||
termInYears: creditDuration,
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
|
||||
const jsonedResponse = await response.json();
|
||||
|
||||
if (jsonedResponse.errCode === 0) {
|
||||
sendCode();
|
||||
} else {
|
||||
setStage(10);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const sendCode = async () => {
|
||||
try {
|
||||
const response = await fetch('https://shahsyotag.halkbank.gov.tm/sendOTP', {
|
||||
|
|
@ -73,8 +125,7 @@ const AcceptStage = ({
|
|||
};
|
||||
|
||||
const onSubmit = () => {
|
||||
sendCode();
|
||||
setStage(9);
|
||||
loanCreateCheck();
|
||||
};
|
||||
|
||||
if (error) {
|
||||
|
|
|
|||
|
|
@ -110,14 +110,65 @@ const PhoneAccept = ({
|
|||
|
||||
if (jsonedResponse.status.ErrorCode === '0') {
|
||||
console.log('success');
|
||||
|
||||
sendCode();
|
||||
loanCreateCheck();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error.toString());
|
||||
}
|
||||
};
|
||||
|
||||
const loanCreateCheck = async () => {
|
||||
try {
|
||||
const response = fetch(
|
||||
'https://shahsyotag.halkbank.gov.tm/onlineloancre-services/api/loancre/check',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'aplication/json' },
|
||||
body: JSON.stringify({
|
||||
clientRecipient: {
|
||||
idSeria: borrowerData.idSeria,
|
||||
idNo: borrowerData.idNo,
|
||||
accountNo: borrowerData.accountNo,
|
||||
name: borrowerData.name,
|
||||
surname: borrowerData.surname,
|
||||
availableAmount: borrowerData.availableAmount,
|
||||
clientType: 'recipient',
|
||||
signRecipient: borrowerData.signRecipient,
|
||||
},
|
||||
clientGuarantor: isGuranter
|
||||
? {
|
||||
idSeria: guaranterData.idSeria,
|
||||
idNo: guaranterData.idNo,
|
||||
accountNo: guaranterData.accountNo,
|
||||
name: guaranterData.name,
|
||||
surname: guaranterData.surname,
|
||||
availableAmount: guaranterData.availableAmount,
|
||||
clientType: 'guarantor',
|
||||
signGuarantor: guaranterData.signGuarantor,
|
||||
}
|
||||
: null,
|
||||
availableAmount: recepientAmount,
|
||||
creditCardAccountNumber: cardDetails,
|
||||
mrtIsInsuarance: isGuranter ? 0 : 1,
|
||||
termInYears: creditDuration,
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
|
||||
const jsonedResponse = await response.json();
|
||||
|
||||
if (jsonedResponse.errCode === 0) {
|
||||
sendCode();
|
||||
} else {
|
||||
setStage(10);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const sendCode = async () => {
|
||||
console.log('startred');
|
||||
|
||||
|
|
@ -158,14 +209,14 @@ const PhoneAccept = ({
|
|||
const jsonedResponse = await response.json();
|
||||
|
||||
if (jsonedResponse === 'OTP validated successfully') {
|
||||
fetchData();
|
||||
loanCreate();
|
||||
} else {
|
||||
setErrMessage(true);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const fetchData = async () => {
|
||||
const loanCreate = async () => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://shahsyotag.halkbank.gov.tm/onlineloancre-services/api/loancre`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue