build merdan
This commit is contained in:
parent
986dee4a99
commit
2c573a59c3
|
|
@ -1,13 +1,13 @@
|
|||
// IMPORT MODULES
|
||||
import React, { useState, useContext } from "react";
|
||||
import { LanguageContext } from "../../backend/LanguageContext";
|
||||
import { UserContext } from "../../backend/UserContext";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import React, { useState, useContext } from 'react';
|
||||
import { LanguageContext } from '../../backend/LanguageContext';
|
||||
import { UserContext } from '../../backend/UserContext';
|
||||
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 next from '../../icons/next.svg';
|
||||
import next_reverse from '../../icons/next-reverse.svg';
|
||||
// import arrow from "../../icons/arrow.svg";
|
||||
|
||||
const schema = z.object({
|
||||
|
|
@ -34,7 +34,7 @@ const AcceptStage = ({
|
|||
recipientWorkPosition,
|
||||
}) => {
|
||||
const { locale } = useContext(LanguageContext);
|
||||
const userToken = localStorage.getItem("userToken");
|
||||
const userToken = localStorage.getItem('userToken');
|
||||
const { user } = useContext(UserContext);
|
||||
const handleCardDetails = (e) => {
|
||||
setCardDetails(e.target.value);
|
||||
|
|
@ -42,7 +42,7 @@ const AcceptStage = ({
|
|||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [error, setError] = useState(false);
|
||||
const [errorMessage, setErrorMesage] = useState("");
|
||||
const [errorMessage, setErrorMesage] = useState('');
|
||||
|
||||
const {
|
||||
register,
|
||||
|
|
@ -51,8 +51,8 @@ const AcceptStage = ({
|
|||
} = useForm({
|
||||
resolver: zodResolver(schema),
|
||||
defaultValues: {
|
||||
amount: recepientAmount ? recepientAmount : "Loading",
|
||||
duration: creditDuration ? creditDuration : "loading",
|
||||
amount: recepientAmount ? recepientAmount : 'Loading',
|
||||
duration: creditDuration ? creditDuration : 'loading',
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -60,12 +60,12 @@ const AcceptStage = ({
|
|||
setIsLoading(true);
|
||||
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: {
|
||||
|
|
@ -76,7 +76,7 @@ const AcceptStage = ({
|
|||
surname: borrowerData.surname,
|
||||
lastname: borrowerData.lastname,
|
||||
availableAmount: borrowerData.availableAmount,
|
||||
clientType: "recipient",
|
||||
clientType: 'recipient',
|
||||
signRecipient: borrowerData.signRecipient,
|
||||
expDate: borrowerData.expDate,
|
||||
},
|
||||
|
|
@ -89,7 +89,7 @@ const AcceptStage = ({
|
|||
surname: guaranterData.surname,
|
||||
lastname: guaranterData.lastname,
|
||||
availableAmount: guaranterData.availableAmount,
|
||||
clientType: "guarantor",
|
||||
clientType: 'guarantor',
|
||||
signGuarantor: guaranterData.signGuarantor,
|
||||
expDate: guaranterData.expDate,
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ const AcceptStage = ({
|
|||
mrtIsInsuarance: isGuranter ? 0 : 1,
|
||||
termInYears: creditDuration,
|
||||
}),
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
|
|
@ -126,15 +126,9 @@ const AcceptStage = ({
|
|||
const response = await fetch(
|
||||
`https://shahsyotag.halkbank.gov.tm/onlineloancre-services/api/loancre`,
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
=======
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
>>>>>>> fe809f4436c87ebe37996e8f7763812ea76c2e70
|
||||
},
|
||||
body: JSON.stringify({
|
||||
clientRecipient: {
|
||||
|
|
@ -145,11 +139,7 @@ const AcceptStage = ({
|
|||
surname: borrowerData.surname,
|
||||
lastname: borrowerData.lastname,
|
||||
availableAmount: borrowerData.availableAmount,
|
||||
<<<<<<< HEAD
|
||||
clientType: "recipient",
|
||||
=======
|
||||
clientType: 'recipient',
|
||||
>>>>>>> fe809f4436c87ebe37996e8f7763812ea76c2e70
|
||||
signRecipient: borrowerData.signRecipient,
|
||||
expDate: borrowerData.expDate,
|
||||
},
|
||||
|
|
@ -162,11 +152,7 @@ const AcceptStage = ({
|
|||
surname: guaranterData.surname,
|
||||
lastname: guaranterData.lastname,
|
||||
availableAmount: guaranterData.availableAmount,
|
||||
<<<<<<< HEAD
|
||||
clientType: "guarantor",
|
||||
=======
|
||||
clientType: 'guarantor',
|
||||
>>>>>>> fe809f4436c87ebe37996e8f7763812ea76c2e70
|
||||
signGuarantor: guaranterData.signGuarantor,
|
||||
expDate: guaranterData.expDate,
|
||||
}
|
||||
|
|
@ -176,11 +162,7 @@ const AcceptStage = ({
|
|||
mrtIsInsuarance: isGuranter ? 0 : 1,
|
||||
termInYears: creditDuration,
|
||||
}),
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
},
|
||||
>>>>>>> fe809f4436c87ebe37996e8f7763812ea76c2e70
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
|
|
@ -201,60 +183,15 @@ const AcceptStage = ({
|
|||
setError(true);
|
||||
}
|
||||
};
|
||||
<<<<<<< HEAD
|
||||
|
||||
const sendData = async (requestBody) => {
|
||||
try {
|
||||
const headers = {
|
||||
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 jsonedResponse = await response.json();
|
||||
if (!cardDetails) {
|
||||
}
|
||||
|
||||
setAcceptedMessage(jsonedResponse.message);
|
||||
setIsLoading(false);
|
||||
|
||||
setStage(11);
|
||||
} catch (error) {
|
||||
console.error(error.toString());
|
||||
setError(true);
|
||||
}
|
||||
};
|
||||
|
||||
=======
|
||||
>>>>>>> fe809f4436c87ebe37996e8f7763812ea76c2e70
|
||||
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) {
|
||||
setError(true);
|
||||
|
|
@ -281,32 +218,28 @@ const AcceptStage = ({
|
|||
<section className="cs-1 err-section">
|
||||
<h1 className="cs-2-title">
|
||||
{errorMessage}
|
||||
{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ş ...'}
|
||||
</h1>
|
||||
<br />
|
||||
<button
|
||||
type="button"
|
||||
className="sign-btn reg-btn"
|
||||
onClick={() => setStage(7)}
|
||||
>
|
||||
<button type="button" className="sign-btn reg-btn" onClick={() => setStage(7)}>
|
||||
<div>
|
||||
<div className="btn-img">
|
||||
<img src={next_reverse} alt="logout" />
|
||||
</div>
|
||||
<h3>
|
||||
{locale === "TKM"
|
||||
? "Yza"
|
||||
: locale === "РУС"
|
||||
? "Назад"
|
||||
: locale === "ENG"
|
||||
? "Back"
|
||||
: "Yza"}
|
||||
{locale === 'TKM'
|
||||
? 'Yza'
|
||||
: locale === 'РУС'
|
||||
? 'Назад'
|
||||
: locale === 'ENG'
|
||||
? 'Back'
|
||||
: 'Yza'}
|
||||
</h3>
|
||||
</div>
|
||||
</button>
|
||||
|
|
@ -318,13 +251,13 @@ const AcceptStage = ({
|
|||
return (
|
||||
<section className="loading">
|
||||
<h1 className="cs-2-title">
|
||||
{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 ...'}
|
||||
</h1>
|
||||
</section>
|
||||
);
|
||||
|
|
@ -334,55 +267,50 @@ const AcceptStage = ({
|
|||
<section className="imm-cs-1 cs-1">
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<h2 className="cs-2-title">
|
||||
{locale === "TKM"
|
||||
? "Karzyň maglumatlaryny tassyklaň"
|
||||
: locale === "РУС"
|
||||
? "Подтвердите данные кредита"
|
||||
: locale === "ENG"
|
||||
? "Confirm the loan details"
|
||||
: "Karzyň maglumatlaryny tassyklaň"}
|
||||
{locale === 'TKM'
|
||||
? 'Karzyň maglumatlaryny tassyklaň'
|
||||
: locale === 'РУС'
|
||||
? 'Подтвердите данные кредита'
|
||||
: locale === 'ENG'
|
||||
? 'Confirm the loan details'
|
||||
: 'Karzyň maglumatlaryny tassyklaň'}
|
||||
</h2>
|
||||
<div className="imm-credit-form-wrapper">
|
||||
<div className="input-block">
|
||||
<label htmlFor="amount">
|
||||
{locale === "TKM"
|
||||
? "Karzyň möçberi"
|
||||
: locale === "РУС"
|
||||
? "Сумма кредита"
|
||||
: locale === "ENG"
|
||||
? "Amount of loan"
|
||||
: "Karzyň möçberi"}
|
||||
{locale === 'TKM'
|
||||
? 'Karzyň möçberi'
|
||||
: locale === 'РУС'
|
||||
? 'Сумма кредита'
|
||||
: locale === 'ENG'
|
||||
? 'Amount of loan'
|
||||
: 'Karzyň möçberi'}
|
||||
</label>
|
||||
<input {...register("amount")} type="text" id="amount" disabled />
|
||||
<input {...register('amount')} type="text" id="amount" disabled />
|
||||
{errors.amount && <span>{errors.amount.message}</span>}
|
||||
</div>
|
||||
<div className="input-block">
|
||||
<label htmlFor="duration">
|
||||
{locale === "TKM"
|
||||
? "Karzyň möhleti"
|
||||
: locale === "РУС"
|
||||
? "Срок кредита"
|
||||
: locale === "ENG"
|
||||
? "Term of loan"
|
||||
: "Karzyň möhleti"}
|
||||
{locale === 'TKM'
|
||||
? 'Karzyň möhleti'
|
||||
: locale === 'РУС'
|
||||
? 'Срок кредита'
|
||||
: locale === 'ENG'
|
||||
? 'Term of loan'
|
||||
: 'Karzyň möhleti'}
|
||||
</label>
|
||||
<input
|
||||
{...register("duration")}
|
||||
type="text"
|
||||
id="duration"
|
||||
disabled
|
||||
/>
|
||||
<input {...register('duration')} type="text" id="duration" disabled />
|
||||
{errors.duration && <span>{errors.duration.message}</span>}
|
||||
</div>
|
||||
<div className="input-block">
|
||||
<label htmlFor="code">
|
||||
{locale === "TKM"
|
||||
? "Karz kartynyň hasabyny dolduryň"
|
||||
: locale === "РУС"
|
||||
? "Заполните счет кредитной карты"
|
||||
: locale === "ENG"
|
||||
? "Fill the credit card account number"
|
||||
: "Karz kartynyň hasabyny dolduryň"}
|
||||
{locale === 'TKM'
|
||||
? 'Karz kartynyň hasabyny dolduryň'
|
||||
: locale === 'РУС'
|
||||
? 'Заполните счет кредитной карты'
|
||||
: locale === 'ENG'
|
||||
? 'Fill the credit card account number'
|
||||
: 'Karz kartynyň hasabyny dolduryň'}
|
||||
</label>
|
||||
<input
|
||||
value={cardDetails}
|
||||
|
|
@ -392,35 +320,31 @@ const AcceptStage = ({
|
|||
placeholder="6435980023168745"
|
||||
/>
|
||||
<span className="another-option" onClick={() => setStage(12)}>
|
||||
{locale === "TKM"
|
||||
? "Kartyňyz ýok bolsa, täze karty üçin ýüz tutuň"
|
||||
: locale === "РУС"
|
||||
? "Оформите новую карту, если она у вас отсувствует"
|
||||
: locale === "ENG"
|
||||
? "Apply for a new card if you do not have one"
|
||||
: "Kartyňyz ýok bolsa, täze karty üçin ýüz tutuň"}
|
||||
{locale === 'TKM'
|
||||
? 'Kartyňyz ýok bolsa, täze karty üçin ýüz tutuň'
|
||||
: locale === 'РУС'
|
||||
? 'Оформите новую карту, если она у вас отсувствует'
|
||||
: locale === 'ENG'
|
||||
? 'Apply for a new card if you do not have one'
|
||||
: 'Kartyňyz ýok bolsa, täze karty üçin ýüz tutuň'}
|
||||
</span>
|
||||
{/* {errors.code && <span>{errors.code.message}</span>} */}
|
||||
</div>
|
||||
</div>
|
||||
<div className="cu-bottom cd-2-title">
|
||||
<button
|
||||
type="button"
|
||||
className="sign-btn reg-btn"
|
||||
onClick={() => setStage(7)}
|
||||
>
|
||||
<button type="button" className="sign-btn reg-btn" onClick={() => setStage(7)}>
|
||||
<div>
|
||||
<div className="btn-img">
|
||||
<img src={next_reverse} alt="logout" />
|
||||
</div>
|
||||
<h3>
|
||||
{locale === "TKM"
|
||||
? "Yza"
|
||||
: locale === "РУС"
|
||||
? "Назад"
|
||||
: locale === "ENG"
|
||||
? "Back"
|
||||
: "Yza"}
|
||||
{locale === 'TKM'
|
||||
? 'Yza'
|
||||
: locale === 'РУС'
|
||||
? 'Назад'
|
||||
: locale === 'ENG'
|
||||
? 'Back'
|
||||
: 'Yza'}
|
||||
</h3>
|
||||
</div>
|
||||
</button>
|
||||
|
|
@ -430,17 +354,16 @@ const AcceptStage = ({
|
|||
disabled={cardDetails.length !== 23 && !isLoading ? true : false}
|
||||
onClick={() => {
|
||||
onSubmit();
|
||||
}}
|
||||
>
|
||||
}}>
|
||||
<div>
|
||||
<h3>
|
||||
{locale === "TKM"
|
||||
? "Dowam et"
|
||||
: locale === "РУС"
|
||||
? "Подтвердить "
|
||||
: locale === "ENG"
|
||||
? "Proceed"
|
||||
: "Dowam et"}
|
||||
{locale === 'TKM'
|
||||
? 'Dowam et'
|
||||
: locale === 'РУС'
|
||||
? 'Подтвердить '
|
||||
: locale === 'ENG'
|
||||
? 'Proceed'
|
||||
: 'Dowam et'}
|
||||
</h3>
|
||||
<div className="btn-img">
|
||||
<img src={next} alt="logout" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue