-
Notifications
You must be signed in to change notification settings - Fork 561
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
Support For BULK beds creation in location #10815
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request introduces new localization keys in the Changes
Possibly Related PRs
Suggested Labels
Suggested Reviewers
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Pro Plan! Simply use the command 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (5)
🔇 Additional comments (4)
✨ Finishing Touches
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: 1
🧹 Nitpick comments (2)
src/pages/Facility/settings/locations/LocationForm.tsx (2)
136-149
: Implemented batch submission mutation.The batch submission mutation is added to handle creating multiple beds at once. However, there is a commented-out error handler that should be either implemented or removed.
Consider either implementing the error handling by uncommenting and updating the error toast:
- // onError: () => { - // toast.error(t("submission_failed")); - // }, + onError: () => { + toast.error(t("bed_creation_failed")); + },Or remove the commented-out code if it's not needed.
152-177
: Implemented bulk bed creation functionality.This implementation allows creating multiple beds at once when beds_count > 1.
However, there's an inconsistency in the mode parameter between single and batch submissions.
In line 180, the single submission uses
mode: "kind"
, but in the batch submission body, it usesmode: "instance"
. Consider using the same mode value for consistency:const data: LocationWrite = { ...values, - mode: "instance", + mode: "kind", description: values.description || "", organizations: values.organizations, parent: values.parent || undefined, };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
public/locale/en.json
(2 hunks)src/pages/Facility/settings/locations/LocationForm.tsx
(9 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Redirect rules - care-ohc
- GitHub Check: Header rules - care-ohc
- GitHub Check: Pages changed - care-ohc
- GitHub Check: Test
- GitHub Check: cypress-run (1)
- GitHub Check: OSSAR-Scan
🔇 Additional comments (10)
public/locale/en.json (2)
471-471
: Localization key added for bed count validation.This localization key provides an error message for validation when the number of beds is not greater than zero, supporting the new bulk bed creation feature.
2297-2297
: Localization key added for bed count field label.This localization key provides the label text for the total number of beds field, supporting the new bulk bed creation feature.
src/pages/Facility/settings/locations/LocationForm.tsx (8)
3-3
: Added direct i18next import for translations.Good addition of the direct import of the translation function, which is used for schema validation messages.
39-42
: Added batch operation type imports.These imports support the new bulk beds creation functionality by providing the types needed for batch requests.
45-45
: Updated validation message to use translation function.Good improvement for internationalization by using the translation function for the field validation error message.
51-54
: Added beds_count field to form schema.The beds_count field is properly defined with appropriate validation using the translation function for the error message.
73-73
: Added default value for beds_count.Setting a default value of 1 for beds_count is appropriate and ensures the form has a valid initial state.
95-96
: Added isEditMode flag for better code readability.Good addition of this variable which makes the code more readable and avoids repeating the condition checking throughout the component.
231-244
: Added real-time preview of generated bed names.Great UX enhancement! This preview shows users exactly what bed names will be created based on their input, helping them understand the batch creation process.
361-364
: Updated button text with translations.Good improvement for internationalization by using the translation function for the action button, with different text based on create/update mode.
Screen.Recording.2025-02-26.at.12.19.23.AM.mov |
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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
public/locale/en.json
(2 hunks)src/pages/Facility/settings/locations/LocationForm.tsx
(9 hunks)
🔇 Additional comments (8)
public/locale/en.json (3)
471-471
: LGTM: Added validation error message for bed count.The new error message is clear and descriptive, ensuring users understand they must enter a positive number for bed count.
474-474
: LGTM: Added error message for bed creation failure.This provides appropriate feedback when bulk bed creation fails.
2298-2298
: LGTM: Added label for total number of beds field.This label clearly describes the purpose of the beds_count field in the form.
src/pages/Facility/settings/locations/LocationForm.tsx (5)
152-177
: LGTM: Added bulk bed creation functionality.The implementation of bulk bed creation correctly:
- Checks if the form type is for beds (
"bd"
)- Verifies it's not in edit mode
- Ensures beds_count is greater than 1
- Builds a batch request with multiple locations
This will significantly improve workflow efficiency for users who need to add multiple beds at once.
289-306
: LGTM: Added beds_count field to the form.The implementation correctly:
- Shows the field only when creating beds (form type is "bd")
- Hides it in edit mode
- Uses proper form control and validation
- Sets appropriate minimum value
95-96
: LGTM: Added clear isEditMode flag.Using a dedicated variable for checking edit mode improves code readability and maintainability throughout the component.
136-149
: LGTM: Added batch submission mutation.The implementation properly handles:
- Success case with appropriate toast message
- Error case with user-friendly error message
- Query invalidation to refresh the data
180-180
:✅ Verification successful
Verify change in location mode from "instance" to "kind".
You've changed the mode from "instance" (in the bulk creation) to "kind" for the regular submission. Please verify this is intentional and won't affect functionality.
🏁 Script executed:
#!/bin/bash # Search for other usages of mode to understand the expected values echo "Searching for mode usage in location-related files..." rg -A 2 -B 2 "mode.*['\"]kind['\"]|mode.*['\"]instance['\"]" --type tsLength of output: 2502
Confirmed: The change to use mode "kind" for regular submission is intentional.
- The code in
src/pages/Facility/settings/locations/LocationForm.tsx
now uses mode"instance"
for bulk creation and mode"kind"
for regular submissions.- The check in
src/pages/Facility/settings/locations/LocationView.tsx
verifies that locations display correctly whenlocation.mode === "kind"
.- Components like
<LocationSearch>
already support both"kind"
and"instance"
as valid values.
Screen.Recording.2025-02-26.at.2.40.39.PM.mov |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit