|
1 | 1 | import { |
2 | 2 | useCallback, |
| 3 | + useContext, |
3 | 4 | useMemo, |
4 | 5 | useState, |
5 | 6 | } from 'react'; |
6 | | -import { useOutletContext } from 'react-router-dom'; |
| 7 | +import { |
| 8 | + generatePath, |
| 9 | + Navigate, |
| 10 | + useOutletContext, |
| 11 | +} from 'react-router-dom'; |
7 | 12 | import { |
8 | 13 | ArtboardLineIcon, |
9 | 14 | PencilFillIcon, |
@@ -67,6 +72,7 @@ import MapContainerWithDisclaimer from '#components/MapContainerWithDisclaimer'; |
67 | 72 | import MapPopup from '#components/MapPopup'; |
68 | 73 | import WikiLink from '#components/WikiLink'; |
69 | 74 | import { adminUrl } from '#config'; |
| 75 | +import RouteContext from '#contexts/route'; |
70 | 76 | import useAuth from '#hooks/domain/useAuth'; |
71 | 77 | import useCountryRaw from '#hooks/domain/useCountryRaw'; |
72 | 78 | import usePermissions from '#hooks/domain/usePermissions'; |
@@ -123,14 +129,14 @@ export function Component(props: BaseProps) { |
123 | 129 | onPresentationModeButtonClick, |
124 | 130 | presentationMode = false, |
125 | 131 | } = props; |
| 132 | + const { countryOngoingActivitiesEmergencies } = useContext(RouteContext); |
126 | 133 |
|
127 | 134 | const strings = useTranslation(i18n); |
128 | 135 | const { isAuthenticated } = useAuth(); |
129 | 136 | const { isGuestUser } = usePermissions(); |
130 | 137 |
|
131 | 138 | const { |
132 | 139 | countryId, |
133 | | - // Note: countryResponse is used only for bounds |
134 | 140 | countryResponse, |
135 | 141 | } = useOutletContext<CountryOutletContext>(); |
136 | 142 | const countryRawResponse = useCountryRaw(); |
@@ -443,6 +449,21 @@ export function Component(props: BaseProps) { |
443 | 449 | ? countryGroupedAppeal[clickedPointProperties.properties.iso3] |
444 | 450 | : undefined; |
445 | 451 |
|
| 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 | + |
446 | 467 | return ( |
447 | 468 | <Container |
448 | 469 | className={styles.countryOngoingActivities} |
|
0 commit comments