Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [DHIS2-6335] use custom map center point #3312

Merged
merged 82 commits into from
Mar 21, 2024
Merged

Conversation

simonadomnisoru
Copy link
Contributor

@simonadomnisoru simonadomnisoru commented Jun 13, 2023

DHIS2-6335

Tech summary

  • The orgUnit geometry is retrieved using useApiMetadataQuery(react query) by useCenterPoint hook in the WidgetEnrollment and withCenterPoint HOC in the rest of the forms.
  • The geometry is only retrieved when we open the map and no coordinate/polygon has been saved previously.
  • When the orgUnit is missing the geometry information, a fallback is used to search the parent orgUnit until a viable one is found. The Map will default to London coordinates if no viable geometry info is found.
  • The geometry information is converted based on its type (Point or Polygon) to Array and passed to the Map component.

Copy link
Member

@JoakimSM JoakimSM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice, change the query key (see comment) and let's get this one in.

(We should probably change the source org. unit in a couple of places, but we need to discuss it a bit first, so this will be other tickets)

const { orgUnit, ...passOnProps } = props;
const [orgUnitKey, setOrgUnitKey] = useState(orgUnit.id);
const [shouldFetch, setShouldFetch] = useState(false);
const queryKey = ['organisationUnit', orgUnitKey];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change the key to reflect that we are just getting geometry here (so we don't clash with other caches). Suggestion: ['organisationUnit', 'geometry', orgUnitKey]

And use same key in useCenterPoint.js

Copy link

@geethaalwan geethaalwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested successfully on 2.41,2.41,2.40.4,2.39.6,2.38.7 versions

@simonadomnisoru simonadomnisoru merged commit 2dbaffe into master Mar 21, 2024
42 checks passed
@simonadomnisoru simonadomnisoru deleted the DHIS2-6335 branch March 21, 2024 10:28
dhis2-bot added a commit that referenced this pull request Mar 21, 2024
## [100.67.5](v100.67.4...v100.67.5) (2024-03-21)

### Bug Fixes

* [DHIS2-6335] use custom map center point ([#3312](#3312)) ([2dbaffe](2dbaffe))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 100.67.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants