Fix date format issues in events API

- Convert Unix timestamps to ISO strings before sending to frontend
- Store dates as ISO strings in database during event creation
- Fix created_at, expires_at, and archived_at date conversions

This resolves the "Invalid time value" error that occurred when viewing
the events page due to SQLite returning dates as Unix timestamps.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-07-07 14:14:05 +02:00
parent 35681d5346
commit fece843505
+8 -4
View File
@@ -77,8 +77,8 @@ router.post('/', adminAuth, [
welcome_message,
color_theme,
share_link: shareLink,
expires_at,
created_at: new Date()
expires_at: expires_at.toISOString(),
created_at: new Date().toISOString()
});
// Log activity
@@ -180,10 +180,14 @@ router.get('/', adminAuth, async (req, res) => {
return acc;
}, {});
// Add photo counts to events
// Add photo counts to events and convert dates
const eventsWithCounts = events.map(event => ({
...event,
photo_count: photoCountMap[event.id] || 0
photo_count: photoCountMap[event.id] || 0,
// Convert Unix timestamps to ISO strings
created_at: event.created_at ? new Date(event.created_at).toISOString() : null,
expires_at: event.expires_at ? new Date(event.expires_at).toISOString() : null,
archived_at: event.archived_at ? new Date(event.archived_at).toISOString() : null
}));
res.json({