Skip to content

Commit 03f2293

Browse files
committed
Redirect obsolete URL-s
1 parent 32b26e6 commit 03f2293

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

app/src/App/routes/SurgeRoutes.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,23 @@ const deploymentCatalogueChildren = customWrapRoute({
14431443
},
14441444
});
14451445

1446+
const obsoleteUrlDeployments = customWrapRoute({
1447+
parent: rootLayout,
1448+
path: 'deployments',
1449+
component: {
1450+
eagerLoad: true,
1451+
render: Navigate,
1452+
props: {
1453+
to: surgeOverview.absolutePath,
1454+
},
1455+
},
1456+
wrapperComponent: Auth,
1457+
context: {
1458+
title: 'Surge Overview',
1459+
visibility: 'anything',
1460+
},
1461+
});
1462+
14461463
export default {
14471464
surgeLayout,
14481465
surgeOverview,
@@ -1537,4 +1554,5 @@ export default {
15371554
deploymentCatalogueIndex,
15381555
deploymentCatalogueChildren,
15391556
deploymentOthers,
1557+
obsoleteUrlDeployments,
15401558
};

app/src/App/routes/index.tsx

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { Navigate } from 'react-router-dom';
1+
import {
2+
Navigate,
3+
useParams,
4+
} from 'react-router-dom';
25

36
import { unwrapRoute } from '#utils/routes';
47

@@ -1187,6 +1190,38 @@ const preparednessOperationalLearning = customWrapRoute({
11871190
},
11881191
});
11891192

1193+
// eslint-disable-next-line
1194+
function ObsoleteFieldReportRedirection() {
1195+
const params = useParams<{
1196+
fieldReportId: string,
1197+
}>();
1198+
1199+
// eslint-disable-next-line
1200+
const to = '/field-reports/' + params.fieldReportId;
1201+
1202+
return (
1203+
<Navigate
1204+
to={to}
1205+
replace
1206+
/>
1207+
);
1208+
}
1209+
1210+
const obsoleteFieldReportDetails = customWrapRoute({
1211+
parent: rootLayout,
1212+
path: 'reports/:fieldReportId',
1213+
component: {
1214+
eagerLoad: true,
1215+
render: ObsoleteFieldReportRedirection,
1216+
props: {},
1217+
},
1218+
wrapperComponent: Auth,
1219+
context: {
1220+
title: 'Field Report Details',
1221+
visibility: 'anything',
1222+
},
1223+
});
1224+
11901225
const wrappedRoutes = {
11911226
fourHundredFour,
11921227
rootLayout,
@@ -1273,6 +1308,7 @@ const wrappedRoutes = {
12731308

12741309
// Redirects
12751310
preparednessOperationalLearning,
1311+
obsoleteFieldReportDetails,
12761312
};
12771313

12781314
export const unwrappedRoutes = unwrapRoute(Object.values(wrappedRoutes));

0 commit comments

Comments
 (0)