Skip to content

Commit

Permalink
Fix series rating stars, 3rd time's the charm (#990)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithmohan authored Aug 18, 2024
1 parent 7d65179 commit abbc933
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/Collection/Series/SeriesRating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const StarIcon = React.memo(({ handleHover, handleVote, hovered, index }: StarIc
const SeriesRating = ({ ratingValue, seriesId }: Props) => {
const { mutate: voteSeries } = useVoteSeriesMutation();

const [hoveredStar, setHoveredStar] = useState(ratingValue);
const [hoveredStar, setHoveredStar] = useState(ratingValue - 1);

const handleVote = useEventCallback((event: React.MouseEvent<HTMLDivElement>) => {
voteSeries({ seriesId, rating: toNumber(event.currentTarget.id) + 1 }, {
Expand All @@ -43,7 +43,7 @@ const SeriesRating = ({ ratingValue, seriesId }: Props) => {
});

const handleClear = useEventCallback(() => {
setHoveredStar(ratingValue);
setHoveredStar(ratingValue - 1);
});

const handleHover = useEventCallback((event: React.MouseEvent<HTMLDivElement>) => {
Expand All @@ -57,7 +57,7 @@ const SeriesRating = ({ ratingValue, seriesId }: Props) => {
// eslint-disable-next-line react/no-array-index-key
key={`star-${index}`}
index={index.toString()}
hovered={hoveredStar > index}
hovered={hoveredStar >= index}
handleHover={handleHover}
handleVote={handleVote}
/>
Expand Down

0 comments on commit abbc933

Please sign in to comment.