import React from 'react';
import { FastField, ErrorMessage } from 'formik';
import {
FormGroup,
Intent,
Classes,
Checkbox,
} from '@blueprintjs/core';
import {
AccountsSelectList,
MoneyInputGroup,
Col,
Row,
Hint,
} from 'components';
import { FormattedMessage as T } from 'react-intl';
import classNames from 'classnames';
import withAccounts from 'containers/Accounts/withAccounts';
import { compose, inputIntent } from 'utils';
/**
* Item form body.
*/
function ItemFormBody({ accountsList }) {
return (
{/*------------- Purchasable checbox ------------- */}
{({ field, field: { value } }) => (
}
defaultChecked={value}
{...field}
/>
)}
{/*------------- Selling price ------------- */}
{({ form, field, field: { value }, meta: { error, touched } }) => (
}
className={'form-group--sell_price'}
intent={inputIntent({ error, touched })}
helperText={}
inline={true}
>
)}
{/*------------- Selling account ------------- */}
{({ form, field: { value }, meta: { error, touched } }) => (
}
labelInfo={}
inline={true}
intent={inputIntent({ error, touched })}
helperText={}
className={classNames(
'form-group--sell-account',
'form-group--select-list',
Classes.FILL,
)}
>
{
form.setFieldValue('sell_account_id', account.id);
}}
defaultSelectText={}
selectedAccountId={value}
disabled={!form.values.sellable}
filterByTypes={['income']}
/>
)}
{/*------------- Sellable checkbox ------------- */}
{({ field, field: { value }, meta: { error, touched } }) => (
}
checked={value}
{...field}
/>
)}
{/*------------- Cost price ------------- */}
{({ field, form, field: { value }, meta: { error, touched } }) => (
}
className={'form-group--item-cost-price'}
intent={inputIntent({ error, touched })}
helperText={}
inline={true}
>
)}
{/*------------- Cost account ------------- */}
{({ form, field: { value }, meta: { error, touched } }) => (
}
labelInfo={}
inline={true}
intent={inputIntent({ error, touched })}
helperText={}
className={classNames(
'form-group--cost-account',
'form-group--select-list',
Classes.FILL,
)}
>
{
form.setFieldValue('cost_account_id', account.id);
}}
defaultSelectText={}
selectedAccountId={value}
disabled={!form.values.purchasable}
filterByTypes={['cost_of_goods_sold']}
/>
)}
);
}
export default compose(
withAccounts(({ accountsList }) => ({
accountsList,
})),
)(ItemFormBody);