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