[CSM Portal] validate call-request times client-side; enter local, store UTC - #1027
Conversation
…ore UTC The call-request create dialog previously validated almost nothing on the time picker: no lead-time or past-time check, duration only gated >=1, unbounded slot count, no dedupe, and a "(UTC)" label that contradicted the local-time widget. Every mismatch round-tripped to the backend and surfaced as a generic 400. - Enforce per-severity minimum lead time on each proposed slot (S0 15m, S1 30m, S2 60m, S3 90m, S4 120m; 300m fallback), mirroring the backend rule. - Enter times in the user's timezone and store/submit UTC; show a live UTC preview per slot. Fix display so stored UTC times render in the user's timezone (previously double-shifted for any non-UTC browser). - Clamp duration to 15-240, cap slots at 3, de-duplicate times, block past times. - Add timezone-aware helpers (zonedInputToUtcIso, utcMsToZonedInputValue) to utils/dateTime.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds timezone conversion utilities, severity-driven lead-time and slot validation in the create call request dialog, wires an optional ChangesCall request severity lead-time and timezone handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant CreateCallRequestDialog
participant zonedInputToUtcIso
participant onSubmit
User->>CreateCallRequestDialog: enter timeslot and duration
CreateCallRequestDialog->>zonedInputToUtcIso: convert local slot to UTC ISO
zonedInputToUtcIso-->>CreateCallRequestDialog: UTC instant
CreateCallRequestDialog->>CreateCallRequestDialog: validate lead time by severity, dedupe, check duration
User->>CreateCallRequestDialog: click submit
CreateCallRequestDialog->>onSubmit: submit filtered utcTimes
sequenceDiagram
participant CsmCaseDetailPage
participant CallRequestsWidget
participant CreateCallRequestDialog
CsmCaseDetailPage->>CallRequestsWidget: severity={c.severity}
CallRequestsWidget->>CreateCallRequestDialog: severity={severity}
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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 |
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@apps/csm-portal/webapp/src/utils/dateTime.ts`:
- Around line 227-237: The midnight normalization logic should stay in
timeZoneOffsetMs, but not in the formatter helpers. Update
utcMsToZonedInputValue and formatAbsoluteForUser so that when an hour value of
24 is encountered it rolls the date forward to the next day’s 00:00 instead of
forcing hour 0 on the same date; keep the existing timeZoneOffsetMs behavior
unchanged. Use the utcMsToZonedInputValue and formatAbsoluteForUser symbols to
locate the formatter-side adjustment.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b519cc39-b82f-4e28-b72f-6f2c087e4ddb
📒 Files selected for processing (5)
apps/csm-portal/webapp/src/features/csm-cases/components/CallRequestRow.tsxapps/csm-portal/webapp/src/features/csm-cases/components/CallRequestsWidget.tsxapps/csm-portal/webapp/src/features/csm-cases/components/CreateCallRequestDialog.tsxapps/csm-portal/webapp/src/features/csm-cases/pages/CsmCaseDetailPage.tsxapps/csm-portal/webapp/src/utils/dateTime.ts
Replace `hour12: false` + defensive `hour === 24 -> 0` handling with an explicit `hourCycle: "h23"` in timeZoneOffsetMs, utcMsToZonedInputValue, and formatAbsoluteForUser. h23 never emits "24", so the fragile midnight branch is removed and the calendar date is always correct.
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
|
@coderabbitai resume |
1 similar comment
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
What
Adds client-side validation to the call-request create dialog and fixes timezone handling for proposed call times.
Previously the time picker validated almost nothing: no lead-time or past-time check, duration only gated
>= 1, an unbounded number of slots, no de-duplication, and a "(UTC)" label that contradicted the local-timedatetime-localwidget. Every mismatch round-tripped to the backend and surfaced as a generic 400 with no actionable message.Changes
min, per-slot error text, and the submit gate all enforce it. The case severity is threaded from the case detail page through the widget to the dialog.zonedInputToUtcIso,utcMsToZonedInputValue, plus an internal offset helper) added toutils/dateTime.ts.Notes
Verification
pnpm build(tsc + vite) andpnpm lintpass. Timezone conversion validated across a DST boundary and round-trips.Summary by CodeRabbit
New Features
Bug Fixes