Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(tours): give the latest stage date a starting value

Maurice400958807867
diff --git a/server/src/nest/tours/tour-activity-stats.helpers.ts b/server/src/nest/tours/tour-activity-stats.helpers.ts
index 6f30415f0..8b384416e 100644
--- a/server/src/nest/tours/tour-activity-stats.helpers.ts
+++ b/server/src/nest/tours/tour-activity-stats.helpers.ts
@@ -197,7 +197,8 @@ function stagedOutcome(tour: TourOfStats, keys: readonly string[], input: Activi
const stages = keys.map((key) => stageDates(tour, key));
if (stages.some((stage) => !stage.any)) return 'unassigned';
if (stages.some((stage) => stage.dates.length === 0) || !last) return 'undated';
- const lastDate = stages.flatMap((stage) => stage.dates).reduce((a, b) => (b > a ? b : a));
+ // Every stage has a date here, so the empty start never wins against an ISO date.
+ const lastDate = stages.flatMap((stage) => stage.dates).reduce((a, b) => (b > a ? b : a), '');
return [planEntry(tour, { assignmentId: last.assignmentId, date: lastDate }, dated.length, input.excluded)];
}