Merge branch 'feature/react-query' of https://github.com/abouolia/Bigcapital into feature/react-query

This commit is contained in:
elforjani3
2021-02-08 19:03:27 +02:00
6 changed files with 72 additions and 15 deletions

View File

@@ -94,8 +94,10 @@ function ItemForm({
);
// Transform API errors.
const transformApiErrors = (errors) => {
const transformApiErrors = (error) => {
const { response: { data: { errors } } } = error;
const fields = {};
if (errors.find((e) => e.type === 'ITEM.NAME.ALREADY.EXISTS')) {
fields.name = formatMessage({ id: 'the_name_used_before' });
}

View File

@@ -1,6 +1,12 @@
import React from 'react';
import { FastField, Field, ErrorMessage } from 'formik';
import { FormGroup, Classes, Checkbox, ControlGroup } from '@blueprintjs/core';
import {
FormGroup,
Classes,
TextArea,
Checkbox,
ControlGroup,
} from '@blueprintjs/core';
import {
AccountsSelectList,
MoneyInputGroup,
@@ -100,6 +106,25 @@ function ItemFormBody({ baseCurrency }) {
</FormGroup>
)}
</FastField>
<FastField name={'sell_description'}>
{({ form: { values }, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'description'} />}
className={'form-group--sell-description'}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'description'} />}
inline={true}
>
<TextArea
growVertically={true}
height={280}
{...field}
disabled={!values.sellable}
/>
</FormGroup>
)}
</FastField>
</Col>
<Col xs={6}>
@@ -174,6 +199,25 @@ function ItemFormBody({ baseCurrency }) {
</FormGroup>
)}
</FastField>
<FastField name={'purchase_description'}>
{({ form: { values }, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'description'} />}
className={'form-group--purchase-description'}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'description'} />}
inline={true}
>
<TextArea
growVertically={true}
height={280}
{...field}
disabled={!values.purchasable}
/>
</FormGroup>
)}
</FastField>
</Col>
</Row>
</div>