refactor: split app into modular src architecture
Some checks failed
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-android (push) Has been cancelled
Luggage List Build / build-web (push) Has been cancelled

This commit is contained in:
2026-04-18 12:56:12 +02:00
parent 3323d09dda
commit bdea52b7c6
17 changed files with 1493 additions and 1343 deletions

25
src/utils/date.js Normal file
View File

@@ -0,0 +1,25 @@
export function makeId(prefix) {
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
}
export function todayYMD() {
const now = new Date();
return `${now.getFullYear()}-${`${now.getMonth() + 1}`.padStart(2, '0')}-${`${now.getDate()}`.padStart(2, '0')}`;
}
export function parseYMD(value) {
if (!value || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return null;
const d = new Date(`${value}T00:00:00`);
return Number.isNaN(d.getTime()) ? null : d;
}
export function findActiveTripId(trips) {
const today = parseYMD(todayYMD());
if (!today) return null;
const active = trips.find((trip) => {
const start = parseYMD(trip.startDate);
const end = parseYMD(trip.endDate);
return !!start && !!end && today >= start && today <= end;
});
return active?.id || null;
}