sbt-idp/cope2n-fe/src/components/left-menu/index.tsx

69 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-02-16 11:09:15 +00:00
import { AppstoreOutlined, BarChartOutlined, RotateRightOutlined, FileSearchOutlined } from '@ant-design/icons';
2024-01-31 04:08:20 +00:00
import { t } from '@lingui/macro';
import { Menu, MenuProps } from 'antd';
import React from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
type MenuItem = Required<MenuProps>['items'][number];
function useGetMenuItem() {
const navigate = useNavigate();
return function getItem(
label: React.ReactNode,
key: React.Key,
icon?: React.ReactNode,
children?: MenuItem[],
type?: 'group',
): MenuItem {
return {
key,
icon,
children,
label,
type,
onClick({ key: clickedKey }) {
navigate(clickedKey);
},
} as MenuItem;
};
}
function LeftMenu() {
const location = useLocation();
const getItem = useGetMenuItem();
const generalSubItems = [
getItem(t`Dashboard`, '/dashboard', <AppstoreOutlined />),
getItem(t`Reports`, '/reports', <BarChartOutlined />),
2024-02-19 04:02:21 +00:00
// getItem(t`Review`, '/reviews', <FileSearchOutlined />),
2024-02-01 10:07:38 +00:00
getItem(t`Inference`, '/inference', <RotateRightOutlined />),
2024-01-31 09:54:39 +00:00
// getItem(t`Users`, '/users', <UsergroupAddOutlined />),
2024-01-31 04:08:20 +00:00
];
return (
<div
style={{
display: 'flex',
flexDirection: 'column',
height: '100%',
}}
>
2024-02-06 06:45:12 +00:00
<div style={{
padding: '16px 8px 8px 8px',
fontWeight: 600,
color: '#555',
}}>
Menu
</div>
2024-01-31 04:08:20 +00:00
<Menu
mode='vertical'
selectedKeys={[location.pathname]}
style={{ borderRight: 'none' }}
items={generalSubItems}
/>
</div>
);
}
export default React.memo(LeftMenu);