@@ -7,24 +7,20 @@ import { getScenarioEditSlice } from 'store/slices/scenarios/edit';
7
7
8
8
import PluginMapboxGl from '@vizzuality/layer-manager-plugin-mapboxgl' ;
9
9
import { LayerManager , Layer } from '@vizzuality/layer-manager-react' ;
10
- import { sortBy } from 'lodash' ;
11
10
import { FiLayers } from 'react-icons/fi' ;
12
11
13
12
import { useAccessToken } from 'hooks/auth' ;
14
13
import { useSelectedFeatures , useTargetedFeatures } from 'hooks/features' ;
15
14
import { useAllGapAnalysis } from 'hooks/gap-analysis' ;
16
15
import {
17
- // usePUGridPreviewLayer,
18
- // useAdminPreviewLayer,
19
16
useWDPAPreviewLayer ,
20
17
usePUGridLayer ,
21
18
useFeaturePreviewLayers ,
22
- // useLegend,
23
19
useBBOX ,
24
20
useTargetedPreviewLayers ,
25
21
} from 'hooks/map' ;
26
22
import { useProject } from 'hooks/projects' ;
27
- import { useCostSurfaceRange , useScenario , useScenarioPU } from 'hooks/scenarios' ;
23
+ import { useScenario , useScenarioPU } from 'hooks/scenarios' ;
28
24
import { useBestSolution } from 'hooks/solutions' ;
29
25
import { useWDPACategories } from 'hooks/wdpa' ;
30
26
@@ -130,59 +126,11 @@ export const ScenariosEditMap = (): JSX.Element => {
130
126
const { data : scenarioData } = useScenario ( sid ) ;
131
127
132
128
const { data : selectedFeaturesData } = useSelectedFeatures ( sid , { } ) ;
133
-
134
129
const { data : targetedFeaturesData } = useTargetedFeatures ( sid , { } ) ;
135
-
136
- const previewFeatureIsSelected = useMemo ( ( ) => {
137
- if ( tab === TABS [ 'scenario-features' ] ) {
138
- return (
139
- ( selectedFeaturesData || [ ] ) . filter ( ( { id } ) => selectedFeatures . includes ( id ) ) . length > 0
140
- ) ;
141
- }
142
-
143
- if ( tab === TABS [ 'scenario-features-targets-spf' ] ) {
144
- return (
145
- ( targetedFeaturesData || [ ] ) . filter ( ( { id } ) => selectedFeatures . includes ( id ) ) . length > 0
146
- ) ;
147
- }
148
-
149
- return false ;
150
- } , [ tab , selectedFeaturesData , targetedFeaturesData , selectedFeatures ] ) ;
151
-
152
- const selectedPreviewFeatures = useMemo ( ( ) => {
153
- if ( tab === TABS [ 'scenario-features' ] ) {
154
- return ( selectedFeaturesData || [ ] )
155
- . filter ( ( { id } ) => selectedFeatures . includes ( id ) )
156
- . map ( ( { name, id } ) => ( { name, id } ) )
157
- . sort ( ( a , b ) => {
158
- const aIndex = selectedFeatures . indexOf ( a . id as string ) ;
159
- const bIndex = selectedFeatures . indexOf ( b . id as string ) ;
160
- return aIndex - bIndex ;
161
- } ) ;
162
- }
163
-
164
- if ( tab === TABS [ 'scenario-features-targets-spf' ] ) {
165
- return ( targetedFeaturesData || [ ] )
166
- . filter ( ( { id } ) => selectedFeatures . includes ( id ) )
167
- . map ( ( { name, id } ) => ( { name, id } ) )
168
- . sort ( ( a , b ) => {
169
- const aIndex = selectedFeatures . indexOf ( a . id as string ) ;
170
- const bIndex = selectedFeatures . indexOf ( b . id as string ) ;
171
- return aIndex - bIndex ;
172
- } ) ;
173
- }
174
-
175
- return [ ] ;
176
- } , [ tab , selectedFeaturesData , targetedFeaturesData , selectedFeatures ] ) ;
177
-
178
- const { data : costSurfaceRangeData } = useCostSurfaceRange ( sid ) ;
179
-
180
130
const { data : allGapAnalysisData } = useAllGapAnalysis ( sid , {
181
131
enabled : ! ! sid ,
182
132
} ) ;
183
-
184
133
const { data : projectData } = useProject ( pid ) ;
185
-
186
134
const { data : protectedAreasData } = useWDPACategories ( {
187
135
adminAreaId :
188
136
projectData ?. adminAreaLevel2Id || projectData ?. adminAreaLevel1I || projectData ?. countryId ,
@@ -285,55 +233,35 @@ export const ScenariosEditMap = (): JSX.Element => {
285
233
puIncludedValue : [ ...puIncludedValue , ...puTmpIncludedValue ] ,
286
234
puExcludedValue : [ ...puExcludedValue , ...puTmpExcludedValue ] ,
287
235
puAvailableValue : [ ...puAvailableValue , ...puTmpAvailableValue ] ,
288
- // features: [TABS['scenario-target-achievement'], TABS['scenario-gap-analysis']].includes(tab)
289
- // ? []
290
- // : featuresIds,
236
+ features : [ TABS [ 'scenario-features' ] , TABS [ 'scenario-features-targets-spf' ] ] . includes ( tab )
237
+ ? [ ]
238
+ : featuresIds ,
239
+ selectedFeatures,
291
240
preHighlightFeatures,
292
241
postHighlightFeatures : postHighlightedFeaturesIds ,
293
- // cost: costSurfaceRangeData,
294
242
runId : selectedSolution ?. runId || bestSolution ?. runId ,
295
243
settings : {
296
- // pugrid: layerSettings.pugrid,
297
- // 'wdpa-percentage': layerSettings['wdpa-percentage'],
298
- // features: layerSettings. features,
299
- // ' cost-surface' : layerSettings[selectedCostSurface] ,
300
- // 'lock-in': layerSettings['lock-in'],
301
- // 'lock-out': layerSettings['lock-out'],
302
- // 'lock-available': layerSettings['lock-available'],
303
- // frequency: layerSettings.frequency,
304
- // solution: layerSettings.solution,
244
+ pugrid : layerSettings . pugrid ,
245
+ 'wdpa-percentage' : layerSettings [ 'wdpa-percentage' ] ,
246
+ ' features-highlight' : layerSettings [ ' features-highlight' ] ,
247
+ cost : layerSettings . cost ,
248
+ 'lock-in' : layerSettings [ 'lock-in' ] ,
249
+ 'lock-out' : layerSettings [ 'lock-out' ] ,
250
+ 'lock-available' : layerSettings [ 'lock-available' ] ,
251
+ frequency : layerSettings . frequency ,
252
+ solution : layerSettings . solution ,
305
253
...layerSettings ,
306
254
} ,
307
255
} ,
308
256
} ) ;
309
257
310
258
const LAYERS = [
311
- // PUGridPreviewLayer,
312
- // AdminPreviewLayer,
313
259
PUGridLayer ,
314
260
WDPApreviewLayer ,
315
261
...FeaturePreviewLayers ,
316
262
...TargetedPreviewLayers ,
317
263
] . filter ( ( l ) => ! ! l ) ;
318
264
319
- // const LEGEND = useLegend({
320
- // layers,
321
- // options: {
322
- // wdpaIucnCategories: protectedAreas,
323
- // wdpaThreshold:
324
- // tab === TABS['scenario-protected-areas'] ? wdpaThreshold : scenarioData?.wdpaThreshold,
325
- // cost: costSurfaceRangeData,
326
- // items: selectedPreviewFeatures,
327
- // puAction,
328
- // puIncludedValue: [...puIncludedValue, ...puTmpIncludedValue],
329
- // puExcludedValue: [...puExcludedValue, ...puTmpExcludedValue],
330
- // puAvailableValue: [...puAvailableValue, ...puTmpAvailableValue],
331
- // runId: selectedSolution?.runId || bestSolution?.runId,
332
- // numberOfRuns: scenarioData?.numberOfRuns || 0,
333
- // layerSettings,
334
- // },
335
- // });
336
-
337
265
useEffect ( ( ) => {
338
266
setBounds ( {
339
267
bbox : BBOX ,
@@ -491,7 +419,7 @@ export const ScenariosEditMap = (): JSX.Element => {
491
419
) ;
492
420
493
421
const handleTransformRequest = useCallback (
494
- ( url ) => {
422
+ ( url : string ) => {
495
423
if ( url . startsWith ( process . env . NEXT_PUBLIC_API_URL ) ) {
496
424
return {
497
425
url,
@@ -520,19 +448,6 @@ export const ScenariosEditMap = (): JSX.Element => {
520
448
[ setLayerSettings , dispatch ]
521
449
) ;
522
450
523
- const onChangeVisibility = useCallback (
524
- ( id ) => {
525
- const { visibility = true } = layerSettings [ id ] || { } ;
526
- dispatch (
527
- setLayerSettings ( {
528
- id,
529
- settings : { visibility : ! visibility } ,
530
- } )
531
- ) ;
532
- } ,
533
- [ setLayerSettings , dispatch , layerSettings ]
534
- ) ;
535
-
536
451
const renderLegendItems = ( {
537
452
type,
538
453
intersections,
0 commit comments