From 78c60c64c2fad312249ad32b7ccc1775df56f9aa Mon Sep 17 00:00:00 2001 From: sync Date: Tue, 24 Sep 2024 19:33:48 +0300 Subject: [PATCH] Implement fetching payer data using getClientInfo. --- src/App.css | 2 +- src/App.jsx | 53 +++++++++++++++++++++++++++++++++++++++----------- vite.config.js | 17 +++++++++++++--- 3 files changed, 57 insertions(+), 15 deletions(-) diff --git a/src/App.css b/src/App.css index b871a12..57a3e0a 100644 --- a/src/App.css +++ b/src/App.css @@ -77,7 +77,7 @@ body { height: 100vh; height: 100svh; display: grid; - grid-template-columns: 1fr 1fr 1fr 1fr; + grid-template-columns: 1fr 1.3fr 0.5fr 1fr; grid-template-rows: 1rem 1rem 1rem 1rem; grid-row-gap: 15px; } diff --git a/src/App.jsx b/src/App.jsx index 3f616c3..4a98714 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,8 +1,43 @@ -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import './App.css'; function App() { - const [count, setCount] = useState(0); + const [payerName, setPayerName] = useState(''); + const [payerINN, setPayerINN] = useState(''); + const [payerPhoneEmail, setPayerPhoneEmail] = useState(''); + const [payerAddress, setPayerAddress] = useState(''); + const [clientId, setClientId] = useState(''); + const [payerBankAccount, setPayerBankAccount] = useState(''); + + useEffect(() => { + const fetchUsingAsyncAwaitWithFetchApi = async () => { + const response = await fetch('/pmtvalidation/validate/', { + method: 'POST', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + fields: [ + { name: 'payer_account' }, + { name: 'client_id', value: '00234052' }, + { name: 'form_type', value: 'EXT-RUB' }, + ], + action: 'getClientInfo', + }), + }); + + const data = await response.json(); + setPayerName(data.fields[3].value); + setPayerINN(data.fields[4].value); + setPayerPhoneEmail(data.fields[6].value); + setPayerAddress(data.fields[7].value); + setClientId(data.fields[1].value); + setPayerBankAccount(data.fields[12].value); + }; + + fetchUsingAsyncAwaitWithFetchApi(); + }, []); return ( <> @@ -20,17 +55,15 @@ function App() {
Плательщик:
-
Шигорина Наталья Николаевна 00234052
+
{`${payerName} ${clientId}`}
Номер счета:
ИНН:
-
123456789123
+
{payerINN}
Сумма:
@@ -39,13 +72,11 @@ function App() {
Телефон или электронный адрес:
-
+7-4942326120 schnn@mail.ru
+
{payerPhoneEmail}
Адрес места жительства:
-
- г. Москва, ул. Дмитрия Ульянова 158/1, кв. 12 -
+
{payerAddress}
Комиссии и расходы: