From b206b0a689dc62dab5bdfbbd3eb49ee6b9b1a0fd Mon Sep 17 00:00:00 2001 From: agrippa Date: Fri, 29 Sep 2023 16:10:34 -0400 Subject: [PATCH] fix nft govpower card (#1841) --- .../ProposalVotingPower/NftVotingPower.tsx | 74 ++++++++----------- .../TokenBalance/TokenBalanceCardWrapper.tsx | 44 +++-------- components/TokenBalance/TokenDeposit.tsx | 25 +------ 3 files changed, 43 insertions(+), 100 deletions(-) diff --git a/components/ProposalVotingPower/NftVotingPower.tsx b/components/ProposalVotingPower/NftVotingPower.tsx index 07ca792403..80d8dfadae 100644 --- a/components/ProposalVotingPower/NftVotingPower.tsx +++ b/components/ProposalVotingPower/NftVotingPower.tsx @@ -104,57 +104,43 @@ export default function NftVotingPower(props: Props) { if (nfts.length === 0) { return ( - -
- You do not have any voting power in this dao. -
-
+
+ You do not have any voting power in this dao. +
) } return ( - -
-
-
My NFT Votes
-
-
- {displayNfts.slice(0, 3).map((nft, index) => ( -
- ))} - {!!remainingCount && ( -
- +{remainingCount} more -
- )} -
- {max && !max.isZero() && ( - +
+
+
My NFT Votes
+
+
+ {displayNfts.slice(0, 3).map((nft, index) => ( +
+ ))} + {!!remainingCount && ( +
+ +{remainingCount} more +
)}
+ {max && !max.isZero() && ( + + )}
- {connected && !ownTokenRecord && ( - - )}
- + {connected && !ownTokenRecord && ( + + )} +
) } - -const Wrapper = (props: Props) => { - if (props.inAccountDetails) { - return
{props.children}
- } else { - return <>{props.children} - } -} diff --git a/components/TokenBalance/TokenBalanceCardWrapper.tsx b/components/TokenBalance/TokenBalanceCardWrapper.tsx index e9e35a3058..c34a674772 100644 --- a/components/TokenBalance/TokenBalanceCardWrapper.tsx +++ b/components/TokenBalance/TokenBalanceCardWrapper.tsx @@ -8,10 +8,7 @@ import ClaimUnreleasedNFTs from './ClaimUnreleasedNFTs' import Link from 'next/link' import { useAddressQuery_CommunityTokenOwner } from '@hooks/queries/addresses/tokenOwnerRecord' import useWalletOnePointOh from '@hooks/useWalletOnePointOh' -import { - useUserCommunityTokenOwnerRecord, - useUserCouncilTokenOwnerRecord, -} from '@hooks/queries/tokenOwnerRecord' +import { useUserCommunityTokenOwnerRecord } from '@hooks/queries/tokenOwnerRecord' import { useRealmConfigQuery } from '@hooks/queries/realmConfig' import ClaimUnreleasedPositions from 'HeliumVotePlugin/components/ClaimUnreleasedPositions' import VanillaAccountDetails from './VanillaAccountDetails' @@ -68,10 +65,9 @@ const TokenBalanceCardInner = ({ inAccountDetails?: boolean }) => { const ownTokenRecord = useUserCommunityTokenOwnerRecord().data?.result - const ownCouncilTokenRecord = useUserCouncilTokenOwnerRecord().data?.result const config = useRealmConfigQuery().data?.result - const { councilTokenAccount, vsrMode } = useRealm() + const { vsrMode } = useRealm() const currentPluginPk = config?.account?.communityTokenConfig.voterWeightAddin const isNftMode = currentPluginPk && NFT_PLUGINS_PKS.includes(currentPluginPk?.toBase58()) @@ -100,35 +96,15 @@ const TokenBalanceCardInner = ({ ) } - if ( - isNftMode && - (!ownTokenRecord || - ownTokenRecord.account.governingTokenDepositAmount.isZero()) - ) { + if (isNftMode && inAccountDetails) { return ( - <> - {(ownCouncilTokenRecord && - !ownCouncilTokenRecord?.account.governingTokenDepositAmount.isZero()) || - (councilTokenAccount && - !councilTokenAccount?.account.amount.isZero()) ? ( - <> - {!inAccountDetails && } - - {inAccountDetails ? ( - - ) : ( - - )} - - - ) : ( - <> - {!inAccountDetails && } - - - - )} - +
+
+ + +
+ +
) } diff --git a/components/TokenBalance/TokenDeposit.tsx b/components/TokenBalance/TokenDeposit.tsx index 8b4af9f79c..0bf0f3b283 100644 --- a/components/TokenBalance/TokenDeposit.tsx +++ b/components/TokenBalance/TokenDeposit.tsx @@ -303,15 +303,9 @@ export const TokenDeposit = ({ } return ( - - {inAccountDetails && ( -

- {tokenRole === GoverningTokenRole.Community ? `Community` : `Council`} -

- )} - +
{(availableTokens != '0' || inAccountDetails) && ( -
+
{tokenRole === GoverningTokenRole.Community ? ( ) : ( @@ -378,19 +372,6 @@ export const TokenDeposit = ({ Please withdraw your tokens and deposit again to get governance power )} - +
) } -const TokenDepositWrapper = ({ - children, - inAccountDetails, -}: { - inAccountDetails?: boolean - children: React.ReactNode -}) => { - if (inAccountDetails) { - return
{children}
- } else { - return
{children}
- } -}