mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-20 00:08:02 +01:00
4167a60588
Follows up on https://github.com/Unleash/unleash/pull/4853 to add Biome to the frontend as well. ![image](https://github.com/Unleash/unleash/assets/14320932/1906faf1-fc29-4172-a4d4-b2716d72cd65) Added a few `biome-ignore` to speed up the process but we may want to check and fix them in the future.
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { PageContent } from 'component/common/PageContent/PageContent';
|
|
import { PageHeader } from 'component/common/PageHeader/PageHeader';
|
|
import { VFC } from 'react';
|
|
import { adminGroups } from './adminRoutes';
|
|
import { INavigationMenuItem } from 'interfaces/route';
|
|
import { Box, Link, Typography } from '@mui/material';
|
|
import { Link as RouterLink } from 'react-router-dom';
|
|
import { useAdminRoutes } from './useAdminRoutes';
|
|
|
|
export const AdminIndex: VFC = () => {
|
|
const adminRoutes = useAdminRoutes();
|
|
|
|
const routeGroups = adminRoutes.reduce(
|
|
(acc, route) => {
|
|
const group = route.group || 'other';
|
|
|
|
const index = acc.findIndex((item) => item.name === group);
|
|
if (index === -1) {
|
|
acc.push({
|
|
name: group,
|
|
description: adminGroups[group] || 'Other',
|
|
items: [route],
|
|
});
|
|
|
|
return acc;
|
|
}
|
|
|
|
acc[index].items.push(route);
|
|
|
|
return acc;
|
|
},
|
|
[] as Array<{
|
|
name: string;
|
|
description: string;
|
|
items: INavigationMenuItem[];
|
|
}>,
|
|
);
|
|
|
|
return (
|
|
<PageContent header={<PageHeader title='Manage Unleash' />}>
|
|
{routeGroups.map((group) => (
|
|
<Box
|
|
key={group.name}
|
|
sx={(theme) => ({ marginBottom: theme.spacing(2) })}
|
|
>
|
|
<Typography variant='h2'>{group.description}</Typography>
|
|
<ul>
|
|
{group.items.map((route) => (
|
|
<li key={route.path}>
|
|
<Link component={RouterLink} to={route.path}>
|
|
{route.title}
|
|
</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</Box>
|
|
))}
|
|
</PageContent>
|
|
);
|
|
};
|