
diff --git a/src/components/ImmediateCreditsStages/PhoneAccept.js b/src/components/ImmediateCreditsStages/PhoneAccept.js
index 90c6fd1..18f0a4f 100644
--- a/src/components/ImmediateCreditsStages/PhoneAccept.js
+++ b/src/components/ImmediateCreditsStages/PhoneAccept.js
@@ -1,13 +1,13 @@
// IMPORT MODULES
-import React, { useState, useContext, useEffect } from 'react';
-import { LanguageContext } from '../../backend/LanguageContext';
-import { useForm } from 'react-hook-form';
-import { z } from 'zod';
-import { zodResolver } from '@hookform/resolvers/zod';
+import React, { useState, useContext, useEffect } from "react";
+import { LanguageContext } from "../../backend/LanguageContext";
+import { useForm } from "react-hook-form";
+import { z } from "zod";
+import { zodResolver } from "@hookform/resolvers/zod";
// IMPORT IMAGES
-import next from '../../icons/next.svg';
-import next_reverse from '../../icons/next-reverse.svg';
-import { UserContext } from '../../backend/UserContext';
+import next from "../../icons/next.svg";
+import next_reverse from "../../icons/next-reverse.svg";
+import { UserContext } from "../../backend/UserContext";
// import arrow from "../../icons/arrow.svg";
const schema = z.object({
@@ -33,7 +33,7 @@ const PhoneAccept = ({
}) => {
const { locale } = useContext(LanguageContext);
const { user } = useContext(UserContext);
- const userToken = localStorage.getItem('userToken');
+ const userToken = localStorage.getItem("userToken");
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(false);
@@ -41,7 +41,7 @@ const PhoneAccept = ({
const [invalidData, setInvalidData] = useState(false);
const [tryAgain, setTryAgain] = useState(false);
- const [codeValue, setPhoneValue] = useState('');
+ const [codeValue, setPhoneValue] = useState("");
const [errMessage, setErrMessage] = useState();
@@ -61,23 +61,26 @@ const PhoneAccept = ({
const confirmPayment = async () => {
try {
const headers = {
- 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
+ "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
};
const formData = new URLSearchParams();
- formData.append('app', 'sanlykarz');
- formData.append('id', borrowerData.idNo);
- formData.append('md-order', paymentDetails['md-order']);
- formData.append('acs-req-id', submitCardDetails['acs-request-id']);
- formData.append('acs-session-url', submitCardDetails['acs-session-url']);
- formData.append('otp', codeValue);
- formData.append('term-url', submitCardDetails['terminate-url']);
+ formData.append("app", "sanlykarz");
+ formData.append("id", borrowerData.idNo);
+ formData.append("md-order", paymentDetails["md-order"]);
+ formData.append("acs-req-id", submitCardDetails["acs-request-id"]);
+ formData.append("acs-session-url", submitCardDetails["acs-session-url"]);
+ formData.append("otp", codeValue);
+ formData.append("term-url", submitCardDetails["terminate-url"]);
- const response = await fetch('https://shahsyotag.halkbank.gov.tm/api/v1/confirm-payment', {
- method: 'POST',
- headers: headers,
- body: formData.toString(),
- });
+ const response = await fetch(
+ "https://shahsyotag.halkbank.gov.tm/api/v1/confirm-payment",
+ {
+ method: "POST",
+ headers: headers,
+ body: formData.toString(),
+ }
+ );
const jsonedResponse = await response.json();
@@ -85,13 +88,16 @@ const PhoneAccept = ({
throw new Error(`HTTP error! Status: ${response.status}`);
}
- if (jsonedResponse.status === 'ok' && jsonedResponse['final-url'].includes('status=1')) {
- console.log(jsonedResponse['final-url']);
+ if (
+ jsonedResponse.status === "ok" &&
+ jsonedResponse["final-url"].includes("status=1")
+ ) {
+ console.log(jsonedResponse["final-url"]);
setInvalidData(false);
checkPayment();
} else if (
- jsonedResponse.status === 'wrong-otp' ||
- !jsonedResponse['final-url'].includes('status=1')
+ jsonedResponse.status === "wrong-otp" ||
+ !jsonedResponse["final-url"].includes("status=1")
) {
setTryAgain(true);
} else {
@@ -103,7 +109,7 @@ const PhoneAccept = ({
const checkPayment = async () => {
try {
const response = await fetch(
- `https://shahsyotag.halkbank.gov.tm/app/api/check-payment-credit-card?paymentId=${paymentLink.id}&orderId=${paymentDetails['md-order']}&status=1`,
+ `https://shahsyotag.halkbank.gov.tm/app/api/check-payment-credit-card?paymentId=${paymentLink.id}&orderId=${paymentDetails["md-order"]}&status=1`
);
if (!response.ok) {
@@ -112,8 +118,8 @@ const PhoneAccept = ({
const jsonedResponse = await response.json();
- if (jsonedResponse.status.ErrorCode === '0') {
- console.log('success');
+ if (jsonedResponse.status.ErrorCode === "0") {
+ console.log("success");
loanCreateCheck();
}
} catch (error) {
@@ -124,12 +130,12 @@ const PhoneAccept = ({
const loanCreateCheck = async () => {
try {
const response = await fetch(
- 'https://shahsyotag.halkbank.gov.tm/onlineloancre-services/api/loancre/check',
+ "https://shahsyotag.halkbank.gov.tm/onlineloancre-services/api/loancre/check",
{
- method: 'POST',
+ method: "POST",
headers: {
- Accept: 'application/json, text/plain',
- 'Content-Type': 'application/json;charset=UTF-8',
+ Accept: "application/json, text/plain",
+ "Content-Type": "application/json;charset=UTF-8",
},
body: JSON.stringify({
clientRecipient: {
@@ -140,7 +146,7 @@ const PhoneAccept = ({
surname: borrowerData.surname,
lastname: borrowerData.lastname,
availableAmount: borrowerData.availableAmount,
- clientType: 'recipient',
+ clientType: "recipient",
signRecipient: borrowerData.signRecipient,
expDate: borrowerData.expDate,
},
@@ -153,7 +159,7 @@ const PhoneAccept = ({
surname: guaranterData.surname,
lastname: guaranterData.lastname,
availableAmount: guaranterData.availableAmount,
- clientType: 'guarantor',
+ clientType: "guarantor",
signGuarantor: guaranterData.signGuarantor,
expDate: guaranterData.expDate,
}
@@ -163,7 +169,7 @@ const PhoneAccept = ({
mrtIsInsuarance: isGuranter ? 0 : 1,
termInYears: creditDuration,
}),
- },
+ }
);
if (!response.ok) {
@@ -174,6 +180,7 @@ const PhoneAccept = ({
if (jsonedResponse.errCode === 0) {
// sendCode();
+ setStage(15);
} else {
setStage(10);
}
@@ -182,13 +189,16 @@ const PhoneAccept = ({
const sendCode = async () => {
try {
- const response = await fetch('https://shahsyotag.halkbank.gov.tm/sendOTP', {
- method: 'POST',
- headers: { 'Content-Type': 'aplication/json' },
- body: JSON.stringify({
- phone_number: user.mobile_phone,
- }),
- });
+ const response = await fetch(
+ "https://shahsyotag.halkbank.gov.tm/sendOTP",
+ {
+ method: "POST",
+ headers: { "Content-Type": "aplication/json" },
+ body: JSON.stringify({
+ phone_number: user.mobile_phone,
+ }),
+ }
+ );
if (!response.ok) {
setErrMessage(response.status);
@@ -207,19 +217,22 @@ const PhoneAccept = ({
const confirmCode = async () => {
try {
setIsLoading(true);
- const response = await fetch('https://shahsyotag.halkbank.gov.tm/validateOTP', {
- headers: { 'Content-Type': 'aplication/json' },
- method: 'POST',
+ const response = await fetch(
+ "https://shahsyotag.halkbank.gov.tm/validateOTP",
+ {
+ headers: { "Content-Type": "aplication/json" },
+ method: "POST",
- body: JSON.stringify({
- phone_number: user.mobile_phone,
- otp: codeValue,
- }),
- });
+ body: JSON.stringify({
+ phone_number: user.mobile_phone,
+ otp: codeValue,
+ }),
+ }
+ );
const jsonedResponse = await response.json();
- if (jsonedResponse === 'OTP validated successfully') {
+ if (jsonedResponse === "OTP validated successfully") {
loanCreate();
} else {
setErrMessage(true);
@@ -232,9 +245,9 @@ const PhoneAccept = ({
const response = await fetch(
`https://shahsyotag.halkbank.gov.tm/onlineloancre-services/api/loancre`,
{
- method: 'POST',
+ method: "POST",
headers: {
- 'Content-Type': 'application/json',
+ "Content-Type": "application/json",
},
body: JSON.stringify({
clientRecipient: {
@@ -245,7 +258,7 @@ const PhoneAccept = ({
surname: borrowerData.surname,
lastname: borrowerData.lastname,
availableAmount: borrowerData.availableAmount,
- clientType: 'recipient',
+ clientType: "recipient",
signRecipient: borrowerData.signRecipient,
expDate: borrowerData.expDate,
},
@@ -258,7 +271,7 @@ const PhoneAccept = ({
surname: guaranterData.surname,
lastname: guaranterData.lastname,
availableAmount: guaranterData.availableAmount,
- clientType: 'guarantor',
+ clientType: "guarantor",
signGuarantor: guaranterData.signGuarantor,
expDate: guaranterData.expDate,
}
@@ -268,7 +281,7 @@ const PhoneAccept = ({
mrtIsInsuarance: isGuranter ? 0 : 1,
termInYears: creditDuration,
}),
- },
+ }
);
if (!response.ok) {
@@ -293,23 +306,26 @@ const PhoneAccept = ({
const sendData = async (requestBody) => {
try {
const headers = {
- Accept: 'application/json',
- 'Content-Type': 'application/json',
+ Accept: "application/json",
+ "Content-Type": "application/json",
Authorization: `Bearer ${userToken}`,
};
- const response = await fetch('https://shahsyotag.halkbank.gov.tm/app/api/quick_loans', {
- method: 'POST',
- headers: headers,
- body: JSON.stringify({
- sign: requestBody.sign,
- where_works: recipientWorkPlace,
- position: recipientWorkPosition,
- mobile_phone: user.mobile_phone,
- name: borrowerData.name,
- surname: borrowerData.surname,
- lastname: borrowerData.lastname,
- }),
- });
+ const response = await fetch(
+ "https://shahsyotag.halkbank.gov.tm/app/api/quick_loans",
+ {
+ method: "POST",
+ headers: headers,
+ body: JSON.stringify({
+ sign: requestBody.sign,
+ where_works: recipientWorkPlace,
+ position: recipientWorkPosition,
+ mobile_phone: user.mobile_phone,
+ name: borrowerData.name,
+ surname: borrowerData.surname,
+ lastname: borrowerData.lastname,
+ }),
+ }
+ );
const jsonedResponse = await response.json();
if (!cardDetails) {
@@ -327,13 +343,16 @@ const PhoneAccept = ({
const codeResend = async () => {
try {
- const response = await fetch('https://shahsyotag.halkbank.gov.tm/sendOTP', {
- method: 'POST',
- headers: { 'Content-Type': 'aplication/json' },
- body: JSON.stringify({
- phone_number: user.mobile_phone,
- }),
- });
+ const response = await fetch(
+ "https://shahsyotag.halkbank.gov.tm/sendOTP",
+ {
+ method: "POST",
+ headers: { "Content-Type": "aplication/json" },
+ body: JSON.stringify({
+ phone_number: user.mobile_phone,
+ }),
+ }
+ );
if (!response.ok) {
setError(true);
@@ -379,13 +398,13 @@ const PhoneAccept = ({
return (
- {locale === 'TKM'
- ? 'Garaşmagyňyzy haýyş edýäris ...'
- : locale === 'РУС'
- ? 'Пожалуйста, подождите...'
- : locale === 'ENG'
- ? 'Please wait...'
- : 'Garaşmagyňyzy haýyş edýäris ...'}
+ {locale === "TKM"
+ ? "Garaşmagyňyzy haýyş edýäris ..."
+ : locale === "РУС"
+ ? "Пожалуйста, подождите..."
+ : locale === "ENG"
+ ? "Please wait..."
+ : "Garaşmagyňyzy haýyş edýäris ..."}
);
@@ -396,28 +415,32 @@ const PhoneAccept = ({
{errMessage}
- {locale === 'TKM'
- ? 'Bir zat ýalňyş ...'
- : locale === 'РУС'
- ? ' Ошибка...'
- : locale === 'ENG'
- ? ' Error...'
- : ' Bir zat ýalňyş ...'}
+ {locale === "TKM"
+ ? "Bir zat ýalňyş ..."
+ : locale === "РУС"
+ ? " Ошибка..."
+ : locale === "ENG"
+ ? " Error..."
+ : " Bir zat ýalňyş ..."}
-