Fix payer bank accounts combobox.

master
sync 1 year ago
parent 714cbc7a3d
commit 6448fb1bb4

@ -1,5 +1,5 @@
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import './App.css'; import './Form.css';
function App() { function App() {
const [payerName, setPayerName] = useState(''); const [payerName, setPayerName] = useState('');
@ -9,6 +9,7 @@ function App() {
const [clientId, setClientId] = useState(''); const [clientId, setClientId] = useState('');
const [payerBankAccount, setPayerBankAccount] = useState(''); const [payerBankAccount, setPayerBankAccount] = useState('');
const [amount, setAmount] = useState('0-00'); const [amount, setAmount] = useState('0-00');
const [payerAccounts, setPayerAccounts] = useState([]);
const handleBlur = () => { const handleBlur = () => {
console.log(amount); console.log(amount);
@ -37,7 +38,6 @@ function App() {
action: 'getClientInfo', action: 'getClientInfo',
}), }),
}); });
const data = await response.json(); const data = await response.json();
setPayerName(data.fields[3].value); setPayerName(data.fields[3].value);
setPayerINN(data.fields[4].value); setPayerINN(data.fields[4].value);
@ -45,6 +45,7 @@ function App() {
setPayerAddress(data.fields[7].value); setPayerAddress(data.fields[7].value);
setClientId(data.fields[1].value); setClientId(data.fields[1].value);
setPayerBankAccount(data.fields[12].value); setPayerBankAccount(data.fields[12].value);
setPayerAccounts(data.accounts);
}; };
fetchUsingAsyncAwaitWithFetchApi(); fetchUsingAsyncAwaitWithFetchApi();
@ -73,7 +74,13 @@ function App() {
onChange={(e) => setPayerBankAccount(e.target.value)} onChange={(e) => setPayerBankAccount(e.target.value)}
onBlur={handleBlur} onBlur={handleBlur}
> >
<option id="1">{payerBankAccount}</option> {payerAccounts.map((item, ind) => (
<option key={`cbAccountNumber_${ind}`}>
{item.description
? `${item.cbAccountNumber}|${item.description}`
: item.cbAccountNumber}
</option>
))}
</select> </select>
</div> </div>
<div className="child">ИНН:</div> <div className="child">ИНН:</div>

@ -1,9 +1,4 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client'; import { createRoot } from 'react-dom/client';
import App from './App.jsx'; import Form from './Form.jsx';
createRoot(document.getElementById('root')).render( createRoot(document.getElementById('root')).render(<Form />);
<StrictMode>
<App />
</StrictMode>
);

Loading…
Cancel
Save