| | |
| | | const deviceType = sprite?.data?.type; |
| | | const incrementOptions = incrementOptionsMap[deviceType] |
| | | |
| | | const { control, handleSubmit, reset, watch, setValue } = useForm({ |
| | | const { control, handleSubmit, reset, watch, setValue, formState: { errors } } = useForm({ |
| | | defaultValues: getDefaultFormValues(value), |
| | | }); |
| | | |
| | |
| | | onCancel(); |
| | | } |
| | | |
| | | const validateIncrement = (value) => { |
| | | if (!value) { |
| | | return true; |
| | | } |
| | | if (deviceType === DEVICE_TYPE.SHELF) { |
| | | if (!sprite?.data?.row || !sprite?.data?.bay) { |
| | | return 'Row or Bay value is required for SHELF device type.'; |
| | | } |
| | | } |
| | | return true; |
| | | }; |
| | | |
| | | const onFormSubmit = (data) => { |
| | | if (data) { |
| | | console.log(data); |
| | | } |
| | | if (handleOnCopy) { |
| | | handleOnCopy(data); |
| | | } |
| | | handleOnCopy?.(data); |
| | | notify.info(translate('common.response.success')); |
| | | }; |
| | | |
| | |
| | | <Controller |
| | | name="autoIncrement" |
| | | control={control} |
| | | rules={{ validate: validateIncrement }} |
| | | render={({ field }) => ( |
| | | <FormControlLabel |
| | | control={ |
| | |
| | | /> |
| | | )} |
| | | /> |
| | | {errors.autoIncrement && ( |
| | | <Typography color="error"> |
| | | {errors.autoIncrement.message} |
| | | </Typography> |
| | | )} |
| | | </Grid> |
| | | |
| | | {(!!incrementOptions?.length && autoIncrement) && ( |