Skip to content

Commit

Permalink
hides PU areas legends when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
agnlez committed Sep 20, 2023
1 parent 30f50b9 commit 4a578f4
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions app/layout/scenarios/edit/map/legend/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,13 @@ export const useLockInLegend = () => {
const { puTmpIncludedValue, puIncludedValue, layerSettings } = useAppSelector(
(state) => state[`/scenarios/${sid}/edit`]
);

const totalIncludedAreas = [...puIncludedValue, ...puTmpIncludedValue];

if (!totalIncludedAreas.length) return null;

return LEGEND_LAYERS['lock-in']({
puIncludedValue: [...puIncludedValue, ...puTmpIncludedValue],
puIncludedValue: totalIncludedAreas,
onChangeVisibility: () => {
dispatch(
setLayerSettings({
Expand All @@ -253,8 +258,12 @@ export const useLockOutLegend = () => {
(state) => state[`/scenarios/${sid}/edit`]
);

const totalExcludedAreas = [...puExcludedValue, ...puTmpExcludedValue];

if (!totalExcludedAreas.length) return null;

return LEGEND_LAYERS['lock-out']({
puExcludedValue: [...puExcludedValue, ...puTmpExcludedValue],
puExcludedValue: totalExcludedAreas,
onChangeVisibility: () => {
dispatch(
setLayerSettings({
Expand All @@ -279,8 +288,12 @@ export const useLockAvailableLegend = () => {
(state) => state[`/scenarios/${sid}/edit`]
);

const totalAvailableAreas = [...puAvailableValue, ...puTmpAvailableValue];

if (!totalAvailableAreas.length) return null;

return LEGEND_LAYERS['lock-available']({
puAvailableValue: [...puAvailableValue, ...puTmpAvailableValue],
puAvailableValue: totalAvailableAreas,
onChangeVisibility: () => {
dispatch(
setLayerSettings({
Expand Down

0 comments on commit 4a578f4

Please sign in to comment.