mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-20 22:01:45 +00:00
fix(transport): resolve Invalid Date on bookings in relative Day N trips
Transport bookings on trips without calendar dates (relative "Day N" mode)
stored a malformed "T10:00" string in reservation_time. Every display
surface used includes('T') + new Date() which yielded Invalid Date.
Add splitReservationDateTime() helper that classifies any reservation_time
shape (full datetime, date-only, bare HH:MM, or legacy "T10:00") into
{ date, time } parts. Fix TransportModal to store a clean bare HH:MM
instead of "T10:00" and update the read-back path. Route all display
surfaces (ReservationsPanel, DayDetailPanel, DayPlanSidebar,
PlaceInspector, SharedTripPage, TripPDF) through the helper, gating the
DATE column on a real calendar date and the TIME column on a time part.
Guard the ICS export to skip time-only reservation_time values instead of
emitting a malformed DTSTART. Backward-compatible: existing saved rows
with "T10:00" render correctly without a data migration.
This commit is contained in:
@@ -506,6 +506,11 @@ export function exportICS(tripId: string | number): { ics: string; filename: str
|
||||
// Reservations as events
|
||||
for (const r of reservations) {
|
||||
if (!r.reservation_time) continue;
|
||||
// Skip time-only values (no calendar date — occurs on relative "Day N" trips)
|
||||
const hasDate = r.reservation_time.includes('T')
|
||||
? /^\d{4}-\d{2}-\d{2}$/.test(r.reservation_time.split('T')[0])
|
||||
: /^\d{4}-\d{2}-\d{2}$/.test(r.reservation_time);
|
||||
if (!hasDate) continue;
|
||||
const hasTime = r.reservation_time.includes('T');
|
||||
const meta = r.metadata ? (typeof r.metadata === 'string' ? JSON.parse(r.metadata) : r.metadata) : {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user