This commit is contained in:
elforjani13
2022-04-03 19:42:11 +02:00
parent dbf4666dfc
commit c49a240280
2 changed files with 38 additions and 6 deletions

View File

@@ -50,7 +50,7 @@ export default function ItemFormFormik({
// Handles the form submit. // Handles the form submit.
const handleFormSubmit = (values, form) => { const handleFormSubmit = (values, form) => {
const { setSubmitting, resetForm, setErrors } = form; const { setSubmitting, resetForm, setErrors } = form;
const formValues = { ...values }; const formValues = { ...values, type: values.type.toString() };
setSubmitting(true); setSubmitting(true);

View File

@@ -7,7 +7,12 @@ import {
Radio, Radio,
Position, Position,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { FormattedMessage as T, FormattedHTMLMessage } from 'components'; import {
FormattedMessage as T,
FormattedHTMLMessage,
FCheckbox,
FFormGroup,
} from 'components';
import { ErrorMessage, FastField } from 'formik'; import { ErrorMessage, FastField } from 'formik';
import { import {
CategoriesSelectList, CategoriesSelectList,
@@ -29,7 +34,7 @@ import { categoriesFieldShouldUpdate } from './utils';
export default function ItemFormPrimarySection() { export default function ItemFormPrimarySection() {
// Item form context. // Item form context.
const { isNewMode, item, itemsCategories } = useItemFormContext(); const { isNewMode, item, itemsCategories } = useItemFormContext();
console.log(item.type, 'XXX');
const nameFieldRef = useRef(null); const nameFieldRef = useRef(null);
useEffect(() => { useEffect(() => {
@@ -53,7 +58,34 @@ export default function ItemFormPrimarySection() {
return ( return (
<div className={classNames(CLASSES.PAGE_FORM_HEADER_PRIMARY)}> <div className={classNames(CLASSES.PAGE_FORM_HEADER_PRIMARY)}>
{/*----------- Item type ----------*/} {/*----------- Item type ----------*/}
<FastField name={'type'}> <FFormGroup
name={'type'}
label={<T id={'item_type'} />}
labelInfo={
<span>
<FieldRequiredHint />
<Hint
content={itemTypeHintContent}
position={Position.BOTTOM_LEFT}
/>
</span>
}
inline={true}
>
<FCheckbox
inline={true}
name="type"
label={<T id={'service'} />}
value="service"
/>
<FCheckbox
inline={true}
name="type"
label={<T id={'inventory'} />}
value="inventory"
/>
</FFormGroup>
{/* <FastField name={'type'}>
{({ form, field: { value }, meta: { touched, error } }) => ( {({ form, field: { value }, meta: { touched, error } }) => (
<FormGroup <FormGroup
medium={true} medium={true}
@@ -85,7 +117,7 @@ export default function ItemFormPrimarySection() {
</RadioGroup> </RadioGroup>
</FormGroup> </FormGroup>
)} )}
</FastField> </FastField> */}
<Row> <Row>
<Col xs={7}> <Col xs={7}>