import { useState, useEffect } from 'react'; import './Form.css'; function App() { const [payerName, setPayerName] = useState(''); const [payerINN, setPayerINN] = useState(''); const [payerPhoneEmail, setPayerPhoneEmail] = useState(''); const [payerAddress, setPayerAddress] = useState(''); const [clientId, setClientId] = useState(''); const [payerBankAccount, setPayerBankAccount] = useState(''); const [amount, setAmount] = useState('0-00'); const [payerAccounts, setPayerAccounts] = useState([]); const handleBlur = () => { console.log(amount); console.log(payerBankAccount); console.log(payerINN); }; useEffect(() => { const URLParams = new URLSearchParams(window.location.search); const cnum = URLParams.get('cnum'); const ftype = URLParams.get('type'); 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: cnum }, { name: 'form_type', value: ftype }, ], 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); setPayerAccounts(data.accounts); }; fetchUsingAsyncAwaitWithFetchApi(); }, []); return ( <>