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:
@@ -77,8 +77,8 @@ router.post('/', adminAuth, [
|
|||||||
welcome_message,
|
welcome_message,
|
||||||
color_theme,
|
color_theme,
|
||||||
share_link: shareLink,
|
share_link: shareLink,
|
||||||
expires_at,
|
expires_at: expires_at.toISOString(),
|
||||||
created_at: new Date()
|
created_at: new Date().toISOString()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Log activity
|
// Log activity
|
||||||
@@ -180,10 +180,14 @@ router.get('/', adminAuth, async (req, res) => {
|
|||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
// Add photo counts to events
|
// Add photo counts to events and convert dates
|
||||||
const eventsWithCounts = events.map(event => ({
|
const eventsWithCounts = events.map(event => ({
|
||||||
...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({
|
res.json({
|
||||||
|
|||||||
Reference in New Issue
Block a user