| | |
| | | } from '../constants'; |
| | | import { useNotification } from '../Notification'; |
| | | |
| | | export const getFormDefaultValues = (data) => { |
| | | return { |
| | | row: data?.row ?? '', |
| | | bay: data?.bay ?? '', |
| | | no: data?.no ?? '', |
| | | ...data, |
| | | } |
| | | }; |
| | | |
| | | const ConfigSettings = (props) => { |
| | | const { sprite, onSubmit } = props; |
| | | const notify = useNotification(); |
| | | const translate = useTranslate(); |
| | | |
| | | const { control, handleSubmit, reset, watch, setValue, unregister } = useForm({ |
| | | defaultValues: getFormDefaultValues(sprite?.data), |
| | | shouldUnregister: true, |
| | | const { control, handleSubmit, reset, watch, setValue } = useForm({ |
| | | defaultValues: { ...sprite?.data }, |
| | | }); |
| | | |
| | | useEffect(() => { |
| | | if (sprite?.data) { |
| | | reset(getFormDefaultValues(sprite.data)); |
| | | reset({ |
| | | ...sprite.data |
| | | }); |
| | | } |
| | | }, [sprite, reset]); |
| | | |
| | |
| | | |
| | | const rowValue = watch('row'); |
| | | const bayValue = watch('bay'); |
| | | |
| | | useEffect(() => { |
| | | if (deviceType !== DEVICE_TYPE.SHELF) { |
| | | unregister('row'); |
| | | unregister('bay'); |
| | | } |
| | | }, [deviceType, unregister]); |
| | | |
| | | useEffect(() => { |
| | | if (deviceType === DEVICE_TYPE.SHELF) { |
| | |
| | | <Divider /> |
| | | </Grid> |
| | | |
| | | {/* <Grid item xs={12}> |
| | | <Typography variant="inherit"> |
| | | {translate('page.map.settings.config.base.no')} |
| | | </Typography> |
| | | </Grid> */} |
| | | <Grid item xs={6}> |
| | | <Controller |
| | | name="no" |