Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(uxd): add init/edit/mint/redeem itxs #162

Merged
merged 18 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 58 additions & 39 deletions components/ProposalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import styled from '@emotion/styled'
import { ChevronRightIcon } from '@heroicons/react/solid'
import ProposalStateBadge from './ProposalStateBadge'
import Link from 'next/link'
import { GovernanceAccountType, Proposal, ProposalState, VoteType } from '@solana/spl-governance'
import {
GovernanceAccountType,
Proposal,
ProposalState,
VoteType,
} from '@solana/spl-governance'
import { ApprovalProgress, VetoProgress } from './QuorumProgress'
import useRealm from '../hooks/useRealm'
import useProposalVotes from '../hooks/useProposalVotes'
Expand All @@ -17,6 +22,7 @@ import MultiChoiceVotes from './MultiChoiceVotes'
type ProposalCardProps = {
proposalPk: PublicKey
proposal: Proposal
unrelinquishedVote?: boolean
}

const StyledSvg = styled(ChevronRightIcon)``
Expand All @@ -29,12 +35,17 @@ const StyledCardWrapper = styled.div`
}
`

const ProposalCard = ({ proposalPk, proposal }: ProposalCardProps) => {
const ProposalCard = ({
proposalPk,
proposal,
unrelinquishedVote,
}: ProposalCardProps) => {
const { symbol } = useRealm()
const { fmtUrlWithCluster } = useQueryContext()
const votesData = useProposalVotes(proposal)
const isMulti = proposal.voteType !== VoteType.SINGLE_CHOICE
&& proposal.accountType === GovernanceAccountType.ProposalV2
const isMulti =
proposal.voteType !== VoteType.SINGLE_CHOICE &&
proposal.accountType === GovernanceAccountType.ProposalV2

return (
<div>
Expand All @@ -59,44 +70,52 @@ const ProposalCard = ({ proposalPk, proposal }: ProposalCardProps) => {
<StyledSvg className="default-transition h-6 ml-3 text-fgd-2 w-6" />
</div>
</div>
<ProposalTimeStatus proposal={proposal} />
</div>
{proposal.state === ProposalState.Voting ?
isMulti ?
<div className="pb-4 px-6">
<MultiChoiceVotes proposal={proposal} limit={3}/>
<div>
<ProposalTimeStatus proposal={proposal} />
</div>
:
(<div className="border-t border-fgd-4 flex flex-col lg:flex-row mt-2 p-4 gap-x-4 gap-y-3">
<div className="w-full lg:w-auto flex-1">
<VoteResults isListView proposal={proposal} />
</div>
<div className="border-r border-fgd-4 hidden lg:block" />
<div className="w-full lg:w-auto flex-1">
<ApprovalProgress
progress={votesData.yesVoteProgress}
votesRequired={votesData.yesVotesRequired}
/>
<div className="text-fgd-3 text-sm mt-4">
{unrelinquishedVote ? '** Vote not relinquished **' : null}
</div>
</div>
{proposal.state === ProposalState.Voting ? (
isMulti ? (
<div className="pb-4 px-6">
<MultiChoiceVotes proposal={proposal} limit={3} />
</div>
{votesData._programVersion !== undefined &&
// @asktree: here is some typescript gore because typescript doesn't know that a number being > 3 means it isn't 1 or 2
votesData._programVersion !== 1 &&
votesData._programVersion !== 2 &&
votesData.veto !== undefined &&
(votesData.veto.voteProgress ?? 0) > 0 ? (
<>
<div className="border-r border-fgd-4 hidden lg:block" />
) : (
<div className="border-t border-fgd-4 flex flex-col lg:flex-row mt-2 p-4 gap-x-4 gap-y-3">
<div className="w-full lg:w-auto flex-1">
<VoteResults isListView proposal={proposal} />
</div>
<div className="border-r border-fgd-4 hidden lg:block" />
<div className="w-full lg:w-auto flex-1">
<ApprovalProgress
progress={votesData.yesVoteProgress}
votesRequired={votesData.yesVotesRequired}
/>
</div>
{votesData._programVersion !== undefined &&
// @asktree: here is some typescript gore because typescript doesn't know that a number being > 3 means it isn't 1 or 2
votesData._programVersion !== 1 &&
votesData._programVersion !== 2 &&
votesData.veto !== undefined &&
(votesData.veto.voteProgress ?? 0) > 0 ? (
<>
<div className="border-r border-fgd-4 hidden lg:block" />

<div className="w-full lg:w-auto flex-1">
<VetoProgress
progress={votesData.veto.voteProgress}
votesRequired={votesData.veto.votesRequired}
/>
</div>
</>
) : undefined}
</div>)
: ""}
<div className="w-full lg:w-auto flex-1">
<VetoProgress
progress={votesData.veto.voteProgress}
votesRequired={votesData.veto.votesRequired}
/>
</div>
</>
) : undefined}
</div>
)
) : (
''
)}
</StyledCardWrapper>
</a>
</Link>
Expand Down
Loading
Loading