Skip to content

Commit

Permalink
always show deposit options in vanilla
Browse files Browse the repository at this point in the history
  • Loading branch information
asktree committed Nov 8, 2023
1 parent 6fb7627 commit c853106
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
27 changes: 26 additions & 1 deletion components/GovernancePower/GovernancePowerCard.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { ChevronRightIcon } from '@heroicons/react/solid'
import { useGovernancePowerAsync } from '@hooks/queries/governancePower'
import {
determineVotingPowerType,
useGovernancePowerAsync,
} from '@hooks/queries/governancePower'
import { useRealmConfigQuery } from '@hooks/queries/realmConfig'
import useSelectedRealmPubkey from '@hooks/selectedRealm/useSelectedRealmPubkey'
import useQueryContext from '@hooks/useQueryContext'
import useWalletOnePointOh from '@hooks/useWalletOnePointOh'
import { GoverningTokenType } from '@solana/spl-governance'
import { useConnection } from '@solana/wallet-adapter-react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useAsync } from 'react-async-hook'
import GovernancePowerForRole from './GovernancePowerForRole'
import { Deposit } from './Vanilla/Deposit'

const GovernancePowerTitle = () => {
const { symbol } = useRouter().query
Expand All @@ -30,6 +37,20 @@ const GovernancePowerTitle = () => {
)
}

// TODO: refactor deposit components to their own generic DepositForRole component
const VanillaDeposit = ({ role }: { role: 'community' | 'council' }) => {
const { connection } = useConnection()

const realmPk = useSelectedRealmPubkey()

const { result: kind } = useAsync(async () => {
if (realmPk === undefined) return undefined
return determineVotingPowerType(connection, realmPk, role)
}, [connection, realmPk, role])

return kind === 'vanilla' ? <Deposit role={role} /> : <></>
}

const GovernancePowerCard = () => {
const connected = useWalletOnePointOh()?.connected ?? false

Expand Down Expand Up @@ -61,6 +82,10 @@ const GovernancePowerCard = () => {
) : bothZero ? (
<div className={'text-xs text-white/50 mt-8'}>
You do not have any governance power in this dao
<div className="flex flex-col">
<VanillaDeposit role="community" />
<VanillaDeposit role="council" />
</div>
</div>
) : (
<div className="flex flex-col gap-2">
Expand Down
11 changes: 6 additions & 5 deletions components/GovernancePower/GovernancePowerForRole.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default function GovernancePowerForRole({

const { result: kind } = useAsync(async () => {
if (realmPk === undefined) return undefined

return determineVotingPowerType(connection, realmPk, role)
}, [connection, realmPk, role])

Expand All @@ -40,9 +39,10 @@ export default function GovernancePowerForRole({
<>
{role === 'community' ? (
kind === 'vanilla' ? (
<VanillaVotingPower role="community" {...props}>
<div>
<VanillaVotingPower role="community" {...props} />
<Deposit role="community" />
</VanillaVotingPower>
</div>
) : kind === 'VSR' ? (
<LockedCommunityVotingPower />
) : kind === 'NFT' ? (
Expand All @@ -51,9 +51,10 @@ export default function GovernancePowerForRole({
<LockedCommunityNFTRecordVotingPower />
) : null
) : kind === 'vanilla' ? (
<VanillaVotingPower role="council" {...props}>
<div>
<VanillaVotingPower role="council" {...props} />
<Deposit role="council" />
</VanillaVotingPower>
</div>
) : null}
</>
)
Expand Down

0 comments on commit c853106

Please sign in to comment.