From 395ada36c39d5a003b6e0b81242039cd4e62d571 Mon Sep 17 00:00:00 2001
From: Jorge Reyes <92123185+JorgeArt81@users.noreply.github.com>
Date: Sat, 29 Jun 2024 17:05:53 -0500
Subject: [PATCH] Split the route into segments
---
src/reports/components/ReportsLayout.jsx | 30 ++++++++++++++----------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/reports/components/ReportsLayout.jsx b/src/reports/components/ReportsLayout.jsx
index e067815995..c1be87bb9a 100644
--- a/src/reports/components/ReportsLayout.jsx
+++ b/src/reports/components/ReportsLayout.jsx
@@ -3,24 +3,30 @@ import { Outlet, useLocation } from 'react-router-dom';
import PageLayout from '../../common/components/PageLayout';
import ReportsMenu from './ReportsMenu';
-const reportsPaths = {
- '/reports/combined': ['reportTitle', 'reportCombined'],
- '/reports/route': ['reportTitle', 'reportRoute'],
- '/reports/event': ['reportTitle', 'reportEvents'],
- '/reports/trip': ['reportTitle', 'reportTrips'],
- '/reports/stop': ['reportTitle', 'reportStops'],
- '/reports/summary': ['reportTitle', 'reportSummary'],
- '/reports/chart': ['reportTitle', 'reportChart'],
- '/reports/logs': ['reportTitle', 'statisticsTitle'],
- '/reports/scheduled': ['settingsTitle', 'reportScheduled'],
- '/reports/statistics': ['reportTitle', 'statisticsTitle'],
+const routes = {
+ reports: {
+ combined: ['reportTitle', 'reportCombined'],
+ route: ['reportTitle', 'reportRoute'],
+ event: ['reportTitle', 'reportEvents'],
+ trip: ['reportTitle', 'reportTrips'],
+ stop: ['reportTitle', 'reportStops'],
+ summary: ['reportTitle', 'reportSummary'],
+ chart: ['reportTitle', 'reportChart'],
+ logs: ['reportTitle', 'statisticsTitle'],
+ scheduled: ['settingsTitle', 'reportScheduled'],
+ statistics: ['reportTitle', 'statisticsTitle'],
+ },
};
const ReportsLayout = () => {
const { pathname } = useLocation();
+ const pathSegmets = pathname.split('/').filter((p) => p !== '');
return (
- } breadcrumbs={[...reportsPaths[pathname]]}>
+ }
+ breadcrumbs={[...routes[pathSegmets[0]][pathSegmets[1]]]}
+ >
);