mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
29 lines
992 B
TypeScript
29 lines
992 B
TypeScript
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||
|
import { adminRoutes } from './adminRoutes';
|
||
|
import { useInstanceStatus } from 'hooks/api/getters/useInstanceStatus/useInstanceStatus';
|
||
|
import { filterAdminRoutes } from './filterAdminRoutes';
|
||
|
import { filterByConfig, mapRouteLink } from 'component/common/util';
|
||
|
|
||
|
export const useAdminRoutes = () => {
|
||
|
const { uiConfig, isPro, isEnterprise } = useUiConfig();
|
||
|
const { isBilling } = useInstanceStatus();
|
||
|
const showEnterpriseOptionsInPro = Boolean(
|
||
|
uiConfig?.flags?.frontendNavigationUpdate
|
||
|
);
|
||
|
|
||
|
return adminRoutes
|
||
|
.filter(filterByConfig(uiConfig))
|
||
|
.filter(route =>
|
||
|
filterAdminRoutes(
|
||
|
route?.menu,
|
||
|
{
|
||
|
enterprise: isEnterprise(),
|
||
|
pro: isPro(),
|
||
|
billing: isBilling,
|
||
|
},
|
||
|
showEnterpriseOptionsInPro
|
||
|
)
|
||
|
)
|
||
|
.map(mapRouteLink);
|
||
|
};
|