diff --git a/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx b/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx index 9dec43e56..63bb4c579 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx @@ -34,14 +34,14 @@ export const DelegateDashboardCard = ({ currentDelegation, delegateTx, dRepID, - voter, votingPower, }: DelegateDashboardCardProps) => { const navigate = useNavigate(); const { t } = useTranslation(); + const { dRepData, isDRepListFetching } = useGetDRepListInfiniteQuery( { - searchPhrase: currentDelegation?.dRepHash ?? delegateTx?.resourceId ?? "", + searchPhrase: delegateTx?.resourceId ?? currentDelegation?.dRepHash ?? "", }, { enabled: !!currentDelegation?.dRepHash || !!delegateTx?.resourceId, @@ -73,10 +73,7 @@ export const DelegateDashboardCard = ({ const cardProps: Partial = (() => { // transaction in progress - if ( - delegateTx && - (!(delegateTx?.resourceId === dRepID) || voter?.isRegisteredAsDRep) - ) { + if (delegateTx && delegateTx?.resourceId !== dRepID) { return { buttons: [learnMoreButton], description: getProgressDescription(delegateTx?.resourceId, ada), @@ -87,8 +84,9 @@ export const DelegateDashboardCard = ({ // current delegation if ( + !delegateTx && currentDelegation && - (!(currentDelegation?.dRepHash === dRepID) || voter?.isRegisteredAsDRep) + currentDelegation?.dRepHash !== dRepID ) { return { buttons: currentDelegation?.dRepView @@ -141,36 +139,38 @@ export const DelegateDashboardCard = ({ imageURL={IMAGES.govActionDelegateImage} isSpaceBetweenButtons={ !!currentDelegation?.dRepView && - (!(currentDelegation?.dRepHash === dRepID) || voter?.isRegisteredAsDRep) + !(currentDelegation?.dRepHash === dRepID) } transactionId={ - !(currentDelegation?.dRepHash === dRepID) || - voter?.isRegisteredAsDRep || - !voter?.isRegisteredAsSoleVoter + (delegateTx && delegateTx?.resourceId !== dRepID) || + (!delegateTx && + currentDelegation && + currentDelegation?.dRepHash !== dRepID) ? delegateTx?.transactionHash ?? currentDelegation?.txHash : undefined } {...cardProps} > {displayedDelegationId && - (!(currentDelegation?.dRepHash === dRepID) || - voter?.isRegisteredAsDRep || - !voter?.isRegisteredAsSoleVoter) && ( - - )} + ((delegateTx && delegateTx?.resourceId !== dRepID) || + (!delegateTx && + currentDelegation && + currentDelegation?.dRepHash !== dRepID)) ? ( + + ) : null} ); }; diff --git a/govtool/frontend/src/context/pendingTransaction/utils.tsx b/govtool/frontend/src/context/pendingTransaction/utils.tsx index 719e5c9d5..ffa97b22a 100644 --- a/govtool/frontend/src/context/pendingTransaction/utils.tsx +++ b/govtool/frontend/src/context/pendingTransaction/utils.tsx @@ -72,7 +72,7 @@ export const refetchData = async ( ) { return data.dRepView; } - return data.dRepView; + return data.dRepHash; } if (type === "registerAsDrep" || type === "retireAsDrep") return data.isRegisteredAsDRep; diff --git a/govtool/frontend/src/pages/DRepDetails.tsx b/govtool/frontend/src/pages/DRepDetails.tsx index 2b86e5195..45fd047bc 100644 --- a/govtool/frontend/src/pages/DRepDetails.tsx +++ b/govtool/frontend/src/pages/DRepDetails.tsx @@ -288,7 +288,7 @@ export const DRepDetails = ({ isConnected }: DRepDetailsProps) => { isLoading={ isDelegating === dRep.view || isDelegating === dRep.drepId } - onClick={() => delegate(dRep.view)} + onClick={() => delegate(dRep.drepId)} size="extraLarge" sx={{ width: "100%" }} variant="contained" diff --git a/govtool/frontend/src/pages/DRepDirectoryContent.tsx b/govtool/frontend/src/pages/DRepDirectoryContent.tsx index 644f7c4b9..2c9a676d0 100644 --- a/govtool/frontend/src/pages/DRepDirectoryContent.tsx +++ b/govtool/frontend/src/pages/DRepDirectoryContent.tsx @@ -10,7 +10,6 @@ import { useGetAdaHolderCurrentDelegationQuery, useGetAdaHolderVotingPowerQuery, useGetDRepListInfiniteQuery, - useGetVoterInfo, } from "@hooks"; import { DataActionsBar, EmptyStateDrepDirectory } from "@molecules"; import { AutomatedVotingOptions, DRepCard } from "@organisms"; @@ -49,7 +48,6 @@ export const DRepDirectoryContent: FC = ({ const { delegate, isDelegating } = useDelegateTodRep(); - const { voter } = useGetVoterInfo(); const { votingPower } = useGetAdaHolderVotingPowerQuery(stakeKey); const { currentDelegation } = useGetAdaHolderCurrentDelegationQuery(stakeKey); const inProgressDelegation = pendingTransaction.delegate?.resourceId; @@ -106,6 +104,7 @@ export const DRepDirectoryContent: FC = ({ const dRepListToDisplay = yourselfDRep ? [yourselfDRep, ...dRepsWithoutYourself] : dRepList; + const inProgressDelegationDRepData = dRepListToDisplay.find( (dRep) => dRep.drepId === inProgressDelegation || @@ -124,8 +123,8 @@ export const DRepDirectoryContent: FC = ({ {/* My delegation */} {myDrep && !inProgressDelegation && - (!(currentDelegation?.dRepHash === myDRepId) || - voter?.isRegisteredAsDRep) && ( + currentDelegation && + currentDelegation?.dRepHash !== myDRepId && (
@@ -138,14 +137,16 @@ export const DRepDirectoryContent: FC = ({ />
)} - {inProgressDelegation && inProgressDelegationDRepData && ( - - )} + {inProgressDelegation && + inProgressDelegation !== myDRepId && + inProgressDelegationDRepData && ( + + )} {/* Automated voting options */} {isConnected && ( @@ -223,7 +224,7 @@ export const DRepDirectoryContent: FC = ({ isDelegating === dRep.view || isDelegating === dRep.drepId } isMe={isSameDRep(dRep, myDRepId)} - onDelegate={() => delegate(dRep.view)} + onDelegate={() => delegate(dRep.drepId)} /> );