Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#119] Add registration as a sole voter #308

Merged
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e58ccbf
Sole voter information page, without footer
JanJaroszczak Feb 14, 2024
d0d520c
add image for sole voter
Sworzen1 Feb 16, 2024
57e7ba9
change props and dashabord card sizes
Sworzen1 Feb 16, 2024
5ac760b
add sole voter into IMAGES
Sworzen1 Feb 16, 2024
ec7cc02
sort IMAGES asc
Sworzen1 Feb 16, 2024
f0a0991
add translations for sole voter card
Sworzen1 Feb 16, 2024
b556540
change way to display cards on dashboard/ add sole voter card
Sworzen1 Feb 16, 2024
8bef9a8
delete unnecessary code
Sworzen1 Feb 16, 2024
5de9636
add feat to changelog
Sworzen1 Feb 16, 2024
69b4925
add sole voter into IMAGES
Sworzen1 Feb 16, 2024
130594e
add retire as sole voter screen
Sworzen1 Feb 19, 2024
a36bc81
add retirement to changelog
Sworzen1 Feb 19, 2024
2e3f63b
update home cards
Sworzen1 Feb 19, 2024
d2dc424
Sole Voter transactions added and UI components unification
JanJaroszczak Feb 20, 2024
6c1a1a4
Minor refactor
JanJaroszczak Feb 21, 2024
42c194a
[#119] Fixes after CR
JanJaroszczak Feb 26, 2024
011f585
[#210] Sole voter wallet logic for registration and retirement
JanJaroszczak Feb 22, 2024
9530e5a
[#210] Sole voter wallet logic for registration and retirement - part 2
JanJaroszczak Feb 26, 2024
c435bc9
[#210] 'user' changed to 'voter'
JanJaroszczak Feb 26, 2024
2119010
[#210] 'UserInfo' changed to 'VoterInfo'
JanJaroszczak Feb 26, 2024
0d4c1e4
[#119] add registration as sole voter
MSzalowski Feb 27, 2024
449761d
[#119] Duplicated lines removed
JanJaroszczak Feb 27, 2024
17d9230
[#119] Make voting on governance actions possible
MSzalowski Feb 27, 2024
5c6659e
[#119] Post code review adjustments
MSzalowski Feb 27, 2024
924e8eb
[#212] provide sole voter information in drep/info
jankun4 Feb 21, 2024
991c18d
[#212] udpate CHANGELOG.md
jankun4 Feb 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ As a minor extension, we also keep a semantic version for the `UNRELEASED`
changes.

## [Unreleased]
- 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
5 changes: 5 additions & 0 deletions govtool/frontend/public/icons/ArrowLeftThin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions govtool/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
UpdatedRepMetadata,
GovernanceActionsCategory,
DashboardGovernanceActionsCategory,
RetireAsSoleVoter,
} from "@pages";
import {
callAll,
Expand All @@ -30,9 +31,10 @@ import {
} from "@utils";
import { SetupInterceptors } from "./services";
import { useGetDRepInfo, useWalletConnectionListener } from "./hooks";
import { RegisterAsSoleVoter } from "./pages/RegisterAsSoleVoter";

export default function App() {
const { enable, setDRep, setIsDrepLoading } = useCardano();
const { enable, setVoter, setIsDrepLoading } = useCardano();
const navigate = useNavigate();
const { data } = useGetDRepInfo();
const { modal, openModal, modals } = useModal();
Expand All @@ -45,11 +47,11 @@ export default function App() {

useEffect(() => {
setIsDrepLoading(true);
setDRep(data);
setVoter(data);
const timer = setTimeout(() => setIsDrepLoading(false), 1000);

return () => clearTimeout(timer);
}, [data?.isRegistered]);
}, [data?.isRegisteredAsDRep, data?.isRegisteredAsSoleVoter]);

const checkTheWalletIsActive = useCallback(() => {
const hrefCondition =
Expand Down Expand Up @@ -115,6 +117,11 @@ export default function App() {
</Route>
<Route path={PATHS.delegateTodRep} element={<DelegateTodRep />} />
<Route path={PATHS.registerAsdRep} element={<RegisterAsdRep />} />
<Route
path={PATHS.registerAsSoleVoter}
element={<RegisterAsSoleVoter />}
/>
<Route path={PATHS.retireAsSoleVoter} element={<RetireAsSoleVoter />} />
<Route path={PATHS.stakeKeys} element={<ChooseStakeKey />} />
<Route path={PATHS.updateMetadata} element={<UpdatedRepMetadata />} />
<Route path="*" element={<ErrorPage />} />
Expand Down
10 changes: 5 additions & 5 deletions govtool/frontend/src/components/atoms/VotingPowerChips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { correctAdaFormat } from "@utils";
import { Tooltip } from "@atoms";

export const VotingPowerChips = () => {
const { dRep, stakeKey, isDrepLoading } = useCardano();
const { voter, stakeKey, isDrepLoading } = useCardano();
const { dRepVotingPower, isDRepVotingPowerLoading } =
useGetDRepVotingPowerQuery();
const { votingPower, powerIsLoading } =
Expand All @@ -33,7 +33,7 @@ export const VotingPowerChips = () => {
alignItems="center"
maxHeight={isMobile ? undefined : 48}
>
{dRep?.isRegistered && (
{voter?.isRegisteredAsDRep && (
<Tooltip
heading={t("tooltips.votingPower.heading")}
paragraphOne={t("tooltips.votingPower.paragraphOne")}
Expand All @@ -55,8 +55,8 @@ export const VotingPowerChips = () => {
{t("votingPower")}
</Typography>
)}
{(dRep?.isRegistered && isDRepVotingPowerLoading) ||
(!dRep?.isRegistered && powerIsLoading) ||
{(voter?.isRegisteredAsDRep && isDRepVotingPowerLoading) ||
(!voter?.isRegisteredAsDRep && powerIsLoading) ||
isDrepLoading ? (
<CircularProgress size={20} color="primary" />
) : (
Expand All @@ -67,7 +67,7 @@ export const VotingPowerChips = () => {
sx={{ whiteSpace: "nowrap" }}
>
₳{" "}
{dRep?.isRegistered
{voter?.isRegisteredAsDRep
? correctAdaFormat(dRepVotingPower) ?? 0
: correctAdaFormat(votingPower) ?? 0}
</Typography>
Expand Down
1 change: 0 additions & 1 deletion govtool/frontend/src/components/molecules/ActionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export const ActionCard: FC<ActionCardProps> = ({ ...props }) => {
<Button
data-testid={dataTestIdFirstButton}
onClick={firstButtonAction}
size="large"
sx={{
width: MOBILE_AND_WIDE_CONDITION ? "100%" : "auto",
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { useMemo } from "react";
import { Box } from "@mui/material";

import { Button, LoadingButton } from "@atoms";
import { useScreenDimension, useTranslation } from "@hooks";

interface Props {
onBackButton: () => void;
onActionButton: () => void;
isLoading?: boolean;
backButtonText?: string;
actionButtonText?: string;
}

export const CenteredBoxBottomButtons = ({
onBackButton,
onActionButton,
isLoading,
backButtonText,
actionButtonText,
}: Props) => {
const { isMobile } = useScreenDimension();
const { t } = useTranslation();

const renderBackButton = useMemo(() => {
return (
<Button
data-testid={"back-button"}
onClick={onBackButton}
size="extraLarge"
sx={{
px: 6,
}}
variant="outlined"
>
{backButtonText ?? t("cancel")}
</Button>
);
}, [isMobile]);

const renderActionButton = useMemo(() => {
return (
<LoadingButton
data-testid={"register-button"}
isLoading={isLoading}
onClick={onActionButton}
sx={{
px: 6,
height: 48,
fontSize: 16,
}}
variant="contained"
>
{actionButtonText ?? t("continue")}
</LoadingButton>
);
}, [isLoading, isMobile]);

return (
<Box
display="flex"
flexDirection={isMobile ? "column-reverse" : "row"}
justifyContent="space-around"
mt={6}
>
{renderBackButton}
<Box px={2} py={isMobile ? 1.5 : 0} />
{renderActionButton}
</Box>
);
};
108 changes: 108 additions & 0 deletions govtool/frontend/src/components/molecules/CenteredBoxPageWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { FC, PropsWithChildren } from "react";
import { Box, Link } from "@mui/material";

import { Background, Typography } from "@atoms";
import { ICONS } from "@consts";
import { DashboardTopNav } from "@organisms";
import { useScreenDimension } from "@hooks";
import { useNavigate } from "react-router-dom";
import { theme } from "@/theme";

interface Props {
pageTitle: string;
backButtonText: string;
backButtonPath: string;
isVotingPowerHidden?: boolean;
}
export const CenteredBoxPageWrapper: FC<PropsWithChildren<Props>> = ({
pageTitle,
backButtonText,
backButtonPath,
isVotingPowerHidden,
children,
}) => {
const { isMobile, screenWidth, pagePadding } = useScreenDimension();
const navigate = useNavigate();
const {
palette: { boxShadow2 },
} = theme;

return (
<Background isReverted>
<Box display={"flex"} minHeight={"100vh"} flexDirection="column">
<DashboardTopNav
imageSRC={ICONS.appLogoIcon}
imageWidth={isMobile ? undefined : 42}
imageHeight={isMobile ? 24 : 35}
title={pageTitle}
isVotingPowerHidden={isVotingPowerHidden}
/>
<Box
display={"flex"}
justifyContent={"center"}
flexDirection={"column"}
mt={isMobile ? 0 : 7}
height={isMobile ? "100%" : "auto"}
sx={{ marginTop: "97px" }}
>
{isMobile && (
<Box borderBottom={1} borderColor={"#fff"}>
<Typography
variant="body2"
sx={{
ml: 2,
my: "26px",
fontSize: "24px",
fontWeight: 400,
}}
>
{pageTitle}
</Typography>
</Box>
)}
<Link
data-testid={"back-button"}
sx={{
cursor: "pointer",
display: "flex",
textDecoration: "none",
my: 3,
marginLeft: isMobile ? 2 : "40px",
}}
onClick={() => navigate(backButtonPath)}
>
<img
src={ICONS.arrowLeftThinIcon}
alt="arrow"
style={{ marginRight: "4px" }}
/>
<Typography
variant="body2"
color="primary"
sx={{
fontWeight: 400,
paddingTop: "1px",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why padding top 1px ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}}
>
{backButtonText}
MSzalowski marked this conversation as resolved.
Show resolved Hide resolved
</Typography>
</Link>
<Box display={"flex"} justifyContent={"center"}>
<Box
width={screenWidth < 768 ? "auto" : "52vw"}
boxShadow={isMobile ? "" : `2px 2px 20px 0px ${boxShadow2}`}
px={pagePadding}
py={isMobile ? 3 : 8}
borderRadius={"20px"}
height="auto"
>
<Box display="flex" flexDirection="column">
{children}
</Box>
</Box>
</Box>
</Box>
</Box>
</Background>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ type DashboardActionCardProps = {
firstButtonIsLoading?: boolean;
firstButtonLabel?: string;
firstButtonVariant?: ButtonProps["variant"];
imageHeight?: number;
imageURL?: string;
imageWidth?: number;
inProgress?: boolean;
isLoading?: boolean;
secondButtonAction?: () => void;
Expand Down Expand Up @@ -62,17 +60,15 @@ export const DashboardActionCard: FC<DashboardActionCardProps> = ({

return (
<Box
mb={3}
p={3}
sx={{ boxShadow: `5px 5px 15px 5px ${boxShadow2}` }}
border={inProgress && !isLoading ? 1 : 0}
borderColor="accentOrange"
borderRadius={3}
flex={1}
display="flex"
flex={1}
flexDirection="column"
border={inProgress && !isLoading ? 1 : 0}
borderColor="accentOrange"
p={3}
position="relative"
maxWidth={440}
sx={{ boxShadow: `5px 5px 15px 5px ${boxShadow2}` }}
>
{inProgress && !isLoading && (
<Box
Expand Down Expand Up @@ -116,7 +112,7 @@ export const DashboardActionCard: FC<DashboardActionCardProps> = ({
) : null}
{inProgress && !isLoading ? (
<Typography variant="title2" fontWeight={700}>
in progress
In Progress
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use t()

</Typography>
) : null}
{description ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const VoteActionForm = ({
const [isContext, setIsContext] = useState<boolean>(false);
const { isMobile, screenWidth } = useScreenDimension();
const { openModal } = useModal();
const { dRep } = useCardano();
const { voter } = useCardano();
const { t } = useTranslation();

const {
Expand Down Expand Up @@ -142,7 +142,7 @@ export const VoteActionForm = ({
/>
</Box>
</Box>
{dRep?.isRegistered && (
{voter?.isRegisteredAsDRep && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|| sole voter

<Button
data-testid="show-votes-button"
variant="text"
Expand Down
2 changes: 2 additions & 0 deletions govtool/frontend/src/components/molecules/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from "./ActionCard";
export * from "./CenteredBoxBottomButtons";
export * from "./CenteredBoxPageWrapper";
export * from "./DashboardActionCard";
export * from "./DataActionsBar";
export * from "./DRepInfoCard";
Expand Down
Loading