send code removed

This commit is contained in:
Kakabay 2024-04-26 17:55:41 +05:00
parent bb4be10cbc
commit 7c9e759657
2 changed files with 103 additions and 120 deletions

View File

@ -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({
@ -32,7 +32,7 @@ const AcceptStage = ({
setErrMessageTkm,
}) => {
const { locale } = useContext(LanguageContext);
const userToken = localStorage.getItem("userToken");
const userToken = localStorage.getItem('userToken');
const { user } = useContext(UserContext);
const handleCardDetails = (e) => {
@ -41,7 +41,7 @@ const AcceptStage = ({
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(false);
const [errorMessage, setErrorMesage] = useState("");
const [errorMessage, setErrorMesage] = useState('');
const {
register,
@ -50,20 +50,20 @@ const AcceptStage = ({
} = useForm({
resolver: zodResolver(schema),
defaultValues: {
amount: recepientAmount ? recepientAmount : "Loading",
duration: creditDuration ? creditDuration : "loading",
amount: recepientAmount ? recepientAmount : 'Loading',
duration: creditDuration ? creditDuration : 'loading',
},
});
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: {
@ -73,7 +73,7 @@ const AcceptStage = ({
name: borrowerData.name,
surname: borrowerData.surname,
availableAmount: borrowerData.availableAmount,
clientType: "recipient",
clientType: 'recipient',
signRecipient: borrowerData.signRecipient,
},
clientGuarantor: isGuranter
@ -84,7 +84,7 @@ const AcceptStage = ({
name: guaranterData.name,
surname: guaranterData.surname,
availableAmount: guaranterData.availableAmount,
clientType: "guarantor",
clientType: 'guarantor',
signGuarantor: guaranterData.signGuarantor,
}
: null,
@ -93,7 +93,7 @@ const AcceptStage = ({
mrtIsInsuarance: isGuranter ? 0 : 1,
termInYears: creditDuration,
}),
}
},
);
if (!response.ok) {
@ -103,7 +103,7 @@ const AcceptStage = ({
const jsonedResponse = await response.json();
if (jsonedResponse.errCode === 0) {
sendCode();
// sendCode();
} else {
setErrMessage(jsonedResponse.messageRu);
setErrMessageTkm(jsonedResponse.message);
@ -115,16 +115,13 @@ const AcceptStage = ({
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);
@ -151,32 +148,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>
@ -188,13 +181,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>
);
@ -204,55 +197,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="surname">
{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}
@ -262,35 +250,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>
@ -300,17 +284,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" />

View File

@ -169,7 +169,7 @@ const PhoneAccept = ({
const jsonedResponse = await response.json();
if (jsonedResponse.errCode === 0) {
sendCode();
// sendCode();
} else {
setStage(10);
}