import React, { useMemo } from 'react'; import { FormGroup, Intent, InputGroup, RadioGroup, Classes, Radio, Position, } from '@blueprintjs/core'; import { FormattedMessage as T } from 'react-intl'; import { ErrorMessage, FastField } from 'formik'; import { CategoriesSelectList, Hint, Col, Row, FieldRequiredHint, } from 'components'; import classNames from 'classnames'; import { CLASSES } from 'common/classes'; import withItemCategories from 'containers/Items/withItemCategories'; import withAccounts from 'containers/Accounts/withAccounts'; import { compose, handleStringChange, inputIntent } from 'utils'; /** * Item form primary section. */ function ItemFormPrimarySection({ // #withItemCategories categoriesList, }) { const itemTypeHintContent = ( <>
{'Service: '} {'Services that you provide to customers. '}
{'Inventory: '} {'Products you buy and/or sell and that you track quantities of.'}
{'Non-Inventory: '} { 'Products you buy and/or sell but don’t need to (or can’t) track quantities of, for example, nuts and bolts used in an installation.' }
); return (
{/*----------- Item type ----------*/} {({ form, field: { value }, meta: { touched, error } }) => ( } labelInfo={ } className={'form-group--item-type'} intent={inputIntent({ error, touched })} helperText={} inline={true} > { form.setFieldValue('type', _value); })} selectedValue={value} > } value="service" /> } value="inventory" /> } value="non-inventory" /> )} {/*----------- Item name ----------*/} {({ field, meta: { error, touched } }) => ( } labelInfo={} className={'form-group--item-name'} intent={inputIntent({ error, touched })} helperText={} inline={true} > )} {/*----------- SKU ----------*/} {({ field, meta: { error, touched } }) => ( } labelInfo={} className={' -group--item-sku'} intent={inputIntent({ error, touched })} helperText={} inline={true} > )} {/*----------- Item category ----------*/} {({ form, field: { value }, meta: { error, touched } }) => ( } inline={true} intent={inputIntent({ error, touched })} helperText={} className={classNames( 'form-group--select-list', 'form-group--category', Classes.FILL, )} > { form.setFieldValue('category_id', category.id); }} popoverProps={{ minimal: true }} /> )} {/* */}
); } export default compose( withAccounts(({ accountsList }) => ({ accountsList, })), withItemCategories(({ categoriesList }) => ({ categoriesList, })), )(ItemFormPrimarySection);