From 2c573a59c3defe91e70e7d7c80f2ddad4a26fea7 Mon Sep 17 00:00:00 2001 From: Kakabay <2kakabayashyrberdyew@gmail.com> Date: Tue, 30 Apr 2024 13:35:58 +0500 Subject: [PATCH] build merdan --- .../ImmediateCreditsStages/AcceptStage.js | 279 +++++++----------- 1 file changed, 101 insertions(+), 178 deletions(-) diff --git a/src/components/ImmediateCreditsStages/AcceptStage.js b/src/components/ImmediateCreditsStages/AcceptStage.js index 766e741..dd412a8 100644 --- a/src/components/ImmediateCreditsStages/AcceptStage.js +++ b/src/components/ImmediateCreditsStages/AcceptStage.js @@ -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 = ({

{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ş ...'}


- @@ -318,13 +251,13 @@ const AcceptStage = ({ 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 ...'}

); @@ -334,55 +267,50 @@ const AcceptStage = ({

- {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ň'}

- + {errors.amount && {errors.amount.message}}
- + {errors.duration && {errors.duration.message}}
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ň'} {/* {errors.code && {errors.code.message}} */}
- @@ -430,17 +354,16 @@ const AcceptStage = ({ disabled={cardDetails.length !== 23 && !isLoading ? true : false} onClick={() => { onSubmit(); - }} - > + }}>

- {locale === "TKM" - ? "Dowam et" - : locale === "РУС" - ? "Подтвердить " - : locale === "ENG" - ? "Proceed" - : "Dowam et"} + {locale === 'TKM' + ? 'Dowam et' + : locale === 'РУС' + ? 'Подтвердить ' + : locale === 'ENG' + ? 'Proceed' + : 'Dowam et'}

logout