Skip to content

Commit

Permalink
check log alreadyVoted in polls
Browse files Browse the repository at this point in the history
  • Loading branch information
ebedoise committed Aug 1, 2024
1 parent 4075b84 commit 9342e22
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/poll/src/Choices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const Choices = () => {

const handleVote = async (choiceId: string) => {
console.log('alreadyVoted: ', alreadyVoted);
console.log('address: ', address);
if (alreadyVoted) {
toast({
title: 'You have already voted',
Expand All @@ -59,6 +60,15 @@ export const Choices = () => {
return;
}

if (!address) {
toast({
title: 'Connect your wallet to vote',
status: 'warning',
duration: 2000,
});
return;
}

await vote({
variables: { choiceId, pollId: id, voters: [address] },
update: updateCacheAfterVote,
Expand Down

0 comments on commit 9342e22

Please sign in to comment.