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

docs: guides & minor changes #1397

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

docs: guides & minor changes #1397

wants to merge 7 commits into from

Conversation

Topener
Copy link
Contributor

@Topener Topener commented Dec 10, 2024

Added a few guides & some minor changes to make the docs slightly better

@Topener Topener changed the title docs: some minor changes docs: guides & minor changes Jan 13, 2025
@Topener Topener marked this pull request as ready for review January 13, 2025 09:42
Copy link
Member

@amcgee amcgee left a comment

Choose a reason for hiding this comment

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

Looks good @Topener thanks! I added some comments on the blog posts, but overall this is a great addition and the suggestions are minor 👍

docs/getting-started.md Outdated Show resolved Hide resolved
docs/guides/display-alerts.md Outdated Show resolved Hide resolved
docs/guides/display-alerts.md Outdated Show resolved Hide resolved
docs/guides/display-alerts.md Outdated Show resolved Hide resolved
docs/guides/using-dataquery.md Outdated Show resolved Hide resolved

In the code above, we first check if there is an error by checking the `error` property. If there is an error, we display the error message. Next, we check if the query is still loading by checking the `loading` property. If the query is still loading, we display a loading spinner. Finally, if the query is successful, we display the data returned by the query.

Keep in mind that the structure of the data returned by the query may vary depending on the query you execute. In this example, we are fetching Organisation Units, so the data returned by the query contains an `organisationUnits` property that contains an array of Organisation Units. We're also assuming the data structure is always the same. This is not really defensive programming, so you should always check if the data is in the expected format.
Copy link
Member

Choose a reason for hiding this comment

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

This is a good paragraph! Maybe link to somewhere that defines defensive programming so that someone who doesn't know what it is can learn more?

Also - we should mention here why we use data.orgUnits (it matches the name we defined in our query object above, which could be anything)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated it, but don't have a good resource where people can learn about it, any suggestions?

docs/guides/using-dataquery.md Outdated Show resolved Hide resolved
docs/guides/using-dataquery.md Show resolved Hide resolved
docs/guides/using-dataquery.md Outdated Show resolved Hide resolved

## Conclusion

In this guide, we walked you through how to use the `useDataQuery` hook in your application to fetch data from the DHIS2 API. We covered how to define a query, execute the query, display the data, apply pagination, and apply filters to the query. By following these steps, you can fetch data from the DHIS2 API in your application with ease. You can now use this knowledge to fetch data from the DHIS2 API in your application and display it to your users, for every API endpoint available in the DHIS2 API.
Copy link
Member

Choose a reason for hiding this comment

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

The logical next step here is to use dynamic queries and refetch with a button or search input. I think it's OK to not go into that here so this guide stays short, but we should mention it and say that we'll be following up with a second guide in the series which picks up where this one leaves off?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! Let's add that as a second guide, but also lets refrain from mentioning it for now so we can merge this PR and I can work on that one after!

Copy link
Member

Choose a reason for hiding this comment

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

You don't need to mention the guide, but I would highly recommend mentioning that we support dynamic queries but that they are out of scope for this guide, with a link to the reference docs.

@Topener Topener requested a review from amcgee January 14, 2025 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants