-
Notifications
You must be signed in to change notification settings - Fork 423
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
Prevent Unnecessary Update Request in Facilities Section #8956
base: develop
Are you sure you want to change the base?
Prevent Unnecessary Update Request in Facilities Section #8956
Conversation
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
package-lock.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove package-lock from commit.
There's already another PR for the infinite load issues for Beds. In the future, make sure to get issue assigned or mention in the original thread before starting to work on an issue. |
I had made those necessary changes. |
package-lock.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this will just remove the file from develop branch. You can make use to checkout
command to check package-lock file from develop and then commit that.
src/components/Form/Form.tsx
Outdated
data-testid="submit-button" | ||
type="submit" | ||
disabled={disabled || !isDirty} | ||
label={"Save & Add More"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's pass in the label as showSaveAndAddMoreBtn prop. Refer to the original files on how we are updating this label, i.e. 'Save and Add More' vs 'Save Bed/Staff Capacity'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok got it and made those changes.
if (btnType == "Save and Exit") handleClose(); | ||
if ( | ||
btnType !== "save-and-add-more" || | ||
bedTypes.length === BED_TYPES.length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latter comparison wouldn't work as bedTypes
length will always be the same.
Here, you want to bring updatedBedTypes
out of scope earlier*, calculate the number of beds that are disabled and then do a check (if it exists + if it equals to BED_TYPES
length).
Something like:
const disabledBedTypesLength = updatedBedTypes?.filter((item) => item.disabled).length;
*In this case, we can't use bedTypes
right away since we are updating it (state may or may not be updated in time).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add package-lock back in (checked out from develop branch).
@@ -115,11 +135,21 @@ const Form = <T extends FormDetails>({ | |||
onClick={props.onCancel} | |||
label={props.cancelLabel ?? "Cancel"} | |||
/> | |||
{props.showSaveAndAddMoreBtn && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but it's a bit confusing with the button text and labeling, since regular submitBtn seems to be using showSaveAndAddMoreBtn as label.
We could change it so that buttonText
corresponds to Save/Update Bed/Staff Capacity and showSaveAndAddMoreBtn
passes in Save & Add More.
Proposed Changes
when all bed types are added it shows an error message "can't add more bed types" and not allowing user to add more bed types
@ohcnetwork/care-fe-code-reviewers
Merge Checklist