blob: 8e973562e75190cb0d5f8862a435a3605de5f3c6 (
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
|
import React from 'react';
import {
Divider, List, ListItem, ListItemIcon, ListItemText,
} from '@material-ui/core';
import TimelineIcon from '@material-ui/icons/Timeline';
import PauseCircleFilledIcon from '@material-ui/icons/PauseCircleFilled';
import PlayCircleFilledIcon from '@material-ui/icons/PlayCircleFilled';
import NotificationsActiveIcon from '@material-ui/icons/NotificationsActive';
import FormatListBulletedIcon from '@material-ui/icons/FormatListBulleted';
import TrendingUpIcon from '@material-ui/icons/TrendingUp';
import BarChartIcon from '@material-ui/icons/BarChart';
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,
}) => (
<ListItem button key={link} component={Link} to={link} selected={selected}>
<ListItemIcon>{icon}</ListItemIcon>
<ListItemText primary={title} />
</ListItem>
);
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'}
/>
</List>
{admin && (
<>
<Divider />
<List>
<MenuItem
title={t('statisticsTitle')}
link="/reports/statistics"
icon={<BarChartIcon />}
selected={location.pathname === '/reports/statistics'}
/>
</List>
</>
)}
</>
);
};
export default ReportsMenu;
|