-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WAITP-1223: Tupaia web map legend (#4724)
* setup map legend * update legend props * mobile map legend * Update MobileMapLegend.tsx * refactor map legend * fix console warnings
- Loading branch information
Showing
15 changed files
with
154 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
packages/tupaia-web/src/features/Map/MapLegend/DesktopMapLegend.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Tupaia | ||
* Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd | ||
*/ | ||
|
||
export { useDefaultMapOverlay } from './useDefaultMapOverlay'; | ||
export { useHiddenMapValues } from './useHiddenMapValues'; | ||
export { useMapOverlayReport } from './useMapOverlayReport'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/tupaia-web/src/features/Map/utils/useHiddenMapValues.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Tupaia | ||
* Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd | ||
*/ | ||
import { useState } from 'react'; | ||
import { LegendProps, Series, Value } from '@tupaia/ui-map-components'; | ||
|
||
export const useHiddenMapValues = (serieses: Series[] = []) => { | ||
const [hiddenValues, setHiddenValues] = useState({}); | ||
const [prevSerieses, setPrevSerieses] = useState(serieses); | ||
|
||
// reset hidden values when changing overlay or entity | ||
if (JSON.stringify(serieses) !== JSON.stringify(prevSerieses)) { | ||
setPrevSerieses(serieses); | ||
const hiddenByDefault = serieses.reduce((values, { hideByDefault, key }) => { | ||
return { ...values, [key]: hideByDefault }; | ||
}, {}); | ||
setHiddenValues(hiddenByDefault); | ||
} | ||
|
||
const setValueHidden = (key: string, value: Value, hidden: boolean) => { | ||
setHiddenValues((currentState: LegendProps['hiddenValues']) => ({ | ||
...currentState, | ||
[key]: { ...currentState[key], [value!]: hidden }, | ||
})); | ||
}; | ||
|
||
return { setValueHidden, hiddenValues }; | ||
}; |
25 changes: 25 additions & 0 deletions
25
packages/tupaia-web/src/features/Map/utils/useMapOverlayReport.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Tupaia | ||
* Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd | ||
*/ | ||
|
||
import { useParams } from 'react-router'; | ||
import { | ||
useMapOverlays, | ||
useMapOverlayReport as useMapOverlayReportQuery, | ||
} from '../../../api/queries'; | ||
import { useDateRanges } from '../../../utils'; | ||
import { URL_SEARCH_PARAMS } from '../../../constants'; | ||
|
||
export const useMapOverlayReport = () => { | ||
const { projectCode, entityCode } = useParams(); | ||
const { selectedOverlay } = useMapOverlays(projectCode, entityCode); | ||
const { startDate, endDate } = useDateRanges( | ||
URL_SEARCH_PARAMS.MAP_OVERLAY_PERIOD, | ||
selectedOverlay, | ||
); | ||
return useMapOverlayReportQuery(projectCode, entityCode, selectedOverlay, { | ||
startDate, | ||
endDate, | ||
}); | ||
}; |
Oops, something went wrong.