[WEB-4663] Consolidate clinic Settings tab with combined save#5
Open
clintonium-119 wants to merge 2 commits into
Open
[WEB-4663] Consolidate clinic Settings tab with combined save#5clintonium-119 wants to merge 2 commits into
clintonium-119 wants to merge 2 commits into
Conversation
Replace the five per-setting panels (each with its own inline save/cancel) with one "Clinic Settings" panel of hairline setting rows — Tier, Patient Limit, Timezone, Require MRN, Unique MRN — and a single Reset / Save Changes footer, mirroring UserActions' one-wrapper pattern. The Delete Clinic danger panel and confirmation modal stay separate; the share code stays in the profile header. Add a presentational SettingRow primitive for the hairline rows. Add a combined updateClinicSettings route action that persists only the changed fields (aggregating per-field partial failures instead of reporting blanket success), and replace the four per-setting on*Update callbacks and their now-dead server branches with one onSaveClinicSettings contract fired once on save. Patient Limit: collapse the old "Limit Applied" toggle into the input's empty state (empty = no limit), add a "Set default (250)" button, and gate the control on US-based tier0100 clinics only — keyed off the staged tier and clinic country so a limit is never set for an ineligible clinic. Tolerate the legacy hardLimit.patientCount field on read (renamed to plan), mirroring blip; only ever write plan. Show the clinic address as a single-line field in the profile header details. Add tests for SettingRow and the consolidated Settings tab.
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/components/Clinic/ClinicProfile.test.tsx`:
- Around line 122-163: Extend the ClinicProfile patient-limit tests around the
existing “Set default” and legacy patientCount cases to verify that clearing the
Maximum patients field submits null. Add coverage showing decimal,
exponent-notation, and negative inputs cannot be saved as truncated limits or
interpreted as removals, using the existing save interaction and request
assertions.
In `@app/routes/clinics`.$clinicId.tsx:
- Around line 443-448: Update the MRN settings handling in the record callback
around MrnSettingsSchema.parse so missing fields do not become false: require
both mrnRequired and mrnUnique to be present or retrieve the existing value for
any missing field, and reject submissions whose values are not the literal
strings "true" or "false".
- Around line 456-472: The patient-limit flow must consistently reject malformed
values and prevent writes for ineligible clinics or failed dependent tier
updates. In app/routes/clinics.$clinicId.tsx lines 456-472, validate that the
effective clinic is US-based tier0100, require an exact non-negative integer or
intentional blank, and skip the patient-limit write when the tier change fails.
In app/components/Clinic/ClinicProfile.tsx lines 310-315, convert only blank
input to null and reject decimal, negative, exponent-form, or otherwise
malformed values. In app/components/Clinic/ClinicProfile.test.tsx lines 122-163,
add regression coverage for blank removal, malformed numbers, and ineligible
clinics.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d5ef1675-48e1-446f-a13b-55c4984e3a3f
📒 Files selected for processing (6)
app/components/Clinic/ClinicProfile.test.tsxapp/components/Clinic/ClinicProfile.tsxapp/components/Clinic/types.tsapp/components/ui/SettingRow.test.tsxapp/components/ui/SettingRow.tsxapp/routes/clinics.$clinicId.tsx
Address data-integrity findings on the combined clinic Settings save: - MRN settings: require both mrnRequired and mrnUnique and accept only the literal 'true'/'false' at the action boundary, so a partial submit can no longer coerce an omitted flag to false and silently clear it (the endpoint replaces the whole settings object). - Patient limit (UI): treat only a blank value as a removal; block the save and show an inline error for decimal, negative, exponent, or otherwise malformed input instead of truncating via parseInt or degrading invalid input to a null removal. - Patient limit (action): reject non-blank values that aren't an exact non-negative integer, and skip the write when a tier change in the same submit failed, so a limit is never applied to a clinic that kept an ineligible tier. Add regression tests for blank removal, valid integer save, and decimal/negative inputs blocking the save.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WEB-4663
I noticed that this element got missed when I did the theme updates. It necessitates a bit of a logic shift on submission, since the UI groups a bunch of fields into one form that hit disparate endpoints. But the UI is much better, so I think it's worth the code shuffle.