mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 21:31:46 +00:00
3b94727c07
- Derive journey lifecycle from linked trip dates (live/upcoming/completed/draft) instead of relying solely on status field; status=archived always wins - Add Archive/Restore Journey action in journey settings dialog - Rename cities → places end-to-end (SQL alias, TS types, stats field, all locales) - Wire up search icon: toggles inline input, filters by title+subtitle client-side - Fix channelConfigured check: trip reminders enabled by default since inapp is always available; remove channel check, controlled solely by admin setting - Expose notify_trip_reminder toggle in Admin → Settings → Notifications - Add trip_date_min/trip_date_max to listJourneys SQL for client-side lifecycle - Add archived status to Journey type (server + client) - Update all 15 locale files with new keys (search, archive, places, trip reminders)
33 lines
972 B
TypeScript
33 lines
972 B
TypeScript
export type JourneyLifecycle = 'archived' | 'live' | 'upcoming' | 'completed' | 'draft'
|
|
|
|
export function computeJourneyLifecycle(
|
|
status: string,
|
|
tripDateMin: string | null | undefined,
|
|
tripDateMax: string | null | undefined,
|
|
): JourneyLifecycle {
|
|
if (status === 'archived') return 'archived'
|
|
|
|
if (tripDateMin && tripDateMax) {
|
|
const today = new Date().toISOString().split('T')[0]
|
|
if (tripDateMin <= today && today <= tripDateMax) return 'live'
|
|
if (tripDateMin > today) return 'upcoming'
|
|
return 'completed'
|
|
}
|
|
|
|
if (!tripDateMin && !tripDateMax) {
|
|
return 'draft'
|
|
}
|
|
|
|
// Single boundary: only start or only end
|
|
if (tripDateMin && !tripDateMax) {
|
|
const today = new Date().toISOString().split('T')[0]
|
|
return tripDateMin > today ? 'upcoming' : 'live'
|
|
}
|
|
if (!tripDateMin && tripDateMax) {
|
|
const today = new Date().toISOString().split('T')[0]
|
|
return tripDateMax < today ? 'completed' : 'live'
|
|
}
|
|
|
|
return 'completed'
|
|
}
|