Skip to content

Commit cbb58f5

Browse files
committed
Use GlobalMap component in SurgeMap
- Remove unused code
1 parent 85f95c2 commit cbb58f5

File tree

6 files changed

+15
-68
lines changed

6 files changed

+15
-68
lines changed

app/src/views/CountryNsOverviewActivities/Map/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ function CountryThreeWNationalSocietyProjectsMap(props: Props) {
337337
<div className={_cs(styles.map, className)}>
338338
<div className={styles.mapWithLegend}>
339339
<GlobalMap
340+
// FIXME: We should use CountryMap instead
340341
onAdminZeroFillClick={handleCountryClick}
341342
>
342343
<MapContainerWithDisclaimer

app/src/views/CountryOngoingActivitiesEmergencies/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ export function Component(props: BaseProps) {
519519
contentViewType="vertical"
520520
>
521521
<GlobalMap
522+
// FIXME: We should use CountryMap instead
522523
onAdminZeroFillClick={handleCountryClick}
523524
>
524525
<MapContainerWithDisclaimer

app/src/views/Emergencies/Map/utils.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import type {
22
CircleLayer,
33
CirclePaint,
4-
FillLayer,
54
} from 'mapbox-gl';
65

76
import {
87
COLOR_BLACK,
98
COLOR_BLUE,
10-
COLOR_DARK_GREY,
11-
COLOR_LIGHT_GREY,
129
COLOR_RED,
1310
COLOR_YELLOW,
1411
} from '#utils/constants';
@@ -21,18 +18,6 @@ export const RESPONSE_LEVEL_WITHOUT_IFRC_RESPONSE = 0;
2118
export const RESPONSE_LEVEL_WITH_IFRC_RESPONSE = 1;
2219
export const RESPONSE_LEVEL_MIXED_RESPONSE = 2;
2320

24-
export const adminFillLayerOptions: Omit<FillLayer, 'id'> = {
25-
type: 'fill',
26-
paint: {
27-
'fill-color': [
28-
'case',
29-
['boolean', ['feature-state', 'hovered'], false],
30-
COLOR_DARK_GREY,
31-
COLOR_LIGHT_GREY,
32-
],
33-
},
34-
};
35-
3621
const circleColor: CirclePaint['circle-color'] = [
3722
'match',
3823
['get', 'responseLevel'],

app/src/views/RegionThreeW/MovementActivitiesMap/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function MovementActivitiesMap(props: Props) {
106106
const strings = useTranslation(i18n);
107107
const { regionResponse } = useOutletContext<RegionOutletContext>();
108108

109-
const countryBounds = useMemo(() => (
109+
const regionBounds = useMemo(() => (
110110
regionResponse ? getBbox(regionResponse.bbox) : undefined
111111
), [regionResponse]);
112112

@@ -238,7 +238,7 @@ function MovementActivitiesMap(props: Props) {
238238
<MapBounds
239239
duration={DURATION_MAP_ZOOM}
240240
padding={DEFAULT_MAP_PADDING}
241-
bounds={countryBounds}
241+
bounds={regionBounds}
242242
/>
243243
{/* eslint-disable-next-line max-len */}
244244
{clickedPointProperties?.lngLat && isDefined(clickedPointProperties.countryId) && (

app/src/views/SurgeOverview/SurgeMap/index.tsx

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
MapSource,
2424
} from '@togglecorp/re-map';
2525

26-
import BaseMap from '#components/domain/BaseMap';
26+
import GlobalMap, { type AdminZeroFeatureProperties } from '#components/domain/GlobalMap';
2727
import Link from '#components/Link';
2828
import MapContainerWithDisclaimer from '#components/MapContainerWithDisclaimer';
2929
import MapPopup from '#components/MapPopup';
@@ -32,7 +32,6 @@ import useInputState from '#hooks/useInputState';
3232
import { useRequest } from '#utils/restRequest';
3333

3434
import {
35-
adminFillLayerOptions,
3635
basePointLayerOptions,
3736
getLegendOptions,
3837
getScaleOptions,
@@ -52,24 +51,8 @@ const sourceOptions: mapboxgl.GeoJSONSourceRaw = {
5251
type: 'geojson',
5352
};
5453

55-
interface CountryProperties {
56-
country_id: number;
57-
disputed: boolean;
58-
fdrs: string;
59-
independent: boolean;
60-
is_deprecated: boolean;
61-
iso: string;
62-
iso3: string;
63-
name: string;
64-
name_ar: string;
65-
name_es: string;
66-
name_fr: string;
67-
record_type: number;
68-
region_id: number;
69-
}
70-
7154
interface ClickedPoint {
72-
feature: GeoJSON.Feature<GeoJSON.Point, CountryProperties>;
55+
properties: AdminZeroFeatureProperties;
7356
lngLat: mapboxgl.LngLatLike;
7457
}
7558

@@ -206,7 +189,7 @@ function SurgeMap(props: Props) {
206189
? {
207190
eruDeployedEvents: mapToList(
208191
listToGroupList(
209-
countryGroupedErus[clickedPointProperties.feature.properties.country_id] ?? [],
192+
countryGroupedErus[clickedPointProperties.properties.country_id] ?? [],
210193
(eru) => eru.event.id ?? -1,
211194
),
212195
(eru) => ({
@@ -216,8 +199,7 @@ function SurgeMap(props: Props) {
216199
),
217200
personnelDeployedEvents: mapToList(
218201
listToGroupList(
219-
// eslint-disable-next-line max-len
220-
countryGroupedPersonnel?.[clickedPointProperties.feature.properties.country_id] ?? [],
202+
countryGroupedPersonnel?.[clickedPointProperties.properties.country_id] ?? [],
221203
(personnel) => personnel.event.id,
222204
),
223205
(personnel) => ({
@@ -229,11 +211,11 @@ function SurgeMap(props: Props) {
229211
: undefined;
230212

231213
const handleCountryClick = useCallback((
232-
feature: mapboxgl.MapboxGeoJSONFeature,
214+
properties: AdminZeroFeatureProperties,
233215
lngLat: mapboxgl.LngLatLike,
234216
) => {
235217
setClickedPointProperties({
236-
feature: feature as unknown as ClickedPoint['feature'],
218+
properties,
237219
lngLat,
238220
});
239221
return false;
@@ -250,15 +232,8 @@ function SurgeMap(props: Props) {
250232
<Container
251233
className={_cs(styles.surgeMap, className)}
252234
>
253-
<BaseMap
254-
baseLayers={(
255-
<MapLayer
256-
layerKey="admin-0"
257-
hoverable
258-
layerOptions={adminFillLayerOptions}
259-
onClick={handleCountryClick}
260-
/>
261-
)}
235+
<GlobalMap
236+
onAdminZeroFillClick={handleCountryClick}
262237
>
263238
<MapContainerWithDisclaimer
264239
className={styles.mapContainer}
@@ -316,10 +291,10 @@ function SurgeMap(props: Props) {
316291
<Link
317292
to="countriesLayout"
318293
urlParams={{
319-
countryId: clickedPointProperties.feature.properties.country_id,
294+
countryId: clickedPointProperties.properties.country_id,
320295
}}
321296
>
322-
{clickedPointProperties.feature.properties.name}
297+
{clickedPointProperties.properties.name}
323298
</Link>
324299
)}
325300
childrenContainerClassName={styles.popupContent}
@@ -368,7 +343,7 @@ function SurgeMap(props: Props) {
368343
)}
369344
</MapPopup>
370345
)}
371-
</BaseMap>
346+
</GlobalMap>
372347
</Container>
373348
);
374349
}

app/src/views/SurgeOverview/SurgeMap/utils.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import type {
22
CircleLayer,
33
CirclePaint,
4-
FillLayer,
54
} from 'mapbox-gl';
65

76
import {
87
COLOR_BLACK,
98
COLOR_BLUE,
10-
COLOR_DARK_GREY,
11-
COLOR_LIGHT_GREY,
129
COLOR_RED,
1310
COLOR_YELLOW,
1411
} from '#utils/constants';
@@ -24,18 +21,6 @@ const SURGE_TYPE_ERU = 0;
2421
const SURGE_TYPE_PERSONNEL = 1;
2522
const SURGE_TYPE_ERU_AND_PERSONNEL = 2;
2623

27-
export const adminFillLayerOptions: Omit<FillLayer, 'id'> = {
28-
type: 'fill',
29-
paint: {
30-
'fill-color': [
31-
'case',
32-
['boolean', ['feature-state', 'hovered'], false],
33-
COLOR_DARK_GREY,
34-
COLOR_LIGHT_GREY,
35-
],
36-
},
37-
};
38-
3924
export function getLegendOptions(strings: i18nType['strings']) {
4025
const legendOptions = [
4126
{

0 commit comments

Comments
 (0)