summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2021-04-24 21:27:06 +0300
committereug-vs <eug-vs@keemail.me>2021-04-24 21:27:06 +0300
commit5c18f9b95e84d42d593d2445edf7f6ddb2a31192 (patch)
tree9755b09b5edaf2b7fbb533eb08b9cb44bdb6ecc8
parent2894f6bf244f66fa64ba8915db18763e78ef03c9 (diff)
downloadcommercel-ui-5c18f9b95e84d42d593d2445edf7f6ddb2a31192.tar.gz
feat: add account field into transfer form
-rw-r--r--src/services/accounts/index.ts1
-rw-r--r--src/services/transfers/TransferForm.tsx9
-rw-r--r--src/services/types.ts1
3 files changed, 10 insertions, 1 deletions
diff --git a/src/services/accounts/index.ts b/src/services/accounts/index.ts
index fc3a830..1936a9c 100644
--- a/src/services/accounts/index.ts
+++ b/src/services/accounts/index.ts
@@ -7,6 +7,7 @@ const service: ServiceParams<Account> = {
nameSingular: 'Счёт',
tableFields: [
{ key: 'name', label: 'Название' },
+ { key: 'currency', label: 'Валюта' },
{ key: 'balance', label: 'Баланс' },
],
searchBy: ['name'],
diff --git a/src/services/transfers/TransferForm.tsx b/src/services/transfers/TransferForm.tsx
index 92846a3..a10630a 100644
--- a/src/services/transfers/TransferForm.tsx
+++ b/src/services/transfers/TransferForm.tsx
@@ -12,20 +12,27 @@ const mapper = (item: Contractor) => ({ key: item._id, label: item.name });
const TransferForm: React.FC<FormikProps<Transfer>> = ({ setFieldValue, values }) => {
const { data: contractors } = hooks.contractors.useList();
+ const { data: accounts } = hooks.accounts.useList();
if (!values.date) setFieldValue('date', moment().format('YYYY-MM-DD'));
if (!values.contractorId && contractors?.length) setFieldValue('contractorId', contractors[0]._id);
return (
<Form id="form">
+ <Input name="date" type="date" label="Дата" required />
<div className="grid grid-cols-2">
<Select
+ name="accountId"
+ label="Счёт"
+ options={accounts?.map(mapper)}
+ required
+ />
+ <Select
name="contractorId"
label="Контрагент"
options={contractors?.map(mapper)}
required
/>
- <Input name="date" type="date" label="Дата" required />
</div>
<div className="grid grid-cols-2">
<Select
diff --git a/src/services/types.ts b/src/services/types.ts
index 6fa5f30..228bc4d 100644
--- a/src/services/types.ts
+++ b/src/services/types.ts
@@ -7,6 +7,7 @@ interface BaseModel {
export interface Account extends BaseModel {
name: string;
code: string;
+ currency: string;
balance: number;
}