Skip to content

Commit

Permalink
[#119] add registration as sole voter
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Mar 1, 2024
1 parent e22c471 commit c6a983d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ As a minor extension, we also keep a semantic version for the `UNRELEASED`
changes.

## [Unreleased]
- Add retire as Sole Voter screen [Issue 198](https://github.com/IntersectMBO/govtool/issues/198)
- Add Sole Voter card [Issue 141](https://github.com/IntersectMBO/govtool/issues/141)
- Add possibility to vote on behalf of myself - Sole Voter [Issue 119](https://github.com/IntersectMBO/govtool/issues/119)
- Create DRep registration page about roles [Issue 205](https://github.com/IntersectMBO/govtool/issues/205)
- Create Checkbox component. Improve Field and ControlledField [Issue 177](https://github.com/IntersectMBO/govtool/pull/177)
- Vitest unit tests added for utils functions [Issue 81](https://github.com/IntersectMBO/govtool/issues/81)
Expand Down
4 changes: 1 addition & 3 deletions govtool/frontend/src/components/organisms/DashboardCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ export const DashboardCards = () => {
title={soleVoterCardTitle}
inProgress={!!soleVoterTransaction?.transactionHash}
dataTestidFirstButton={
user?.isRegisteredAsSoleVoter
voter?.isRegisteredAsSoleVoter
? "retire-as-sole-voter-button"
: "register-as-sole-voter-button"
}
Expand Down Expand Up @@ -495,9 +495,7 @@ export const DashboardCards = () => {
"https://docs.sanchogov.tools/faqs/what-does-it-mean-to-register-as-a-drep"
)
}
secondButtonLabel={t("learnMore")}
secondButtonVariant={"outlined"}
dataTestidSecondButton="learn-more-button"
imageURL={IMAGES.soleVoterImage}
/>
{/* REGISTARTION AS SOLE VOTER CARD END*/}
Expand Down
5 changes: 1 addition & 4 deletions govtool/frontend/src/context/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ CardanoContext.displayName = "CardanoContext";

function CardanoProvider(props: Props) {
const [isEnabled, setIsEnabled] = useState(false);
const [isEnableLoading, setIsEnableLoading] = useState<string | null>(null);
const [voter, setVoter] = useState<VoterInfo | undefined>(undefined);
const [walletApi, setWalletApi] = useState<CardanoApiWallet | undefined>(
undefined
Expand Down Expand Up @@ -1251,8 +1252,6 @@ function CardanoProvider(props: Props) {
isDrepLoading,
setIsDrepLoading,
isEnableLoading,
soleVoter,
setSoleVoter,
}),
[
address,
Expand Down Expand Up @@ -1287,8 +1286,6 @@ function CardanoProvider(props: Props) {
isDrepLoading,
setIsDrepLoading,
isEnableLoading,
soleVoter,
setSoleVoter,
]
);

Expand Down
13 changes: 10 additions & 3 deletions govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ import { useCardano } from "@context";
import { getDRepVotingPower } from "@services";

export const useGetDRepVotingPowerQuery = () => {
const { dRepID, dRep } = useCardano();
const { dRepID, voter } = useCardano();

const { data, isLoading } = useQuery({
queryKey: [QUERY_KEYS.useGetDRepVotingPowerKey, dRepID, dRep?.isRegistered],
queryKey: [
QUERY_KEYS.useGetDRepVotingPowerKey,
dRepID,
voter?.isRegisteredAsDRep,
voter?.isRegisteredAsSoleVoter,
],
queryFn: async () => {
return await getDRepVotingPower({ dRepID });
},
enabled: !!dRepID && !!dRep?.isRegistered,
enabled:
!!dRepID &&
(!!voter?.isRegisteredAsDRep || !!voter?.isRegisteredAsSoleVoter),
});

return { dRepVotingPower: data, isDRepVotingPowerLoading: isLoading };
Expand Down

0 comments on commit c6a983d

Please sign in to comment.