Добавлена проверка на некорректно выбранную скважину

This commit is contained in:
goodmice 2022-05-04 15:00:26 +05:00
parent 9d6e5b0687
commit fb82815cbc

View File

@ -54,7 +54,7 @@ const getLabel = (wellsTree: TreeNodeData[], value?: string): string | undefined
break break
default: break default: break
} }
return value return 'Ошибка! Скважина не найдена!'
} }
export const WellTreeSelector = memo(({ ...other }) => { export const WellTreeSelector = memo(({ ...other }) => {
@ -100,14 +100,9 @@ export const WellTreeSelector = memo(({ ...other }) => {
) )
}, []) }, [])
useEffect(() => { useEffect(() => setValue(getLabel(wellsTree, routeMatch?.url)), [wellsTree, routeMatch])
setValue(getLabel(wellsTree, routeMatch?.url))
}, [wellsTree, routeMatch])
const onChange = useCallback((value: string): void => { const onChange = useCallback((value?: string): void => setValue(getLabel(wellsTree, value)), [wellsTree])
if (wellsTree)
setValue(getLabel(wellsTree, value))
}, [wellsTree])
const onSelect = useCallback((value: RawValueType | LabelInValueType): void => { const onSelect = useCallback((value: RawValueType | LabelInValueType): void => {
if (['number', 'string'].includes(typeof value)) if (['number', 'string'].includes(typeof value))