feat: add status change timestamps to bookings export#1467
Merged
Conversation
Adds per-status timestamp columns (Requested/First Approved/Final Approved/Declined/Checked In/Checked Out/No Show/Canceled/Closed) to the admin CSV export so auditors can see each transition, not just the final status. Enables downstream calculations like late cancellation (cancel within 48h of start). Switches the date conversion to the shared `toFirebaseTimestamp` helper and adds a `safeFormat` wrapper so unparseable values render as empty cells instead of crashing the export with `RangeError: Invalid time value`.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds per-status transition timestamp columns (Requested At, First/Final Approved At, Declined At, Checked In/Out At, No Show At, Canceled At, Closed At) to the admin CSV export, and hardens timestamp parsing by delegating to the shared toFirebaseTimestamp helper with a safeFormat wrapper that returns "" for unparseable values.
Changes:
- Switch local
toDateto usetoFirebaseTimestampand returnnullon bad/missing inputs. - Add
safeFormatand reuse it for both existing Booking Start/End columns and the new status timestamp columns. - Guard
calculateTimeInUseagainst nulltoDateresults.
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 of Changes
Adds per-status timestamp columns to the admin CSV export (
/api/bookings/export) so auditors can see each status transition, not just the single "End Event Status".New columns (in NY timezone, format
M/d/yyyy h:mm a):This unblocks downstream audit work — e.g. a Late Cancellation tally computed from
Canceled At - Booking Startin the existing App Script. Values are read directly from the per-status fields already present on{tenant}-bookingsdocuments; no new collection joins.Also hardens the date conversion path: switches to the shared
toFirebaseTimestamphelper fromcomponents/src/client/utils/serverDate.tsand adds a smallsafeFormatwrapper. Bookings with malformed/legacy timestamp values now render an empty cell instead of crashing the entire export withRangeError: Invalid time value. This fix also covers the pre-existingBooking Start/End Date/Timecolumns.Schema Changes
Checklist
No unit tests added: the route has no existing test scaffold and the change is mostly column wiring + delegation to an already-tested helper.
Screenshots / Video
CSV output verified locally against the MC dev dataset: new columns populate for bookings with transitions and stay empty for un-traversed statuses; bookings that previously triggered a 500 due to legacy timestamp shapes now export cleanly with empty cells in the affected columns.