forked from ddrilling/asb_cloud_front
Убран сброс пути при выборе месторождения/куста/скважины
This commit is contained in:
parent
836bcd583d
commit
61d71899db
@ -99,6 +99,8 @@ export const WellTreeSelector = memo<WellTreeSelectorProps>(({ show, expand, cur
|
|||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
|
|
||||||
|
console.log(location.pathname)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (current) setSelected([current])
|
if (current) setSelected([current])
|
||||||
}, [current])
|
}, [current])
|
||||||
@ -156,7 +158,17 @@ export const WellTreeSelector = memo<WellTreeSelectorProps>(({ show, expand, cur
|
|||||||
}, [wellsTree])
|
}, [wellsTree])
|
||||||
|
|
||||||
const onSelect = useCallback((value: Key[]): void => {
|
const onSelect = useCallback((value: Key[]): void => {
|
||||||
navigate(String(value), { state: { from: location.pathname }})
|
const newRoot = /\/(\w+)\/(\d+)/.exec(String(value))
|
||||||
|
const oldRoot = /\/(\w+)\/(\d+)/.exec(location.pathname)
|
||||||
|
if (!newRoot || !oldRoot) return
|
||||||
|
|
||||||
|
let newPath = newRoot[0]
|
||||||
|
if (oldRoot[1] === newRoot[1]) { /// Если типы страниц одинаковые (deposit, cluster, well)
|
||||||
|
const url = location.pathname.substring(oldRoot[0].length)
|
||||||
|
newPath = newPath + url
|
||||||
|
}
|
||||||
|
|
||||||
|
navigate(newPath, { state: { from: location.pathname }})
|
||||||
}, [navigate, location])
|
}, [navigate, location])
|
||||||
|
|
||||||
useEffect(() => onChange(location.pathname), [onChange, location])
|
useEffect(() => onChange(location.pathname), [onChange, location])
|
||||||
|
Loading…
Reference in New Issue
Block a user