-
Notifications
You must be signed in to change notification settings - Fork 522
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
Fix: Bed capacity pop up errors #9123
Fix: Bed capacity pop up errors #9123
Conversation
WalkthroughThe changes in the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
src/components/Facility/BedCapacity.tsx (1)
289-295
: Consider UX improvements for better user guidanceWhile the current changes fix the immediate issues, consider these improvements to fully meet the PR objectives:
- Add a tooltip to explain why the "Add Bed" button is disabled when no options are available
- Consider combining the two save buttons to reduce UI complexity
Here's a suggested implementation:
- {headerText === "Add Bed Capacity" && ( - <Submit - id="bed-capacity-save-and-exit" - onClick={(e) => handleSubmit(e, "Save and Exit")} - label="Save Bed Capacity" - /> - )} - {!isLastOptionType && ( - <Submit - id="bed-capacity-save" - onClick={(e) => handleSubmit(e)} - label={buttonText} - /> - )} + {headerText === "Add Bed Capacity" ? ( + <Submit + id="bed-capacity-save" + onClick={(e) => handleSubmit(e, isLastOptionType ? "Save and Exit" : undefined)} + label={buttonText} + title={bedTypes.length === 0 ? "All bed types have been added" : undefined} + disabled={bedTypes.length === 0} + /> + ) : ( + <Submit + id="bed-capacity-save" + onClick={(e) => handleSubmit(e)} + label={buttonText} + /> + )}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/components/Facility/BedCapacity.tsx
(2 hunks)
🔇 Additional comments (3)
src/components/Facility/BedCapacity.tsx (3)
80-81
: LGTM: Loading state fix addresses infinite loading issue
The immediate clearing of loading state after setting empty bed types correctly fixes the infinite loading bug that occurred when all bed types were already added.
282-288
: LGTM: Button rendering fix addresses pop-up closing issue
The "Save Bed Capacity" button is now correctly shown when adding bed capacity, ensuring users can always save and close the pop-up.
80-81
: Verify edge cases in the updated flow
Please ensure these edge cases are covered:
- Race conditions: Multiple rapid clicks on save buttons during loading state
- Form validation: The
min
attribute on number inputs might not prevent all negative number scenarios
Also applies to: 282-295
✅ Verification successful
Based on the shell script results, I can now provide a final response:
Edge cases are properly handled in the current implementation
- Race conditions during loading state:
- The code properly manages loading state with
setIsLoading(false)
in both success and error cases - Loading state updates are properly sequenced with state resets (
setBedTypes([])
)
- Form validation for negative numbers:
- All number inputs have proper validation with
min={0}
or appropriate minimum values - The bed capacity form specifically enforces:
- Minimum total capacity of 1 with
min={1}
- Current occupancy between 0 and total capacity with
min={0} max={state.form.totalCapacity}
- Minimum total capacity of 1 with
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for loading state management patterns
rg "setIsLoading" -A 5
# Search for number input validation
rg "type=\"number\"" -A 5
Length of output: 78082
LGTM @khavinshankar review and merge them , non related test failure |
@AdityaJ2305 Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌 |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
@nihal467
ScreenRecording
Screen.Recording.2024-11-15.at.10.28.55.AM.1.mov
Merge Checklist
Summary by CodeRabbit
New Features
Bug Fixes