fix: improve rating UI label and notification context

This commit is contained in:
Hördle Bot
2025-11-23 10:42:20 +01:00
parent 4d3032df36
commit f13a719d0e
2 changed files with 25 additions and 15 deletions

View File

@@ -65,6 +65,17 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max
setLastAction(null);
}, [dailyPuzzle?.id]);
useEffect(() => {
if (dailyPuzzle) {
const ratedPuzzles = JSON.parse(localStorage.getItem('hoerdle_rated_puzzles') || '[]');
if (ratedPuzzles.includes(dailyPuzzle.id)) {
setHasRated(true);
} else {
setHasRated(false);
}
}
}, [dailyPuzzle]);
if (!dailyPuzzle) return (
<div className="game-container" style={{ textAlign: 'center', padding: '2rem' }}>
<h2>No Puzzle Available</h2>
@@ -181,22 +192,13 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max
}
};
useEffect(() => {
if (dailyPuzzle) {
const ratedPuzzles = JSON.parse(localStorage.getItem('hoerdle_rated_puzzles') || '[]');
if (ratedPuzzles.includes(dailyPuzzle.id)) {
setHasRated(true);
} else {
setHasRated(false);
}
}
}, [dailyPuzzle]);
const handleRatingSubmit = async (rating: number) => {
if (!dailyPuzzle) return;
try {
await submitRating(dailyPuzzle.songId, rating, genre);
await submitRating(dailyPuzzle.songId, rating, genre, isSpecial, dailyPuzzle.puzzleNumber);
setHasRated(true);
// Persist to localStorage
@@ -356,7 +358,7 @@ function StarRating({ onRate, hasRated }: { onRate: (rating: number) => void, ha
return (
<div className="star-rating" style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '0.5rem' }}>
<span style={{ fontSize: '0.875rem', color: '#666', fontWeight: '500' }}>Rate this song:</span>
<span style={{ fontSize: '0.875rem', color: '#666', fontWeight: '500' }}>Rate this puzzle:</span>
<div style={{ display: 'flex', gap: '0.25rem', justifyContent: 'center' }}>
{[...Array(5)].map((_, index) => {
const ratingValue = index + 1;