fix(v5): calendar uses from/to params + Buchen guards invalid datetime#335
Merged
Conversation
Mirrors parkhub-rust PR #373 fix. Two Codex-flagged silent-fail bugs shipped on main here via #331 need the same treatment. 1. `api.calendarEvents(start, end)` serialized to `?start=...&end=...`, but `BookingCalendarController::calendarEvents` reads `from`/`to`. Mismatch → month-scope filter ignored → unbounded event set + stale Kalender counts. Rename positional params to `from`/`to` and build the query via `URLSearchParams`. 2. In Buchen, the confirm path ran `new Date(startDate).toISOString()` unconditionally. If the user clears the `datetime-local` input the call throws `RangeError: Invalid time value` inside the onClick, the mutation never fires, and nothing visible happens. Add `isValidDt` guard and surface a German error toast before mutating. Tests: - `client.test.ts` asserts `from=`/`to=` present and `start=`/`end=` absent (regression guard). - `Buchen.test.tsx` adds an empty-input case that asserts the error toast fires + `createBooking` is never called, plus a regression guard that valid defaults still produce parseable ISO.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f2be5b078
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Addresses 1 Codex review finding on #335: `BookingCalendarController::calendarEvents` applies `where('end_time', '<=', $to)`. When callers pass a date-only `YYYY-MM-DD` (Kalender.tsx, Calendar.tsx), Laravel interprets it as `00:00:00` of that day and silently excludes bookings ending later on the boundary day, so monthly calendar results were incomplete on the last day of each selected range. Normalise `to` at the client boundary: if `to` matches `YYYY-MM-DD`, append ` 23:59:59` so the <= filter is inclusive of the entire selected final day. Full-datetime inputs pass through unchanged, allowing precise windowed calls. Backend semantics are unchanged; this is a pure client-side hygiene fix that matches the bug report. Added regression tests for both the bare date (normalised) and full-datetime (passthrough) paths.
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.
Summary
Mirrors the parkhub-rust PR #373 fix for two Codex-flagged silent-fail bugs already shipped on main via #331.
api.calendarEvents(start, end)serialized to?start=...&end=..., butBookingCalendarController::calendarEventsreadsfrom/to. The month-scope filter was silently dropped → unbounded event set + stale Kalender counts + payload bloat. Rename positional params and build the query viaURLSearchParams.new Date(startDate).toISOString()throwsRangeErroron an emptydatetime-local. The exception fires inside the onClick, the mutation never fires, and the user sees nothing happen. Added anisValidDtguard that surfaces a German error toast.Test plan
npm run test -- --run src/design-v5/screens/{Kalender,Buchen} src/api/client— 107/107 passing locallyfrom=/to=and neitherstart=norend=createBookingcalltoISOString()