Skip to content

fix(v5): calendar uses from/to params + Buchen guards invalid datetime#335

Merged
nash87 merged 2 commits into
mainfrom
fix/v5-calendar-buchen-guards
Apr 24, 2026
Merged

fix(v5): calendar uses from/to params + Buchen guards invalid datetime#335
nash87 merged 2 commits into
mainfrom
fix/v5-calendar-buchen-guards

Conversation

@nash87
Copy link
Copy Markdown
Owner

@nash87 nash87 commented Apr 24, 2026

Summary

Mirrors the parkhub-rust PR #373 fix for two Codex-flagged silent-fail bugs already shipped on main via #331.

  • Calendar query mismatch: api.calendarEvents(start, end) serialized to ?start=...&end=..., but BookingCalendarController::calendarEvents reads from/to. The month-scope filter was silently dropped → unbounded event set + stale Kalender counts + payload bloat. Rename positional params and build the query via URLSearchParams.
  • Buchen invalid-datetime silent fail: new Date(startDate).toISOString() throws RangeError on an empty datetime-local. The exception fires inside the onClick, the mutation never fires, and the user sees nothing happen. Added an isValidDt guard that surfaces a German error toast.

Test plan

  • npm run test -- --run src/design-v5/screens/{Kalender,Buchen} src/api/client — 107/107 passing locally
  • Client regression test asserts URL contains from=/to= and neither start= nor end=
  • New Buchen test clears the datetime input and asserts error toast + no createBooking call
  • New regression-guard test asserts valid defaults still produce parseable ISO via toISOString()

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.
@nash87 nash87 enabled auto-merge (squash) April 24, 2026 01:42
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread parkhub-web/src/api/client.ts
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.
@nash87 nash87 merged commit b7358f7 into main Apr 24, 2026
20 checks passed
@nash87 nash87 deleted the fix/v5-calendar-buchen-guards branch April 24, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant