| | |
| | | const notify = useNotification(); |
| | | const translate = useTranslate(); |
| | | |
| | | const { control, handleSubmit, reset, watch, setValue } = useForm({ |
| | | const { control, handleSubmit, reset, watch, setValue, formState: { errors } } = useForm({ |
| | | defaultValues: { ...sprite?.data }, |
| | | }); |
| | | |
| | |
| | | ]); |
| | | |
| | | const onFormSubmit = (data) => { |
| | | if (sprite && sprite.data) { |
| | | if (sprite?.data) { |
| | | Object.keys(data).forEach((key) => { |
| | | sprite.data[key] = data[key]; |
| | | }); |
| | |
| | | if (onSubmit) { |
| | | onSubmit(data); |
| | | } |
| | | console.log(sprite.data); |
| | | notify.info(translate('common.response.success')); |
| | | }; |
| | | |
| | |
| | | <> |
| | | <Box component="form" onSubmit={handleSubmit(onFormSubmit)} noValidate sx={{ mt: 0 }}> |
| | | <Grid container spacing={1.4}> |
| | | |
| | | {deviceType === DEVICE_TYPE.SHELF && ( |
| | | <> |
| | | <Grid item xs={6}> |
| | |
| | | <Controller |
| | | name="no" |
| | | control={control} |
| | | rules={{ |
| | | required: translate('ra.validation.required') // warn msg |
| | | }} |
| | | render={({ field }) => { |
| | | return ( |
| | | <TextField |
| | |
| | | label={translate('page.map.settings.config.base.no')} |
| | | type="text" |
| | | value={field.value ?? ''} |
| | | error={!!errors.no} // show red warn |
| | | helperText={errors.no ? errors.no.message : null} // show warn msg |
| | | fullWidth |
| | | onChange={(e) => { |
| | | field.onChange(e); |