From 23af1bf15b609c67d2dde7fb8ca257cd773e9a35 Mon Sep 17 00:00:00 2001 From: sync Date: Mon, 30 Sep 2024 19:06:55 +0300 Subject: [PATCH] Create props to fields mappings for the entire form. --- src/Form.jsx | 104 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 90 insertions(+), 14 deletions(-) diff --git a/src/Form.jsx b/src/Form.jsx index 6971550..9ce5edf 100644 --- a/src/Form.jsx +++ b/src/Form.jsx @@ -10,11 +10,40 @@ function App() { const [payerBankAccount, setPayerBankAccount] = useState(''); const [amount, setAmount] = useState('0-00'); const [payerAccounts, setPayerAccounts] = useState([]); + const [payerAccount, setPayerAccount] = useState(''); + const [chargesDetails, setChargesDetails] = useState('OUR'); + const [bnfAccount, setBNFAccount] = useState(''); + const [bnfBankBic, setBNFBankBic] = useState(''); + const [bnfINN, setBNFINN] = useState(''); + const [bnfKPP, setBNFKPP] = useState(''); + const [bnfName, setBNFName] = useState(''); + const [bnfBankName, setBNFBankName] = useState(''); + const [paymentDetails, setPaymentDetails] = useState(''); + const [codePurpose, setCodePurpose] = useState('1'); + const [taxUINCode, setTaxUINCode] = useState(''); + + const fields = [ + { name: 'payer_name', value: payerName }, + { name: 'client_id', value: clientId }, + { name: 'payer_inn', value: payerINN }, + { name: 'payer_phone_email', value: payerPhoneEmail }, + { name: 'payer_address', value: payerAddress }, + { name: 'amount', value: amount }, + { name: 'payer_account', value: payerAccount }, + { name: 'details_of_charges', value: chargesDetails }, + { name: 'bnf_account', value: bnfAccount }, + { name: 'bnf_bank_bic', value: bnfBankBic }, + { name: 'bnf_inn', value: bnfINN }, + { name: 'bnf_kpp', value: bnfKPP }, + { name: 'bnf_name', value: bnfName }, + { name: 'bnf_bank_name', value: bnfBankName }, + { name: 'payment_details', value: paymentDetails }, + { name: 'code_purpose', value: codePurpose }, + { name: 'tax_uin_code', value: taxUINCode }, + ]; const handleBlur = () => { - console.log(amount); - console.log(payerBankAccount); - console.log(payerINN); + console.log(fields); }; useEffect(() => { @@ -71,7 +100,8 @@ function App() {
Номер счета:
+
@@ -118,7 +153,12 @@ function App() {
БИК:
- + setBNFBankBic(e.target.value)} + onBlur={handleBlur} + style={{ maxWidth: '32ch' }} + />
№ Корр. счета:
@@ -128,27 +168,50 @@ function App() {
Номер счета:
- + setBNFAccount(e.target.value)} + onBlur={handleBlur} + style={{ maxWidth: '32ch' }} + />
ИНН:
- + setBNFINN(e.target.value)} + onBlur={handleBlur} + style={{ maxWidth: '32ch' }} + />
КПП (103):
- + setBNFKPP(e.target.value)} + onBlur={handleBlur} + style={{ maxWidth: '32ch' }} + />
Наименование:
- + setBNFName(e.target.value)} + onBlur={handleBlur} + style={{ width: '100ch' }} + />
Банк получателя:
-
+
{bnfBankName}
Назначение платежа: