diff --git a/govtool/frontend/src/components/molecules/AutomatedVotingCard.tsx b/govtool/frontend/src/components/molecules/AutomatedVotingCard.tsx index c566011a5..dd17fa3cf 100644 --- a/govtool/frontend/src/components/molecules/AutomatedVotingCard.tsx +++ b/govtool/frontend/src/components/molecules/AutomatedVotingCard.tsx @@ -1,31 +1,46 @@ import { Box, Divider } from "@mui/material"; -import { Button, Spacer, Typography } from "@atoms"; +import { Button, Typography } from "@atoms"; import { useScreenDimension, useTranslation } from "@hooks"; import { AutomatedVotingCardProps } from "./types"; +import { Card } from "./Card"; +import { primaryBlue } from "@/consts"; +import { useModal } from "@/context"; export const AutomatedVotingCard = ({ description, + inProgress, + isConnected, + isSelected, onClickDelegate, onClickInfo, title, votingPower, }: AutomatedVotingCardProps) => { const { isMobile, screenWidth } = useScreenDimension(); + const { openModal } = useModal(); const { t } = useTranslation(); return ( - `${theme.palette.neutralWhite}40`, + boxShadow: `0px 4px 15px 0px ${primaryBlue.c100}`, display: "flex", flex: 1, flexDirection: screenWidth < 1440 ? "column" : "row", justifyContent: "space-between", - padding: "18px 24px", + mt: inProgress || isSelected ? 2 : 0, + py: 2.25, }} > - - + {!isConnected + ? ( + + ) + : !isSelected && ( + + )} - + ); }; diff --git a/govtool/frontend/src/components/molecules/types.ts b/govtool/frontend/src/components/molecules/types.ts index 62576a774..d2fa9d75f 100644 --- a/govtool/frontend/src/components/molecules/types.ts +++ b/govtool/frontend/src/components/molecules/types.ts @@ -18,6 +18,9 @@ export type StepProps = { export type AutomatedVotingCardProps = { description: string; + inProgress?: boolean; + isConnected?: boolean; + isSelected?: boolean; onClickDelegate: () => void; onClickInfo: () => void; title: string; diff --git a/govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx b/govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx index ff7503e28..f0482abab 100644 --- a/govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx +++ b/govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx @@ -3,19 +3,39 @@ import { AccordionDetails, AccordionSummary, Box, + Chip, } from "@mui/material"; import { Typography } from "@atoms"; import { ICONS } from "@consts"; import { useTranslation } from "@hooks"; import { AutomatedVotingCard } from "@molecules"; +import { useState } from "react"; -export const AutomatedVotingOptions = () => { +type AutomatedVotingOptionsProps = { + currentDelegation: string | undefined; + delegate: (delegateTo: string) => void; + delegationInProgress?: string; + isConnected?: boolean; + votingPower: string; +}; + +export const AutomatedVotingOptions = ({ + currentDelegation, + delegate, + delegationInProgress, + isConnected, + votingPower, +}: AutomatedVotingOptionsProps) => { const { t } = useTranslation(); + const [isOpen, setIsOpen] = useState(false); + return ( setIsOpen(isExpanded)} sx={(theme) => ({ bgcolor: `${theme.palette.lightBlue}80`, border: `1px solid ${theme.palette.neutralWhite}`, @@ -26,6 +46,19 @@ export const AutomatedVotingOptions = () => { sx={{ borderRadius: 3, px: { xxs: 2, md: 3 } }} > {t("dRepDirectory.automatedVotingOptions")} + {currentDelegation && !isOpen && ( + // TODO this Chip is temporary, since there were no design for this case + theme.palette.neutralWhite, + fontWeight: 400, + ml: 2, + textTransform: 'uppercase', + }} + /> + )} { > {}} - onClickInfo={() => {}} + inProgress={delegationInProgress === "abstain"} + isConnected={isConnected} + isSelected={currentDelegation === "drep_always_abstain"} + onClickDelegate={() => delegate("abstain")} + onClickInfo={() => { }} title={t("dRepDirectory.abstainCardTitle")} - votingPower="99,111,111" + votingPower={votingPower} /> {}} - onClickInfo={() => {}} + inProgress={delegationInProgress === "no confidence"} + isConnected={isConnected} + isSelected={currentDelegation === "drep_always_no_confidence"} + onClickDelegate={() => delegate("no confidence")} + onClickInfo={() => { }} title={t("dRepDirectory.noConfidenceTitle")} - votingPower="99,111,111" + votingPower={votingPower} /> diff --git a/govtool/frontend/src/components/organisms/DRepCard.tsx b/govtool/frontend/src/components/organisms/DRepCard.tsx index c7c6cf4d8..ffc0107cc 100644 --- a/govtool/frontend/src/components/organisms/DRepCard.tsx +++ b/govtool/frontend/src/components/organisms/DRepCard.tsx @@ -35,11 +35,11 @@ export const DRepCard = ({ diff --git a/govtool/frontend/src/i18n/locales/en.ts b/govtool/frontend/src/i18n/locales/en.ts index 993c92855..6be777e67 100644 --- a/govtool/frontend/src/i18n/locales/en.ts +++ b/govtool/frontend/src/i18n/locales/en.ts @@ -659,5 +659,6 @@ export const en = { viewDetails: "View details", votingPower: "Voting power", yes: "Yes", + yourself: "Yourself", }, }; diff --git a/govtool/frontend/src/pages/DRepDirectoryContent.tsx b/govtool/frontend/src/pages/DRepDirectoryContent.tsx index d1cc38b4c..58b8b3daf 100644 --- a/govtool/frontend/src/pages/DRepDirectoryContent.tsx +++ b/govtool/frontend/src/pages/DRepDirectoryContent.tsx @@ -21,7 +21,7 @@ export const DRepDirectoryContent: FC = ({ }) => { const { dRepID: myDRepId, - isEnableLoading, + isEnabled, pendingTransaction, stakeKey, } = useCardano(); @@ -29,19 +29,20 @@ export const DRepDirectoryContent: FC = ({ const { delegate } = useDelegateTodRep(); + const { votingPower } = useGetAdaHolderVotingPowerQuery(); const { currentDelegation } = useGetAdaHolderCurrentDelegationQuery(stakeKey); const inProgressDelegation = pendingTransaction.delegate?.resourceId; - const { data: myDRepList, isLoading: isMyDRepLoading } = useGetDRepListQuery( + const { data: myDRepList } = useGetDRepListQuery( currentDelegation?.startsWith('drep') ? currentDelegation : formHexToBech32(currentDelegation), { enabled: !!inProgressDelegation || !!currentDelegation } ); const myDrep = myDRepList?.[0]; - const { data: dRepList, isLoading: isDRepListLoading } = useGetDRepListQuery(); - - const { votingPower } = useGetAdaHolderVotingPowerQuery(); + const { data: dRepList } = useGetDRepListQuery(); - if (isEnableLoading || isMyDRepLoading || isDRepListLoading) return ; + if (!isEnabled || votingPower === undefined || !dRepList) { + return ; + } const ada = correctAdaFormat(votingPower); @@ -62,18 +63,35 @@ export const DRepDirectoryContent: FC = ({ {isConnected && (
- {t("dRepDirectory.delegationOptions")} - + + {t("dRepDirectory.delegationOptions")} + +
)}
- {t("dRepDirectory.listTitle")} + + {t('dRepDirectory.listTitle')} + - {dRepList?.map((dRep) => (isSameDRep(dRep, myDrep?.view) - ? null - : ( - + {dRepList?.map((dRep) => + (isSameDRep(dRep, myDrep?.view) ? null : ( + = ({ onDelegate={() => delegate(dRep.drepId)} /> - )))} + )), + )}