Skip to content

Commit

Permalink
Merge pull request #211 from IntersectMBO/feat/143-create-a-sole-vote…
Browse files Browse the repository at this point in the history
…r-information-page

Sole voter information page, without footer
  • Loading branch information
JanJaroszczak authored Feb 19, 2024
2 parents 9541604 + cd7231e commit 180a39f
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 0 deletions.
5 changes: 5 additions & 0 deletions govtool/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ 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();
Expand Down Expand Up @@ -115,6 +116,10 @@ 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.stakeKeys} element={<ChooseStakeKey />} />
<Route path={PATHS.updateMetadata} element={<UpdatedRepMetadata />} />
<Route path="*" element={<ErrorPage />} />
Expand Down
108 changes: 108 additions & 0 deletions govtool/frontend/src/components/organisms/SoleVoterInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { useMemo } from "react";
import { Box, Link } from "@mui/material";

import { LoadingButton, Button, Typography } from "@atoms";
import { theme } from "@/theme";
import { useScreenDimension, useTranslation } from "@hooks";
import { Trans } from "react-i18next";
import { openInNewTab } from "@/utils";
import { useNavigate } from "react-router-dom";
import { PATHS } from "@consts";

export const SoleVoterInfo = () => {
const {
palette: { boxShadow2 },
} = theme;
const { isMobile, pagePadding, screenWidth } = useScreenDimension();
const navigate = useNavigate();
const { t } = useTranslation();

const renderBackButton = useMemo(() => {
return (
<Button
data-testid={"back-button"}
onClick={() => navigate(PATHS.dashboard)}
size="extraLarge"
sx={{
px: 6,
width: isMobile ? "100%" : "auto",
}}
variant="outlined"
>
{t("cancel")}
</Button>
);
}, [isMobile]);

const renderRegisterButton = useMemo(() => {
return (
<LoadingButton
data-testid={"register-button"}
// isLoading={isLoading}
onClick={() => {}}
sx={{
borderRadius: 50,
textTransform: "none",
px: 6,
width: isMobile ? "100%" : "auto",
height: 48,
}}
variant="contained"
>
{t("soleVoter.continueToRegister")}
</LoadingButton>
);
}, [
// isLoading,
isMobile,
]);

return (
<Box
width={screenWidth < 768 ? "auto" : screenWidth < 1024 ? "60vw" : "45vw"}
boxShadow={isMobile ? "" : `2px 2px 20px 0px ${boxShadow2}`}
px={pagePadding}
py={isMobile ? 3 : 8}
borderRadius={"20px"}
mb={isMobile ? 0 : 6}
height="auto"
>
<Box display="flex" flexDirection="column">
<Typography sx={{ mt: 1, textAlign: "center" }} variant="headline4">
{t("soleVoter.heading")}
</Typography>
<Typography
fontWeight={400}
sx={{
mb: 7,
mt: isMobile ? 4 : 10,
textAlign: "center",
whiteSpace: "pre-line",
}}
variant="body1"
>
<Trans
i18nKey="soleVoter.description"
components={[
<Link
onClick={() => openInNewTab("https://sancho.network/")}
sx={{ cursor: "pointer" }}
key="0"
/>,
]}
/>
</Typography>
</Box>
<Box
display="flex"
flexDirection={isMobile ? "column" : "row"}
justifyContent="space-between"
mt={6}
>
{isMobile ? renderRegisterButton : renderBackButton}
<Box px={2} py={isMobile ? 1.5 : 0} />
{isMobile ? renderBackButton : renderRegisterButton}
</Box>
</Box>
);
};
1 change: 1 addition & 0 deletions govtool/frontend/src/consts/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const PATHS = {
faqs: "/faqs",
delegateTodRep: "/delegate",
registerAsdRep: "/register",
registerAsSoleVoter: "/register_sole_voter",
stakeKeys: "/stake_keys",
updateMetadata: "/update_metadata",
};
8 changes: 8 additions & 0 deletions govtool/frontend/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ export const en = {
showAll: "Show all",
viewAll: "View all",
},
soleVoter: {
becomeSoleVoter: "Become a Sole Voter",
continueToRegister: "Continue to register",
description:
"A Sole Voter is someone that can vote on any Governance Action with their own Voting Power, which is equal to the balance of ADA in their connected wallet. <0>Learn More</0> about Sole Voter.\n\nBecoming a Sole Voter will require a refundable deposit of <strong>₳2</strong>.\n\nYour deposit will be refunded if you either retire or delegate your voting power to someone else (a DRep)",
heading: "What this Means",
},
system: {
sanchoNet: "SanchoNet",
sanchoNetIsBeta:
Expand Down Expand Up @@ -356,6 +363,7 @@ export const en = {
abstain: "Abstain",
back: "Back",
backToList: "Back to the list",
backToDashboard: "Back to dashboard",
cancel: "Cancel",
clear: "Clear",
confirm: "Confirm",
Expand Down
110 changes: 110 additions & 0 deletions govtool/frontend/src/pages/RegisterAsSoleVoter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { useEffect } from "react";
import { Box, Link } from "@mui/material";

import { Background, Typography } from "@atoms";
import { ICONS, PATHS } from "@consts";
import { DashboardTopNav, Footer } from "@organisms";
import { useScreenDimension, useTranslation } from "@hooks";
import { useNavigate } from "react-router-dom";
import { WALLET_LS_KEY, getItemFromLocalStorage } from "@/utils/localStorage";
import { SoleVoterInfo } from "@/components/organisms/SoleVoterInfo";

export const RegisterAsSoleVoter = () => {
const { isMobile, screenWidth } = useScreenDimension();
const navigate = useNavigate();
const { t } = useTranslation();

useEffect(() => {
if (
!getItemFromLocalStorage(`${WALLET_LS_KEY}_stake_key`) ||
!getItemFromLocalStorage(`${WALLET_LS_KEY}_name`)
) {
navigate(PATHS.home);
}
}, []);

return (
<Background isReverted>
<Box display={"flex"} minHeight={"100vh"} flexDirection="column">
<DashboardTopNav
imageSRC={ICONS.appLogoIcon}
imageWidth={isMobile ? undefined : 42}
imageHeight={isMobile ? 24 : 35}
title={t("soleVoter.becomeSoleVoter")}
/>

<Box
mt={isMobile ? 0 : 7}
height={isMobile ? "100%" : "auto"}
sx={{
marginTop: isMobile ? "97px" : "153px",
display: isMobile ? "flex" : "grid",
...(isMobile && {
flexDirection: "column",
}),
...(!isMobile && { gridTemplateColumns: "1fr auto 1fr" }),
}}
>
{isMobile && (
<Box borderBottom={1} borderColor={"#fff"}>
<Typography
variant="body2"
sx={{
ml: 2,
my: "26px",
fontSize: "24px",
fontWeight: 400,
}}
>
{t("soleVoter.becomeSoleVoter")}
</Typography>
</Box>
)}
<Link
data-testid={"back-to-list-link"}
sx={{
cursor: "pointer",
alignSelf: "flex-start",
display: "flex",
justifyContent: "center",
textDecoration: "none",
marginBottom: 3,
mt: isMobile ? 3 : "none",
mx: isMobile ? 2 : 1,
}}
onClick={() => navigate(PATHS.dashboard)}
>
<img
src={ICONS.arrowRightIcon}
alt="arrow"
style={{
marginRight: isMobile
? "12px"
: screenWidth < 950
? "8px"
: "12px",
transform: "rotate(180deg)",
}}
/>
<Typography
variant="body2"
color="primary"
sx={{
display: "inline-block",
fontSize: isMobile
? "14px"
: screenWidth < 950
? "12px"
: "14px",
}}
>
{t("backToDashboard")}
</Typography>
</Link>
<SoleVoterInfo />
</Box>
{isMobile && <Footer />}
</Box>
</Background>
);
};

0 comments on commit 180a39f

Please sign in to comment.