diff --git a/govtool/frontend/src/components/molecules/DelegationAction.tsx b/govtool/frontend/src/components/molecules/DelegationAction.tsx index 04fdbc2d4..2132a7bed 100644 --- a/govtool/frontend/src/components/molecules/DelegationAction.tsx +++ b/govtool/frontend/src/components/molecules/DelegationAction.tsx @@ -3,51 +3,47 @@ import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos"; import { Typography } from "@atoms"; import { gray } from "@consts"; -import { useTranslation } from "@hooks"; import { Card } from "./Card"; import { DirectVoterActionProps } from "./types"; export const DelegationAction = ({ dRepId, + drepName, onCardClick, sx, -}: DirectVoterActionProps) => { - const { t } = useTranslation(); - - return ( - theme.palette.neutralWhite, - borderColor: gray.c100, - display: "flex", - justifyContent: "space-between", - px: 1.5, - py: 1, - cursor: "pointer", - ...sx, - }} - onCardClick={onCardClick} - > - - - {t("dashboard.cards.drepName")} - - - {dRepId} - - - - - ); -}; +}: DirectVoterActionProps) => ( + theme.palette.neutralWhite, + borderColor: gray.c100, + display: "flex", + justifyContent: "space-between", + px: 1.5, + py: 1, + cursor: "pointer", + ...sx, + }} + onCardClick={onCardClick} + > + + + {drepName} + + + {dRepId} + + + + +); diff --git a/govtool/frontend/src/components/molecules/types.ts b/govtool/frontend/src/components/molecules/types.ts index 343936767..448dc3da6 100644 --- a/govtool/frontend/src/components/molecules/types.ts +++ b/govtool/frontend/src/components/molecules/types.ts @@ -19,6 +19,7 @@ export type StepProps = { export type DirectVoterActionProps = { dRepId: string; + drepName: string; onCardClick: () => void; sx?: SxProps; }; diff --git a/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx b/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx index 1a92559b2..9dec43e56 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx @@ -4,14 +4,19 @@ import { Trans } from "react-i18next"; import { IMAGES, PATHS } from "@consts"; import { PendingTransaction } from "@context"; -import { useTranslation } from "@hooks"; +import { useGetDRepListInfiniteQuery, useTranslation } from "@hooks"; import { CurrentDelegation, VoterInfo } from "@models"; import { DashboardActionCard, DashboardActionCardProps, DelegationAction, } from "@molecules"; -import { correctAdaFormat, formHexToBech32, openInNewTab } from "@utils"; +import { + correctAdaFormat, + formHexToBech32, + getMetadataDataMissingStatusTranslation, + openInNewTab, +} from "@utils"; import { AutomatedVotingOptionCurrentDelegation, AutomatedVotingOptionDelegationId, @@ -34,6 +39,16 @@ export const DelegateDashboardCard = ({ }: DelegateDashboardCardProps) => { const navigate = useNavigate(); const { t } = useTranslation(); + const { dRepData, isDRepListFetching } = useGetDRepListInfiniteQuery( + { + searchPhrase: currentDelegation?.dRepHash ?? delegateTx?.resourceId ?? "", + }, + { + enabled: !!currentDelegation?.dRepHash || !!delegateTx?.resourceId, + }, + ); + + const myDRepDelegationData = dRepData?.[0]; const learnMoreButton = { children: t("learnMore"), @@ -129,7 +144,9 @@ export const DelegateDashboardCard = ({ (!(currentDelegation?.dRepHash === dRepID) || voter?.isRegisteredAsDRep) } transactionId={ - !(currentDelegation?.dRepHash === dRepID) || voter?.isRegisteredAsDRep + !(currentDelegation?.dRepHash === dRepID) || + voter?.isRegisteredAsDRep || + !voter?.isRegisteredAsSoleVoter ? delegateTx?.transactionHash ?? currentDelegation?.txHash : undefined } @@ -137,8 +154,18 @@ export const DelegateDashboardCard = ({ > {displayedDelegationId && (!(currentDelegation?.dRepHash === dRepID) || - voter?.isRegisteredAsDRep) && ( + voter?.isRegisteredAsDRep || + !voter?.isRegisteredAsSoleVoter) && ( = ({ ? [yourselfDRep, ...dRepsWithoutYourself] : dRepList; const inProgressDelegationDRepData = dRepListToDisplay.find( - (dRep) => dRep.drepId === inProgressDelegation, + (dRep) => + dRep.drepId === inProgressDelegation || + dRep.view === inProgressDelegation, ); const isAnAutomatedVotingOptionChosen = @@ -221,7 +223,7 @@ export const DRepDirectoryContent: FC = ({ isDelegating === dRep.view || isDelegating === dRep.drepId } isMe={isSameDRep(dRep, myDRepId)} - onDelegate={() => delegate(dRep.drepId)} + onDelegate={() => delegate(dRep.view)} /> );