feat: Add sorting by activations and average rating to admin page and include bonus star in game share text.
This commit is contained in:
@@ -51,7 +51,7 @@ interface Song {
|
|||||||
excludeFromGlobal: boolean;
|
excludeFromGlobal: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type SortField = 'id' | 'title' | 'artist' | 'createdAt' | 'releaseYear';
|
type SortField = 'id' | 'title' | 'artist' | 'createdAt' | 'releaseYear' | 'activations' | 'averageRating';
|
||||||
type SortDirection = 'asc' | 'desc';
|
type SortDirection = 'asc' | 'desc';
|
||||||
|
|
||||||
export default function AdminPage() {
|
export default function AdminPage() {
|
||||||
@@ -824,7 +824,7 @@ export default function AdminPage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const sortedSongs = [...filteredSongs].sort((a, b) => {
|
const sortedSongs = [...filteredSongs].sort((a, b) => {
|
||||||
// Handle numeric sorting for ID and Release Year
|
// Handle numeric sorting for ID, Release Year, Activations, and Rating
|
||||||
if (sortField === 'id') {
|
if (sortField === 'id') {
|
||||||
return sortDirection === 'asc' ? a.id - b.id : b.id - a.id;
|
return sortDirection === 'asc' ? a.id - b.id : b.id - a.id;
|
||||||
}
|
}
|
||||||
@@ -833,6 +833,12 @@ export default function AdminPage() {
|
|||||||
const yearB = b.releaseYear || 0;
|
const yearB = b.releaseYear || 0;
|
||||||
return sortDirection === 'asc' ? yearA - yearB : yearB - yearA;
|
return sortDirection === 'asc' ? yearA - yearB : yearB - yearA;
|
||||||
}
|
}
|
||||||
|
if (sortField === 'activations') {
|
||||||
|
return sortDirection === 'asc' ? a.activations - b.activations : b.activations - a.activations;
|
||||||
|
}
|
||||||
|
if (sortField === 'averageRating') {
|
||||||
|
return sortDirection === 'asc' ? a.averageRating - b.averageRating : b.averageRating - a.averageRating;
|
||||||
|
}
|
||||||
|
|
||||||
// String sorting for other fields
|
// String sorting for other fields
|
||||||
const valA = String(a[sortField]).toLowerCase();
|
const valA = String(a[sortField]).toLowerCase();
|
||||||
@@ -1414,8 +1420,18 @@ export default function AdminPage() {
|
|||||||
>
|
>
|
||||||
Added {sortField === 'createdAt' && (sortDirection === 'asc' ? '↑' : '↓')}
|
Added {sortField === 'createdAt' && (sortDirection === 'asc' ? '↑' : '↓')}
|
||||||
</th>
|
</th>
|
||||||
<th style={{ padding: '0.75rem' }}>Activations</th>
|
<th
|
||||||
<th style={{ padding: '0.75rem' }}>Rating</th>
|
style={{ padding: '0.75rem', cursor: 'pointer', userSelect: 'none' }}
|
||||||
|
onClick={() => handleSort('activations')}
|
||||||
|
>
|
||||||
|
Activations {sortField === 'activations' && (sortDirection === 'asc' ? '↑' : '↓')}
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
style={{ padding: '0.75rem', cursor: 'pointer', userSelect: 'none' }}
|
||||||
|
onClick={() => handleSort('averageRating')}
|
||||||
|
>
|
||||||
|
Rating {sortField === 'averageRating' && (sortDirection === 'asc' ? '↑' : '↓')}
|
||||||
|
</th>
|
||||||
<th style={{ padding: '0.75rem' }}>Actions</th>
|
<th style={{ padding: '0.75rem' }}>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max
|
|||||||
}
|
}
|
||||||
|
|
||||||
const speaker = hasWon ? '🔉' : '🔇';
|
const speaker = hasWon ? '🔉' : '🔇';
|
||||||
|
const bonusStar = (hasWon && gameState.yearGuessed && dailyPuzzle.releaseYear && gameState.scoreBreakdown.some(item => item.reason === 'Bonus: Correct Year')) ? '⭐' : '';
|
||||||
const genreText = genre ? `Genre: ${genre}\n` : '';
|
const genreText = genre ? `Genre: ${genre}\n` : '';
|
||||||
|
|
||||||
let shareUrl = 'https://hoerdle.elpatron.me';
|
let shareUrl = 'https://hoerdle.elpatron.me';
|
||||||
@@ -184,7 +185,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = `Hördle #${dailyPuzzle.puzzleNumber}\n${genreText}\n${speaker}${emojiGrid}\nScore: ${gameState.score}\n\n#Hördle #Music\n\n${shareUrl}`;
|
const text = `Hördle #${dailyPuzzle.puzzleNumber}\n${genreText}\n${speaker}${emojiGrid}${bonusStar}\nScore: ${gameState.score}\n\n#Hördle #Music\n\n${shareUrl}`;
|
||||||
|
|
||||||
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user