Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgnlez committed Sep 20, 2023
1 parent 4a578f4 commit ae2c7a5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
39 changes: 22 additions & 17 deletions app/hooks/map/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,26 @@ export const LEGEND_LAYERS = {
onChangeVisibility,
};
},
'wdpa-percentage': () => ({
id: 'wdpa-percentage',
name: 'Protected areas',
icon: (
<Icon
icon={HEXAGON_SVG}
className="mt-0.5 h-3.5 w-3.5 stroke-current stroke-2"
style={{ color: COLORS.wdpa }}
/>
),
settingsManager: {
opacity: true,
visibility: true,
},
}),
'wdpa-percentage': (options: { onChangeVisibility: () => void }) => {
const { onChangeVisibility } = options;

return {
id: 'wdpa-percentage',
name: 'Protected areas',
icon: (
<Icon
icon={HEXAGON_SVG}
className="mt-0.5 h-3.5 w-3.5 stroke-current stroke-2"
style={{ color: COLORS.wdpa }}
/>
),
settingsManager: {
opacity: true,
visibility: true,
},
onChangeVisibility,
};
},
'designated-areas': (options: {
items: { id: WDPA['id']; name: string }[];
onChangeVisibility: (WDPAId: WDPA['id']) => void;
Expand Down Expand Up @@ -459,7 +464,7 @@ export const LEGEND_LAYERS = {
},

// SOLUTIONS
frequency: (options) => {
frequency: (options: { numberOfRuns: number; onChangeVisibility?: () => void }) => {
const { numberOfRuns, onChangeVisibility } = options;

return {
Expand Down Expand Up @@ -488,7 +493,7 @@ export const LEGEND_LAYERS = {
value: '100',
},
],
onChangeVisibility,
...(onChangeVisibility && { onChangeVisibility }),
};
},
solution: (options?: { onChangeVisibility?: () => void }) => ({
Expand Down
10 changes: 5 additions & 5 deletions app/layout/scenarios/edit/map/legend/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const useFeatureAbundanceLegend = () => {
});
};

export const useFeatureLegend = () => {
export const useFeaturesLegend = () => {
const { query } = useRouter();
const { sid } = query as { sid: string };

Expand Down Expand Up @@ -316,13 +316,13 @@ export const useWDPAPreviewLegend = () => {
const { setLayerSettings } = scenarioSlice.actions;
const { layerSettings } = useAppSelector((state) => state[`/scenarios/${sid}/edit`]);

return LEGEND_LAYERS['wdpa-preview']({
return LEGEND_LAYERS['wdpa-percentage']({
onChangeVisibility: () => {
dispatch(
setLayerSettings({
id: 'wdpa-preview',
id: 'wdpa-percentage',
settings: {
visibility: !layerSettings['wdpa-preview']?.visibility,
visibility: !layerSettings['wdpa-percentage']?.visibility,
},
})
);
Expand Down Expand Up @@ -415,7 +415,7 @@ export const useScenarioLegend = () => {
},
{
name: 'Features (Binary)',
layers: useFeatureLegend(),
layers: useFeaturesLegend(),
},
];
};
4 changes: 1 addition & 3 deletions app/layout/scenarios/reports/solutions/frequency/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export const FrequencyPage = (): JSX.Element => {
const LEGEND = useMemo(() => {
return {
...LEGEND_LAYERS.frequency({
options: {
numberOfRuns: scenarioQuery.data?.numberOfRuns,
},
numberOfRuns: scenarioQuery.data?.numberOfRuns,
}),
name: `Frequency (${scenarioQuery.data?.numberOfRuns})`,
settingsManager: null,
Expand Down

0 comments on commit ae2c7a5

Please sign in to comment.