From ae9e4c504e17404420d6f081a282c1e12472452c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=B6rdle=20Bot?= Date: Sat, 22 Nov 2025 16:38:15 +0100 Subject: [PATCH] Add Song of the Day filter and badges to Admin Song Library --- app/admin/page.tsx | 49 ++++++++++++++++++++++++++++++++++++++++-- app/api/songs/route.ts | 1 + 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/app/admin/page.tsx b/app/admin/page.tsx index 9831d65..2a45219 100644 --- a/app/admin/page.tsx +++ b/app/admin/page.tsx @@ -21,6 +21,14 @@ interface Genre { }; } +interface DailyPuzzle { + id: number; + date: string; + songId: number; + genreId: number | null; + specialId: number | null; +} + interface Song { id: number; title: string; @@ -28,6 +36,7 @@ interface Song { filename: string; createdAt: string; activations: number; + puzzles: DailyPuzzle[]; genres: Genre[]; specials: Special[]; } @@ -535,6 +544,9 @@ export default function AdminPage() { } else if (selectedGenreFilter.startsWith('special:')) { const specialId = Number(selectedGenreFilter.split(':')[1]); matchesFilter = song.specials?.some(s => s.id === specialId) || false; + } else if (selectedGenreFilter === 'daily') { + const today = new Date().toISOString().split('T')[0]; + matchesFilter = song.puzzles?.some(p => p.date === today) || false; } } @@ -863,6 +875,7 @@ export default function AdminPage() { style={{ minWidth: '150px' }} > + {genres.map(genre => ( @@ -1020,8 +1033,40 @@ export default function AdminPage() { ) : ( <> - {song.title} - {song.artist} + +
{song.title}
+
{song.artist}
+ + {/* Daily Puzzle Badges */} +
+ {song.puzzles?.filter(p => p.date === new Date().toISOString().split('T')[0]).map(p => { + if (!p.genreId && !p.specialId) { + return ( + + 🌍 Global Daily + + ); + } + if (p.genreId) { + const genreName = genres.find(g => g.id === p.genreId)?.name; + return ( + + 🏷️ {genreName} Daily + + ); + } + if (p.specialId) { + const specialName = specials.find(s => s.id === p.specialId)?.name; + return ( + + ★ {specialName} Daily + + ); + } + return null; + })} +
+
{song.genres?.map(g => ( diff --git a/app/api/songs/route.ts b/app/api/songs/route.ts index 555cdf5..356998d 100644 --- a/app/api/songs/route.ts +++ b/app/api/songs/route.ts @@ -25,6 +25,7 @@ export async function GET() { createdAt: song.createdAt, coverImage: song.coverImage, activations: song.puzzles.length, + puzzles: song.puzzles, genres: song.genres, specials: song.specials, }));