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: manually marked Atlas countries not saved when no trips exist — closes #95

Maurice02b907e764a6
diff --git a/server/src/routes/atlas.ts b/server/src/routes/atlas.ts
index 4b6962b2d..e692e5f6e 100644
--- a/server/src/routes/atlas.ts
+++ b/server/src/routes/atlas.ts
@@ -96,7 +96,10 @@ router.get('/stats', (req: Request, res: Response) => {
const tripIds = trips.map(t => t.id);
if (tripIds.length === 0) {
- return res.json({ countries: [], trips: [], stats: { totalTrips: 0, totalPlaces: 0, totalCountries: 0, totalDays: 0 } });
+ // Still include manually marked countries even without trips
+ const manualCountries = db.prepare('SELECT country_code FROM visited_countries WHERE user_id = ?').all(userId) as { country_code: string }[];
+ const countries = manualCountries.map(mc => ({ code: mc.country_code, placeCount: 0, tripCount: 0, firstVisit: null, lastVisit: null }));
+ return res.json({ countries, trips: [], stats: { totalTrips: 0, totalPlaces: 0, totalCountries: countries.length, totalDays: 0 } });
}
const placeholders = tripIds.map(() => '?').join(',');