| | |
| | | import React from 'react'; |
| | | import React, { useEffect } from 'react'; |
| | | import { useTranslate } from "react-admin"; |
| | | import { useForm, Controller } from 'react-hook-form'; |
| | | import { |
| | |
| | | const theme = useTheme(); |
| | | const translate = useTranslate(); |
| | | |
| | | const { control, handleSubmit, reset, watch } = useForm({ |
| | | const { control, handleSubmit, reset, watch, setValue } = useForm({ |
| | | defaultValues: { |
| | | taskMode: 'MOVE', |
| | | startCode: '', |
| | |
| | | { value: 'STA_TO_LOC', label: translate('page.map.insight.control.type.STA_TO_LOC') }, |
| | | { value: 'STA_TO_STA', label: translate('page.map.insight.control.type.STA_TO_STA') }, |
| | | ]; |
| | | |
| | | useEffect(() => { |
| | | reset(); |
| | | }, [curAgvNo, reset]); |
| | | |
| | | const onSubmit = (data) => { |
| | | if (curAgvNo) { |
| | |
| | | setInputValue: setEndStaInputValue, |
| | | } = useCoolHook('/sta/page', 'staNo'); |
| | | |
| | | useEffect(() => { |
| | | const fieldsToClear = ['startCode', 'endCode', 'startLocNo', 'endLocNo', 'startStaNo', 'endStaNo']; |
| | | |
| | | fieldsToClear.forEach(field => { |
| | | if (!showField(field)) { |
| | | setValue(field, ''); |
| | | } |
| | | }); |
| | | }, [taskMode, setValue, showField]); |
| | | |
| | | return ( |
| | | <> |