blob: dc0da4b99a56a508adbb225f20f6db83317b6b5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
import React from 'react';
import {
Divider, List, ListItemButton, ListItemIcon, ListItemText,
} from '@mui/material';
import TimelineIcon from '@mui/icons-material/Timeline';
import PauseCircleFilledIcon from '@mui/icons-material/PauseCircleFilled';
import PlayCircleFilledIcon from '@mui/icons-material/PlayCircleFilled';
import NotificationsActiveIcon from '@mui/icons-material/NotificationsActive';
import FormatListBulletedIcon from '@mui/icons-material/FormatListBulleted';
import TrendingUpIcon from '@mui/icons-material/TrendingUp';
import BarChartIcon from '@mui/icons-material/BarChart';
import RouteIcon from '@mui/icons-material/Route';
import { Link, useLocation } from 'react-router-dom';
import { useTranslation } from '../../common/components/LocalizationProvider';
import { useAdministrator } from '../../common/util/permissions';
const MenuItem = ({
title, link, icon, selected,
}) => (
<ListItemButton button key={link} component={Link} to={link} selected={selected}>
<ListItemIcon>{icon}</ListItemIcon>
<ListItemText primary={title} />
</ListItemButton>
);
const ReportsMenu = () => {
const t = useTranslation();
const location = useLocation();
const admin = useAdministrator();
return (
<>
<List>
<MenuItem
title={t('reportRoute')}
link="/reports/route"
icon={<TimelineIcon />}
selected={location.pathname === '/reports/route'}
/>
<MenuItem
title={t('reportEvents')}
link="/reports/event"
icon={<NotificationsActiveIcon />}
selected={location.pathname === '/reports/event'}
/>
<MenuItem
title={t('reportTrips')}
link="/reports/trip"
icon={<PlayCircleFilledIcon />}
selected={location.pathname === '/reports/trip'}
/>
<MenuItem
title={t('reportStops')}
link="/reports/stop"
icon={<PauseCircleFilledIcon />}
selected={location.pathname === '/reports/stop'}
/>
<MenuItem
title={t('reportSummary')}
link="/reports/summary"
icon={<FormatListBulletedIcon />}
selected={location.pathname === '/reports/summary'}
/>
<MenuItem
title={t('reportChart')}
link="/reports/chart"
icon={<TrendingUpIcon />}
selected={location.pathname === '/reports/chart'}
/>
<MenuItem
title={t('reportReplay')}
link="/replay"
icon={<RouteIcon />}
/>
</List>
{admin && (
<>
<Divider />
<List>
<MenuItem
title={t('statisticsTitle')}
link="/reports/statistics"
icon={<BarChartIcon />}
selected={location.pathname === '/reports/statistics'}
/>
</List>
</>
)}
</>
);
};
export default ReportsMenu;
|