Skip to content

Commit ee1bd60

Browse files
szabozoltan69frozenhelium
authored andcommitted
Non-sovereign country pages redirect
1 parent 64644ae commit ee1bd60

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

.changeset/ten-dodos-sin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"go-web-app": patch
3+
---
4+
5+
Add proper redirect for Non-sovereign country in the country ongoing emergencies page

app/src/views/CountryOngoingActivitiesEmergencies/index.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import {
22
useCallback,
3+
useContext,
34
useMemo,
45
useState,
56
} from 'react';
6-
import { useOutletContext } from 'react-router-dom';
7+
import {
8+
generatePath,
9+
Navigate,
10+
useOutletContext,
11+
} from 'react-router-dom';
712
import {
813
ArtboardLineIcon,
914
PencilFillIcon,
@@ -67,6 +72,7 @@ import MapContainerWithDisclaimer from '#components/MapContainerWithDisclaimer';
6772
import MapPopup from '#components/MapPopup';
6873
import WikiLink from '#components/WikiLink';
6974
import { adminUrl } from '#config';
75+
import RouteContext from '#contexts/route';
7076
import useAuth from '#hooks/domain/useAuth';
7177
import useCountryRaw from '#hooks/domain/useCountryRaw';
7278
import usePermissions from '#hooks/domain/usePermissions';
@@ -123,14 +129,14 @@ export function Component(props: BaseProps) {
123129
onPresentationModeButtonClick,
124130
presentationMode = false,
125131
} = props;
132+
const { countryOngoingActivitiesEmergencies } = useContext(RouteContext);
126133

127134
const strings = useTranslation(i18n);
128135
const { isAuthenticated } = useAuth();
129136
const { isGuestUser } = usePermissions();
130137

131138
const {
132139
countryId,
133-
// Note: countryResponse is used only for bounds
134140
countryResponse,
135141
} = useOutletContext<CountryOutletContext>();
136142
const countryRawResponse = useCountryRaw();
@@ -443,6 +449,21 @@ export function Component(props: BaseProps) {
443449
? countryGroupedAppeal[clickedPointProperties.properties.iso3]
444450
: undefined;
445451

452+
if (countryResponse?.sovereign_state_id && countryResponse?.independent === false) {
453+
const redirectCountryId = countryResponse.sovereign_state_id;
454+
const countryPath = generatePath(
455+
countryOngoingActivitiesEmergencies.absoluteForwardPath,
456+
{ countryId: redirectCountryId },
457+
);
458+
459+
return (
460+
<Navigate
461+
to={countryPath}
462+
replace
463+
/>
464+
);
465+
}
466+
446467
return (
447468
<Container
448469
className={styles.countryOngoingActivities}

0 commit comments

Comments
 (0)