|  |  | 
 |  |  | import * as Common from '@/utils/common'; | 
 |  |  | import { useFormContext } from 'react-hook-form'; | 
 |  |  |  | 
 |  |  | const TreeSelectInput = ({ resource, label, source = 'parentId', value, isTranslate = false, ...rest }) => { | 
 |  |  | const TreeSelectInput = ({ resource, required, onChange, label, source = 'parentId', value, isTranslate = false, ...rest }) => { | 
 |  |  |     const translate = useTranslate(); | 
 |  |  |     const { setValue } = useFormContext(); | 
 |  |  |     const form = useFormContext(); | 
 |  |  |     const [filter, setFilter] = React.useState(""); | 
 |  |  |     const [treeData, setTreeData] = React.useState([]); | 
 |  |  |  | 
 |  |  |     const [proxyVal, setProxyVal] = React.useState(''); | 
 |  |  |  | 
 |  |  |     const record = useRecordContext() | 
 |  |  |     const val = value || record[source]; | 
 |  |  |     const val = value || record?.[source]; | 
 |  |  |  | 
 |  |  |     useEffect(() => { | 
 |  |  |         const http = async (resource) => { | 
 |  |  | 
 |  |  |     const handleChange = (event) => { | 
 |  |  |         const val = event.target.value; | 
 |  |  |         setProxyVal(val); | 
 |  |  |         setValue(source, val, { | 
 |  |  |         form?.setValue(source, val, { | 
 |  |  |             shouldValidate: true, | 
 |  |  |             shouldDirty: true, | 
 |  |  |         }); | 
 |  |  |         onChange(event) | 
 |  |  |     }; | 
 |  |  |  | 
 |  |  |     return ( | 
 |  |  |         <FormControl fullWidth> | 
 |  |  |         <FormControl fullWidth required={required}> | 
 |  |  |             <InputLabel>{translate(label)}</InputLabel> | 
 |  |  |             <Select | 
 |  |  |                 value={proxyVal || ''} |