Skip to content

Commit

Permalink
fix: fix voteable states
Browse files Browse the repository at this point in the history
  • Loading branch information
mymphe authored and folkyatina committed Jun 28, 2022
1 parent 814c109 commit 3e47466
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions apps/voting/app/src/hooks/useVotePhase.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ import useNow from './useNow'
export const useVotePhase = vote => {
const now = useNow()

const { open, objectionPhaseStartDate, endDate, executed } = vote.data
const { open, objectionPhaseStartDate, endDate } = vote.data

const isMainPhase = open && isBefore(now, objectionPhaseStartDate)
const isObjectionPhase =
isAfter(now, objectionPhaseStartDate) && isBefore(now, endDate)
const voteOver = !open || (open && !executed)

const canVoteYes = open && !isObjectionPhase
const canVoteNo = open
const canVoteYes = isMainPhase
const canVoteNo = isMainPhase || isObjectionPhase

return {
isMainPhase,
isObjectionPhase,
canVoteYes,
canVoteNo,
voteOver,
}
}

0 comments on commit 3e47466

Please sign in to comment.