Bug fixes and improvements #14

Merged
Michilis merged 4 commits from dev into main 2026-03-07 22:53:13 +00:00
3 changed files with 14 additions and 2 deletions
Showing only changes of commit 596ec71191 - Show all commits

View File

@@ -200,8 +200,15 @@ siteSettingsRouter.put('/featured-event', requireAuth(['admin']), zValidator('js
if (event.status !== 'published') { if (event.status !== 'published') {
return c.json({ error: 'Event must be published to be featured' }, 400); return c.json({ error: 'Event must be published to be featured' }, 400);
} }
const eventEndTime = event.endDatetime || event.startDatetime;
if (new Date(eventEndTime).getTime() <= Date.now()) {
return c.json(
{ error: 'Cannot feature an event that has already ended' },
400
);
}
} }
// Get or create settings // Get or create settings
const existing = await dbGet<any>( const existing = await dbGet<any>(
(db as any).select().from(siteSettings).limit(1) (db as any).select().from(siteSettings).limit(1)

View File

@@ -25,6 +25,9 @@ NEXT_PUBLIC_TIKTOK=spanglishsocialpy
# Must match the REVALIDATE_SECRET in backend/.env # Must match the REVALIDATE_SECRET in backend/.env
REVALIDATE_SECRET=change-me-to-a-random-secret REVALIDATE_SECRET=change-me-to-a-random-secret
# Next event cache revalidation (seconds) - homepage metadata/social preview refresh interval. Default: 3600
NEXT_EVENT_REVALIDATE_SECONDS=3600
# Plausible Analytics (optional - leave empty to disable tracking) # Plausible Analytics (optional - leave empty to disable tracking)
NEXT_PUBLIC_PLAUSIBLE_URL=https://analytics.azzamo.net NEXT_PUBLIC_PLAUSIBLE_URL=https://analytics.azzamo.net
NEXT_PUBLIC_PLAUSIBLE_DOMAIN=spanglishcommunity.com NEXT_PUBLIC_PLAUSIBLE_DOMAIN=spanglishcommunity.com

View File

@@ -38,8 +38,10 @@ interface NextEvent {
async function getNextUpcomingEvent(): Promise<NextEvent | null> { async function getNextUpcomingEvent(): Promise<NextEvent | null> {
try { try {
const revalidateSeconds =
parseInt(process.env.NEXT_EVENT_REVALIDATE_SECONDS || '3600', 10) || 3600;
const response = await fetch(`${apiUrl}/api/events/next/upcoming`, { const response = await fetch(`${apiUrl}/api/events/next/upcoming`, {
next: { tags: ['next-event'] }, next: { tags: ['next-event'], revalidate: revalidateSeconds },
}); });
if (!response.ok) return null; if (!response.ok) return null;
const data = await response.json(); const data = await response.json();