Skip to content

Commit

Permalink
fix: voting w/o selecting any option still sends a request (#21)
Browse files Browse the repository at this point in the history
fixes #20
  • Loading branch information
BamButz committed Oct 14, 2020
1 parent c522061 commit d281023
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pages/poll/[poll].js
Expand Up @@ -64,6 +64,12 @@ const PollPage = props => {
.map(option => props.options.indexOf(option.value))
} else {
body.selected = [new FormData(e.target).get('selected')]
.filter(item => item != null) // If nothing is selected a null value would be inserted
}

if (body.selected.length < 1) {
setToast('You have to select at least 1 option')
return;
}

setToast('Voting...')
Expand Down

1 comment on commit d281023

@vercel
Copy link

@vercel vercel bot commented on d281023 Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.