@@ -32,9 +32,8 @@ import {
3232 MapLayer ,
3333 MapSource ,
3434} from '@togglecorp/re-map' ;
35- import type { LngLatBoundsLike } from 'mapbox-gl' ;
35+ import { type LngLatBoundsLike } from 'mapbox-gl' ;
3636
37- import BaseMap from '#components/domain/BaseMap' ;
3837import DisasterTypeSelectInput from '#components/domain/DisasterTypeSelectInput' ;
3938import DistrictSearchMultiSelectInput , { type DistrictItem } from '#components/domain/DistrictSearchMultiSelectInput' ;
4039import Link from '#components/Link' ;
@@ -48,13 +47,13 @@ import {
4847 DEFAULT_MAP_PADDING ,
4948 DURATION_MAP_ZOOM ,
5049} from '#utils/constants' ;
51- import { adminFillLayerOptions } from '#utils/map' ;
5250import type {
5351 GoApiResponse ,
5452 GoApiUrlQuery ,
5553} from '#utils/restRequest' ;
5654import { useRequest } from '#utils/restRequest' ;
5755
56+ import GlobalMap , { type AdminZeroFeatureProperties } from '../GlobalMap' ;
5857import {
5958 APPEAL_TYPE_DREF ,
6059 APPEAL_TYPE_EAP ,
@@ -87,24 +86,8 @@ const sourceOptions: mapboxgl.GeoJSONSourceRaw = {
8786 type : 'geojson' ,
8887} ;
8988
90- interface CountryProperties {
91- country_id : number ;
92- disputed : boolean ;
93- fdrs : string ;
94- independent : boolean ;
95- is_deprecated : boolean ;
96- iso : string ;
97- iso3 : string ;
98- name : string ;
99- name_ar : string ;
100- name_es : string ;
101- name_fr : string ;
102- record_type : number ;
103- region_id : number ;
104- }
105-
10689interface ClickedPoint {
107- feature : GeoJSON . Feature < GeoJSON . Point , CountryProperties > ;
90+ featureProperties : AdminZeroFeatureProperties ;
10891 lngLat : mapboxgl . LngLatLike ;
10992}
11093
@@ -188,8 +171,8 @@ function ActiveOperationMap(props: Props) {
188171 ) ;
189172
190173 const [
191- clickedPointProperties ,
192- setClickedPointProperties ,
174+ clickedPoint ,
175+ setClickedPoint ,
193176 ] = useState < ClickedPoint | undefined > ( ) ;
194177
195178 const [ scaleBy , setScaleBy ] = useInputState < ScaleOption [ 'value' ] > ( 'peopleTargeted' ) ;
@@ -348,29 +331,30 @@ function ActiveOperationMap(props: Props) {
348331 ) ;
349332
350333 const handleCountryClick = useCallback ( (
351- feature : mapboxgl . MapboxGeoJSONFeature ,
334+ featureProperties : AdminZeroFeatureProperties ,
352335 lngLat : mapboxgl . LngLatLike ,
353336 ) => {
354- setClickedPointProperties ( {
355- feature : feature as unknown as ClickedPoint [ 'feature' ] ,
337+ setClickedPoint ( {
338+ featureProperties ,
356339 lngLat,
357340 } ) ;
358- return false ;
341+
342+ return true ;
359343 } , [ ] ) ;
360344
361345 const handlePointClose = useCallback (
362346 ( ) => {
363- setClickedPointProperties ( undefined ) ;
347+ setClickedPoint ( undefined ) ;
364348 } ,
365- [ setClickedPointProperties ] ,
349+ [ setClickedPoint ] ,
366350 ) ;
367351
368352 const handleClearFiltersButtonclick = useCallback ( ( ) => {
369353 setFilter ( { } ) ;
370354 } , [ setFilter ] ) ;
371355
372- const popupDetails = clickedPointProperties
373- ? countryGroupedAppeal [ clickedPointProperties . feature . properties . iso3 ]
356+ const popupDetails = clickedPoint
357+ ? countryGroupedAppeal [ clickedPoint . featureProperties . iso3 ]
374358 : undefined ;
375359
376360 const [ districtOptions , setDistrictOptions ] = useState < DistrictItem [ ] | null | undefined > ( ) ;
@@ -447,15 +431,8 @@ function ActiveOperationMap(props: Props) {
447431 </ Link >
448432 ) }
449433 >
450- < BaseMap
451- baseLayers = { (
452- < MapLayer
453- layerKey = "admin-0"
454- hoverable
455- layerOptions = { adminFillLayerOptions }
456- onClick = { handleCountryClick }
457- />
458- ) }
434+ < GlobalMap
435+ onClick = { handleCountryClick }
459436 >
460437 < MapContainerWithDisclaimer
461438 className = { styles . mapContainer }
@@ -503,18 +480,18 @@ function ActiveOperationMap(props: Props) {
503480 }
504481 />
505482 </ MapSource >
506- { clickedPointProperties ?. lngLat && (
483+ { clickedPoint ?. lngLat && (
507484 < MapPopup
508485 onCloseButtonClick = { handlePointClose }
509- coordinates = { clickedPointProperties . lngLat }
486+ coordinates = { clickedPoint . lngLat }
510487 heading = { (
511488 < Link
512489 to = "countriesLayout"
513490 urlParams = { {
514- countryId : clickedPointProperties . feature . properties . country_id ,
491+ countryId : clickedPoint . featureProperties . country_id ,
515492 } }
516493 >
517- { clickedPointProperties . feature . properties . name }
494+ { clickedPoint . featureProperties . name }
518495 </ Link >
519496 ) }
520497 childrenContainerClassName = { styles . popupContent }
@@ -560,7 +537,7 @@ function ActiveOperationMap(props: Props) {
560537 padding = { DEFAULT_MAP_PADDING }
561538 />
562539 ) }
563- </ BaseMap >
540+ </ GlobalMap >
564541 { onPresentationModeButtonClick && ! presentationMode && (
565542 < Button
566543 className = { styles . presentationModeButton }
0 commit comments