Skip to content

Commit

Permalink
feat: add proposal final tally table
Browse files Browse the repository at this point in the history
  • Loading branch information
wgwz committed Jul 25, 2023
1 parent bf9a8b5 commit 03764d4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/components/organisms/proposal-final-tally-table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { TallyResult } from '@regen-network/api/types/codegen/cosmos/group/v1/types'

import { Table, TableContainer, Tbody, Td, Th, Thead, Tr } from '@/atoms'
import { TableTitlebar } from '@/molecules/table-titlebar'

export const ProposalFinalTallyTable = ({
finalTallyResult,
}: {
finalTallyResult: TallyResult
}) => {
return (
<TableContainer>
<TableTitlebar title="Finally Tally Results" />
<Table variant="striped" size="lg">
<Thead>
<Tr>
<Th>Yes</Th>
<Th>No</Th>
<Th>Abstain</Th>
<Th>No with veto</Th>
</Tr>
</Thead>
<Tbody>
<Tr>
<Td>{finalTallyResult.yesCount}</Td>
<Td>{finalTallyResult.noCount}</Td>
<Td>{finalTallyResult.abstainCount}</Td>
<Td>{finalTallyResult.noWithVetoCount}</Td>
</Tr>
</Tbody>
</Table>
</TableContainer>
)
}
7 changes: 6 additions & 1 deletion src/hooks/use-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ export function useHistoricalProposal(proposalId?: string) {
groupVersion: proposal.groupVersion,
groupPolicyVersion: proposal.groupPolicyVersion,
status: ProposalStatus[proposal.status as keyof typeof ProposalStatus],
finalTallyResult: proposal.finalTallyResult,
finalTallyResult: {
yesCount: proposal.finalTallyResult.yes_count,
noCount: proposal.finalTallyResult.no_count,
abstainCount: proposal.finalTallyResult.abstain_count,
noWithVetoCount: proposal.finalTallyResult.no_with_veto_count,
},
messages: proposal.messages,
submitTime: proposal.submitTime,
votingPeriodEnd: proposal.votingPeriodEnd,
Expand Down
4 changes: 4 additions & 0 deletions src/pages/proposal-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useTxToasts } from 'hooks/use-toasts'
import { Button, PageContainer, RouteLink, Stack } from '@/atoms'
import { Loading } from '@/molecules/loading'
import { ProposalDetails } from '@/organisms/proposal-details'
import { ProposalFinalTallyTable } from '@/organisms/proposal-final-tally-table'
import { ProposalSummary } from '@/organisms/proposal-summary'
import { ProposalVotesTable } from '@/organisms/proposal-votes-table'

Expand Down Expand Up @@ -59,6 +60,8 @@ export default function ProposalPage() {
!isLoadingGroup &&
!isLoadingHistoricalProposal
) {
const { finalTallyResult } = historicalProposal
console.log({ finalTallyResult })
return (
<PageContainer>
<Stack w="full" spacing={6}>
Expand All @@ -78,6 +81,7 @@ export default function ProposalPage() {
group={group}
/>
<ProposalDetails proposal={historicalProposal} />
<ProposalFinalTallyTable finalTallyResult={finalTallyResult} />
</Stack>
</PageContainer>
)
Expand Down

0 comments on commit 03764d4

Please sign in to comment.