63 lines
3.8 KiB
TypeScript
63 lines
3.8 KiB
TypeScript
import type { RouteObject } from 'react-router-dom';
|
|
import AssessmentIcon from '@mui/icons-material/Assessment';
|
|
import BarChartIcon from '@mui/icons-material/BarChart';
|
|
import DashboardIcon from '@mui/icons-material/Dashboard';
|
|
import PieChartIcon from '@mui/icons-material/PieChart';
|
|
import ScaleIcon from '@mui/icons-material/Scale';
|
|
import TableChartIcon from '@mui/icons-material/TableChart';
|
|
import UploadFileIcon from '@mui/icons-material/UploadFile';
|
|
import type { MenuItem } from '@/shell/types';
|
|
import {
|
|
DashboardPage, DetailsPage, DistributionPage, FrequencyPage, MotMultiTripsPage, NumOfTripsPage, PhoneApprovalsPage,
|
|
QuotaPage, TableReportPage, WeighbridgeFilesPage,
|
|
} from './pages';
|
|
import { tableReports } from './meta';
|
|
import strings from './strings';
|
|
import orderStrings from '../grains-orders/strings';
|
|
|
|
const B = '/grains/reports';
|
|
|
|
export const routes: RouteObject[] = [
|
|
{ path: `${B}/dashboard`, element: <DashboardPage /> },
|
|
{ path: `${B}/trips/num-of-trips`, element: <NumOfTripsPage /> },
|
|
{ path: `${B}/trips/quota`, element: <QuotaPage /> },
|
|
{ path: `${B}/trips/frequency`, element: <FrequencyPage /> },
|
|
{ path: `${B}/trips/distribution`, element: <DistributionPage /> },
|
|
{ path: `${B}/trips/details`, element: <DetailsPage /> },
|
|
{ path: `${B}/mot/multi-trips`, element: <MotMultiTripsPage /> },
|
|
{ path: `${B}/t/:key`, element: <TableReportPage /> },
|
|
{ path: `${B}/imports/phone-approvals`, element: <PhoneApprovalsPage /> },
|
|
{ path: `${B}/imports/weighbridge-files`, element: <WeighbridgeFilesPage /> },
|
|
];
|
|
|
|
const table = (key: string, icon: MenuItem['icon'] = TableChartIcon): MenuItem => ({
|
|
key: `grains.reports.t.${key}`, title: strings[tableReports[key]!.titleKey], icon, path: `${B}/t/${key}`,
|
|
});
|
|
|
|
export const menu: MenuItem[] = [
|
|
{
|
|
// One flat group: every report is a direct entry (no sub menus). Each entry is shown by its own permission key.
|
|
key: 'grains.reports',
|
|
title: strings['rpt.menu.group'],
|
|
icon: AssessmentIcon,
|
|
children: [
|
|
{ key: 'grains.reports.dashboard', title: strings['rpt.menu.dashboard'], icon: DashboardIcon, path: `${B}/dashboard` },
|
|
{ key: 'grains.reports.numOfTrips', title: strings['rpt.menu.numOfTrips'], icon: BarChartIcon, path: `${B}/trips/num-of-trips` },
|
|
{ key: 'grains.reports.quota', title: strings['rpt.menu.quota'], icon: PieChartIcon, path: `${B}/trips/quota` },
|
|
{ key: 'grains.reports.frequency', title: strings['rpt.menu.frequency'], icon: BarChartIcon, path: `${B}/trips/frequency` },
|
|
{ key: 'grains.reports.distribution', title: strings['rpt.menu.distribution'], icon: PieChartIcon, path: `${B}/trips/distribution` },
|
|
{ key: 'grains.reports.details', title: strings['rpt.menu.details'], icon: TableChartIcon, path: `${B}/trips/details` },
|
|
table('weighbridge-events', ScaleIcon), table('waybridge-summary', ScaleIcon), table('waybridge-details', ScaleIcon),
|
|
table('loading-weights', ScaleIcon), table('closed-permits'), table('incapability'),
|
|
{ key: 'grains.orders.reportOrders', title: orderStrings['ord.orders.reportTitle'], icon: PieChartIcon, path: '/grains/orders/reports/tender-orders' },
|
|
table('tender-order'), table('distribution-summary'), table('order-distribution'), table('call-list'),
|
|
table('companies-turn'), table('owners-turn'),
|
|
table('drivers'), table('trucks'),
|
|
{ key: 'grains.reports.motMulti', title: strings['rpt.menu.motMulti'], icon: BarChartIcon, path: `${B}/mot/multi-trips` },
|
|
table('mot-grain-cube'), table('mot-grain-frequency'),
|
|
{ key: 'grains.reports.phoneApprovals', title: strings['rpt.menu.phoneApprovals'], icon: UploadFileIcon, path: `${B}/imports/phone-approvals` },
|
|
{ key: 'grains.reports.wbFiles', title: strings['rpt.menu.wbFiles'], icon: UploadFileIcon, path: `${B}/imports/weighbridge-files`, roles: ['SU'] },
|
|
],
|
|
},
|
|
];
|