| | |
| | | } from '../constants'; |
| | | import { useNotification } from '../Notification'; |
| | | |
| | | export const getFormDefaultValues = (data) => ({ |
| | | 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 } = useForm({ |
| | | defaultValues: { |
| | | ...sprite.data, |
| | | }, |
| | | defaultValues: getFormDefaultValues(sprite?.data), |
| | | }); |
| | | |
| | | useEffect(() => { |
| | | if (sprite?.data) { |
| | | reset(getFormDefaultValues(sprite.data)); |
| | | } |
| | | }, [sprite, reset]); |
| | | |
| | | const rowValue = watch('row'); |
| | | const bayValue = watch('bay'); |
| | | |