Skip to content

Commit

Permalink
fix: vote index typecast
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 committed Mar 11, 2024
1 parent e6496e5 commit a57a70a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions app/components/PollVotes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ export const PollVotes = ({ poll }: { poll: HMSPoll }) => {
const hasVoted = question?.responses?.some((response) => response.peer.peerid === localPeerId)

const [selectedOptionIndex, setSelectedOptionIndex] = useState<number | undefined>()
const [loading, setLoading] = useState(false)

function handleChange(event: any) {
setSelectedOptionIndex(event.target.value)
}

useEffect(() => {
const newVoteCount = question.options.map(() => 0)
Expand Down Expand Up @@ -56,8 +51,8 @@ export const PollVotes = ({ poll }: { poll: HMSPoll }) => {
style={{ cursor: 'pointer' }}
type="radio"
value={index}
checked={Number(selectedOptionIndex) === index}
onChange={handleChange}
checked={selectedOptionIndex === index}
onChange={() => setSelectedOptionIndex(index)}
id={'' + index}
/>
)}
Expand Down Expand Up @@ -111,7 +106,7 @@ export const PollVotes = ({ poll }: { poll: HMSPoll }) => {
.addResponsesToPoll(poll.id, [
{
questionIndex: poll.questions[0].index,
option: Number(selectedOptionIndex + 1),
option: selectedOptionIndex + 1,
},
])
.then(() => toast(`Your vote has been submitted for "${question.text}`))
Expand Down

0 comments on commit a57a70a

Please sign in to comment.