Skip to content

Commit

Permalink
type errors as usual
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinta0 committed Aug 25, 2024
1 parent 2155f0d commit ca152d1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions components/GlyphGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,11 @@ const GlyphGenerator = () => {
</div>
);

const getUserVote = (item: GalleryItem, voteType: 'up' | 'down'): boolean => {
if (!userId || !item.votes || !item.votes.users) return false;
return item.votes.users[userId] === voteType;
};

const ImageCarousel = ({ images }: { images: string[] }) => {
const [emblaRef, emblaApi] = useEmblaCarousel({ loop: true });
const [currentIndex, setCurrentIndex] = useState(0);
Expand Down Expand Up @@ -707,14 +712,14 @@ const GlyphGenerator = () => {
<span className="mr-2">{item.votes?.count || 0}</span>
<Button
onClick={() => handleVote(item.id, 'up')}
className={`mr-1 ${item.votes?.users?.[userId] === 'up' ? 'bg-blue-500' : ''}`}
className={`mr-1 ${getUserVote(item, 'up') ? 'bg-blue-500' : ''}`}
disabled={item.creatorId === userId}
>
👍
</Button>
<Button
onClick={() => handleVote(item.id, 'down')}
className={`mr-1 ${item.votes?.users?.[userId] === 'down' ? 'bg-red-500' : ''}`}
className={`mr-1 ${getUserVote(item, 'down') ? 'bg-red-500' : ''}`}
disabled={item.creatorId === userId}
>
👎
Expand Down

0 comments on commit ca152d1

Please sign in to comment.