Skip to content

Commit bb9f9b7

Browse files
committed
Add redirects for old emergency additional tabs
1 parent 906111d commit bb9f9b7

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

src/App/routes/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ const surgeCatalogueInformationManagementGenevaSupport = customWrapRoute({
12821282
},
12831283
wrapperComponent: Auth,
12841284
context: {
1285-
title: 'Information Management Support- Geneva',
1285+
title: 'Information Management Support - Geneva',
12861286
visibility: 'anything',
12871287
},
12881288
});

src/views/EmergencyAdditionalTab/index.tsx

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
import { useContext } from 'react';
12
import {
3+
Navigate,
4+
generatePath,
5+
useLocation,
26
useOutletContext,
37
useParams,
48
} from 'react-router-dom';
9+
import { isDefined } from '@togglecorp/fujs';
510

611
import { type EmergencyOutletContext } from '#utils/outletContext';
712
import HtmlOutput from '#components/HtmlOutput';
13+
import RouteContext from '#contexts/route';
814

915
import styles from './styles.module.css';
1016

@@ -15,16 +21,39 @@ interface Props {
1521
// eslint-disable-next-line import/prefer-default-export
1622
export function Component(props: Props) {
1723
const urlParams = useParams<{ tabId: string }>();
24+
const location = useLocation();
25+
const routes = useContext(RouteContext);
1826
const { infoPageId } = props;
1927
const { emergencyAdditionalTabs } = useOutletContext<EmergencyOutletContext>();
2028

2129
const additionalTab = emergencyAdditionalTabs?.find(
2230
(tab) => tab.infoPageId === infoPageId
23-
|| urlParams.tabId === tab.tabId,
31+
|| urlParams.tabId === tab.tabId
32+
|| location.hash === `#${tab.tabId}`,
2433
);
2534

35+
if (isDefined(additionalTab) && `#${additionalTab.tabId}` === location.hash) {
36+
const newPath = generatePath(
37+
// eslint-disable-next-line react/destructuring-assignment
38+
routes.emergencyAdditionalInfo.absoluteForwardPath,
39+
{
40+
...urlParams,
41+
tabId: additionalTab.tabId,
42+
},
43+
);
44+
45+
return (
46+
<Navigate
47+
to={newPath}
48+
replace
49+
/>
50+
);
51+
}
52+
2653
return (
27-
<div className={styles.additionalTab}>
54+
<div
55+
className={styles.additionalTab}
56+
>
2857
{additionalTab?.snippets?.map((snippet) => (
2958
<HtmlOutput
3059
key={snippet.id}

0 commit comments

Comments
 (0)