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

1339: Save Button Disabled During API Call, Disllowing Multiple Requests #1345

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

aayush6194
Copy link

Pull Requests Requirements

  • The PR title includes a brief description of the work done, including the
    Issue number if applicable.
  • The PR includes a video showing the changes for the work done.
  • The PR title follows conventional commit label standards.
  • The changes confirm to the OpenElis Global x3 Styleguide and design
    documentation.
  • The changes include tests or are validated by existing tests.
  • I have read and agree to the Contributing Guidelines of this project.

Summary

  • Added isSubmitting to track the state of the API call.
  • The Save Button disabled while isSubmitting is true.
  • postToOpenElisServer() return a Promise, allowing to chain additional .then() handler

@mozzy11
Copy link
Collaborator

mozzy11 commented Dec 19, 2024

Thanks @aayush6194

mozzy11
mozzy11 previously approved these changes Dec 19, 2024
@@ -35,7 +35,7 @@ export const postToOpenElisServer = (
callback,
extraParams,
) => {
fetch(
return fetch(
Copy link
Collaborator

@mozzy11 mozzy11 Dec 19, 2024

Choose a reason for hiding this comment

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

@aayush6194 , we already pass a call back to the fetch function when it returns the Response.

you can revert this change here so that we are consistent across the API call utilities

@@ -330,7 +336,9 @@ function CreatePatientForm(props) {
days: "",
});
},
);
).then(() => {
setIsSubmitting(false);
Copy link
Collaborator

@mozzy11 mozzy11 Dec 19, 2024

Choose a reason for hiding this comment

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

you can instead set this directly in the call back here ,when the call returns the Response , like we do for the other post-Submit actions

@mozzy11
Copy link
Collaborator

mozzy11 commented Dec 19, 2024

Thanks @aayush6194 , just added a few minor comments , just make sure we have consistence across all the API call utilities

@mozzy11 mozzy11 dismissed their stale review December 19, 2024 13:49

need to adrees some minor comments

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