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

76 lines
1.8 KiB
TypeScript
Raw Normal View History

2024-01-31 09:54:39 +00:00
import { AppstoreOutlined, BarChartOutlined } 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 />),
2024-01-31 09:54:39 +00:00
// getItem(t`Inference`, '/inference', <RotateRightOutlined />),
// getItem(t`Reviews`, '/reviews', <FileSearchOutlined />),
2024-01-31 04:08:20 +00:00
getItem(t`Reports`, '/reports', <BarChartOutlined />),
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',
justifyContent: 'space-between',
height: '100%',
}}
>
<Menu
mode='vertical'
selectedKeys={[location.pathname]}
style={{ borderRight: 'none' }}
items={generalSubItems}
/>
2024-01-31 09:54:39 +00:00
{/* <div
2024-01-31 04:08:20 +00:00
style={{
display: 'flex',
alignItems: 'center',
marginLeft: '20px',
marginBottom: '20px',
gap: '10px',
cursor: 'pointer',
}}
>
<QuestionCircleOutlined />
<span>Help</span>
2024-01-31 09:54:39 +00:00
</div> */}
2024-01-31 04:08:20 +00:00
</div>
);
}
export default React.memo(LeftMenu);