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-793: Add SWR to conditions widget #397

Merged
merged 3 commits into from
Sep 28, 2021
Merged

MF-793: Add SWR to conditions widget #397

merged 3 commits into from
Sep 28, 2021

Conversation

denniskigen
Copy link
Member

@denniskigen denniskigen commented Sep 24, 2021

Requirements

  • This PR has a title that briefly describes the work done, including the ticket number if there is a ticket.
  • My work conforms to the OpenMRS 3.0 Styleguide.
  • I checked for feature overlap with existing widgets.

Summary

This PR:

  1. Adds SWR data fetching hooks to the conditions widget.
  2. Refactors the existing components to reuse these hooks.
  3. Adds a mutate call in the ConditionsForm so that the related widgets automatically revalidate when a new condition is successfully recorded via the form.
  4. Refactors existing tests to work within the SWR paradigm.

Issue

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

@denniskigen denniskigen changed the title MF-793: Add SWR to Conditions widget MF-793: Add SWR to conditions widget Sep 25, 2021
@denniskigen denniskigen marked this pull request as draft September 25, 2021 09:56
@denniskigen denniskigen marked this pull request as ready for review September 25, 2021 16:46
map((entries) => entries?.map((entry) => entry.resource) ?? []),
map((data) => formatConditions(data)),
map((data) => data.sort((a, b) => (b?.onsetDateTime > a?.onsetDateTime ? 1 : -1))),
export function useConditions(patientUuid: string) {

Choose a reason for hiding this comment

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

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.

Looks good other than the 1s wait in the tests. Please fix that and feel free to merge.

Remove the view state reducer logic from the ConditionsForm component code. I'll argue that it only served to make the code unwieldy and harder to reason about. This change shaves 100 lines of boilerplate from the component code as well.
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.

3 participants