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:
jubnl
2026-05-22 18:55:40 +02:00
parent cf59b189cf
commit 40bb67167b
11 changed files with 222 additions and 89 deletions
+12
View File
@@ -65,6 +65,18 @@ export function formatTime(timeStr: string | null | undefined, locale: string, t
} catch { return timeStr }
}
export function splitReservationDateTime(value?: string | null): { date: string | null; time: string | null } {
if (!value) return { date: null, time: null }
const isoDate = /^\d{4}-\d{2}-\d{2}$/
if (value.includes('T')) {
const [d, t] = value.split('T')
return { date: isoDate.test(d) ? d : null, time: t ? t.slice(0, 5) : null }
}
if (isoDate.test(value)) return { date: value, time: null }
if (/^\d{1,2}:\d{2}/.test(value)) return { date: null, time: value.slice(0, 5) }
return { date: null, time: null }
}
export function dayTotalCost(dayId: number, assignments: AssignmentsMap, currency: string): string | null {
const da = assignments[String(dayId)] || []
const total = da.reduce((s, a) => s + (parseFloat(a.place?.price || '') || 0), 0)