Skip to content

Commit

Permalink
fix: show final tally result table if voting period is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
wgwz committed Jul 31, 2023
1 parent 485220e commit c82b561
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/organisms/proposal-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ export const ProposalSummary = ({
proposal,
userVote,
votes,
votingClosed,
}: {
group: UIGroup
onVote?: (option: VoteOptionType) => void
proposal: UIProposal
userVote?: Vote
votes?: Vote[]
votingClosed?: boolean
}) => {
const cardBgDark = useColorModeValue('gray.100', 'gray.700')
const now = new Date()
const votingClosed = new Date(proposal.votingPeriodEnd || now).getTime() < now.getTime()
const proposalFinalized =
proposal.status.toString() === 'PROPOSAL_STATUS_ACCEPTED' ||
proposal.status.toString() === 'PROPOSAL_STATUS_REJECTED'
Expand Down
20 changes: 17 additions & 3 deletions src/pages/proposal-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ export default function ProposalPage() {
throwError('Group not found')
}

const now = new Date()
const votingClosed =
new Date(
isHistorical ? historicalProposal.votingPeriodEnd : proposal.votingPeriodEnd,
).getTime() < now.getTime()

return (
<PageContainer>
<Stack w="full" spacing={6}>
Expand All @@ -99,8 +105,11 @@ export default function ProposalPage() {
</div>
{isHistorical ? (
<>
<ProposalSummary proposal={historicalProposal} group={group} />
<ProposalDetails proposal={historicalProposal} />
<ProposalSummary
proposal={historicalProposal}
group={group}
votingClosed={votingClosed}
/>
<ProposalDetails proposal={historicalProposal} />
<ProposalFinalTallyTable
finalTallyResult={historicalProposal.finalTallyResult}
Expand All @@ -114,9 +123,14 @@ export default function ProposalPage() {
onVote={handleVote}
userVote={userVote}
votes={votes}
votingClosed={votingClosed}
/>
<ProposalDetails proposal={proposal} />
<ProposalVotesTable votes={votes || []} groupMembers={groupMembers || []} />
{votingClosed ? (
<ProposalFinalTallyTable finalTallyResult={proposal.finalTallyResult} />
) : (
<ProposalVotesTable votes={votes || []} groupMembers={groupMembers || []} />
)}
</>
)}
</Stack>
Expand Down

0 comments on commit c82b561

Please sign in to comment.