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

MF-788: Add swr to allergies widget #383

Merged
merged 4 commits into from
Sep 24, 2021
Merged

MF-788: Add swr to allergies widget #383

merged 4 commits into from
Sep 24, 2021

Conversation

denniskigen
Copy link
Member

@denniskigen denniskigen commented Sep 17, 2021

Requirements

Summary

This PR sets up the allergies widget to work with SWR. It introduces a reusable useAllergies hook that encapsulates fetching of allergies data from the backend using the SWR paradigm.

Additionally, it introduces a call to the SWR mutate function which automatically revalidates the allergies widget data immediately after a new allergy is successfully recorded using the allergy form.

Videos

saving-allergy.mp4
revalidate-on-focus.mp4
showing-potentially-stale-data-while-revalidating.mp4
overview-component-pagination.mp4

Related Issue

https://issues.openmrs.org/browse/MF-788

@brandones
Copy link
Contributor

Is this in progress (should be draft) or are you waiting on a review (request some reviewers)?

@denniskigen
Copy link
Member Author

Ready for review @brandones

@denniskigen denniskigen changed the title Add swr to allergies widget MF-788: Add swr to allergies widget Sep 23, 2021
export const patientAllergiesFormWorkspace = 'patient-allergy-form-workspace';
export const allergiesToShowCount = 5;
Copy link
Contributor

Choose a reason for hiding this comment

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

Matter of taste, but I'd just put this in the file it goes with. It's pretty specific to that component.

Copy link
Contributor

@brandones brandones left a comment

Choose a reason for hiding this comment

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

This rules. The code is shorter, has more robust state handling, and does the awesome SWR stuff. Thanks @denniskigen .

@brandones brandones merged commit df62e1c into master Sep 24, 2021
@brandones brandones deleted the MF-788 branch September 24, 2021 00:40
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