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

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