fix(dashboard): settings navigation loop (#7412)
* fix: settings navigation loop * fix comment
This commit is contained in:
committed by
GitHub
parent
6f1b90f207
commit
ccf335fcf4
@@ -80,6 +80,18 @@ const useDeveloperRoutes = (): NavItemProps[] => {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the `from` prop is not another settings route, to avoid
|
||||
* the user getting stuck in a navigation loop.
|
||||
*/
|
||||
const getSafeFromValue = (from: string) => {
|
||||
if (from.startsWith("/settings")) {
|
||||
return "/orders"
|
||||
}
|
||||
|
||||
return from
|
||||
}
|
||||
|
||||
const SettingsSidebar = () => {
|
||||
const routes = useSettingRoutes()
|
||||
const developerRoutes = useDeveloperRoutes()
|
||||
@@ -90,7 +102,7 @@ const SettingsSidebar = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (location.state?.from) {
|
||||
setFrom(location.state.from)
|
||||
setFrom(getSafeFromValue(location.state.from))
|
||||
}
|
||||
}, [location])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user