Skip to content

Commit

Permalink
[#119] Post code review adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Mar 1, 2024
1 parent 6d048cb commit dd4c036
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Box, ButtonProps, Skeleton } from "@mui/material";
import { FC, ReactNode } from "react";

import { CopyButton, LoadingButton, Typography } from "@atoms";
import { useScreenDimension } from "@hooks";
import { useScreenDimension, useTranslation } from "@hooks";
import { theme } from "@/theme";

type DashboardActionCardProps = {
Expand Down Expand Up @@ -31,6 +31,7 @@ type DashboardActionCardProps = {
export const DashboardActionCard: FC<DashboardActionCardProps> = ({
...props
}) => {
const { t } = useTranslation();
const {
cardId,
cardTitle,
Expand Down Expand Up @@ -83,7 +84,7 @@ export const DashboardActionCard: FC<DashboardActionCardProps> = ({
}}
>
<Typography color={"orangeDark"} variant="body2">
In progress
{t("inProgress").toLocaleUpperCase()}
</Typography>
</Box>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const VoteActionForm = ({
/>
</Box>
</Box>
{voter?.isRegisteredAsDRep && (
{(voter?.isRegisteredAsDRep || voter?.isRegisteredAsSoleVoter) && (
<Button
data-testid="show-votes-button"
variant="text"
Expand Down
7 changes: 2 additions & 5 deletions govtool/frontend/src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useCardano } from "@context";
import { Background, ScrollToManage } from "@atoms";
import { useScreenDimension } from "@hooks";
import { DashboardTopNav, Drawer, Footer } from "@organisms";
import { WALLET_LS_KEY, getItemFromLocalStorage } from "@/utils/localStorage";
import { checkIsWalletConnected } from "@/utils";

const getPageTitle = (pathname: string) => {
if (pathname === PATHS.dashboard) {
Expand All @@ -33,10 +33,7 @@ export const Dashboard = () => {
}, [pathname, divRef]);

useEffect(() => {
if (
!getItemFromLocalStorage(`${WALLET_LS_KEY}_stake_key`) ||
!getItemFromLocalStorage(`${WALLET_LS_KEY}_name`)
) {
if (checkIsWalletConnected()) {
if (window.location.pathname === PATHS.dashboard) {
navigate(PATHS.home);
} else {
Expand Down
7 changes: 2 additions & 5 deletions govtool/frontend/src/pages/DelegateTodRep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
Footer,
} from "@organisms";
import { useScreenDimension, useTranslation } from "@hooks";
import { WALLET_LS_KEY, getItemFromLocalStorage } from "@/utils/localStorage";
import { useNavigate } from "react-router-dom";
import { checkIsWalletConnected } from "@/utils";

export const DelegateTodRep = () => {
const [step, setStep] = useState(1);
Expand All @@ -20,10 +20,7 @@ export const DelegateTodRep = () => {
const { t } = useTranslation();

useEffect(() => {
if (
!getItemFromLocalStorage(`${WALLET_LS_KEY}_stake_key`) ||
!getItemFromLocalStorage(`${WALLET_LS_KEY}_name`)
) {
if (checkIsWalletConnected()) {
navigate(PATHS.home);
}
}, []);
Expand Down
7 changes: 2 additions & 5 deletions govtool/frontend/src/pages/RegisterAsSoleVoter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ import { useNavigate } from "react-router-dom";
import { PATHS } from "@consts";
import { RegisterAsSoleVoterBox } from "@organisms";
import { useTranslation } from "@hooks";
import { WALLET_LS_KEY, getItemFromLocalStorage } from "@/utils/localStorage";
import { CenteredBoxPageWrapper } from "@molecules";
import { checkIsWalletConnected } from "@/utils";

export const RegisterAsSoleVoter = () => {
const navigate = useNavigate();
const { t } = useTranslation();

useEffect(() => {
if (
!getItemFromLocalStorage(`${WALLET_LS_KEY}_stake_key`) ||
!getItemFromLocalStorage(`${WALLET_LS_KEY}_name`)
) {
if (checkIsWalletConnected()) {
navigate(PATHS.home);
}
}, []);
Expand Down
7 changes: 2 additions & 5 deletions govtool/frontend/src/pages/RegisterAsdRep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
useTranslation,
} from "@hooks";
import { useNavigate } from "react-router-dom";
import { WALLET_LS_KEY, getItemFromLocalStorage } from "@/utils/localStorage";
import { checkIsWalletConnected } from "@/utils";

export const RegisterAsdRep = () => {
const [step, setStep] = useState<number>(1);
Expand All @@ -28,10 +28,7 @@ export const RegisterAsdRep = () => {
const registerAsdRepFormMethods = useRegisterAsdRepFormController();

useEffect(() => {
if (
!getItemFromLocalStorage(`${WALLET_LS_KEY}_stake_key`) ||
!getItemFromLocalStorage(`${WALLET_LS_KEY}_name`)
) {
if (checkIsWalletConnected()) {
navigate(PATHS.home);
}
}, []);
Expand Down
7 changes: 2 additions & 5 deletions govtool/frontend/src/pages/RetireAsSoleVoter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ import { PATHS } from "@consts";
import { RetireAsSoleVoterBox } from "@organisms";
import { useTranslation } from "@hooks";
import { useNavigate } from "react-router-dom";
import { WALLET_LS_KEY, getItemFromLocalStorage } from "@/utils/localStorage";
import { CenteredBoxPageWrapper } from "@molecules";
import { checkIsWalletConnected } from "@/utils";

export const RetireAsSoleVoter = () => {
const navigate = useNavigate();
const { t } = useTranslation();

useEffect(() => {
if (
!getItemFromLocalStorage(`${WALLET_LS_KEY}_stake_key`) ||
!getItemFromLocalStorage(`${WALLET_LS_KEY}_name`)
) {
if (checkIsWalletConnected()) {
navigate(PATHS.home);
}
}, []);
Expand Down
7 changes: 2 additions & 5 deletions govtool/frontend/src/pages/UpdatedRepMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "@hooks";
import { ControlledField, DashboardTopNav, Footer } from "@organisms";
import { theme } from "@/theme";
import { WALLET_LS_KEY, getItemFromLocalStorage, openInNewTab } from "@utils";
import { checkIsWalletConnected, openInNewTab } from "@utils";

export const UpdatedRepMetadata = () => {
const navigate = useNavigate();
Expand All @@ -27,10 +27,7 @@ export const UpdatedRepMetadata = () => {
useUpdatedRepMetadataForm();

useEffect(() => {
if (
!getItemFromLocalStorage(`${WALLET_LS_KEY}_stake_key`) ||
!getItemFromLocalStorage(`${WALLET_LS_KEY}_name`)
) {
if (checkIsWalletConnected()) {
navigate(PATHS.home);
} else {
const isPendingTx = isPendingTransaction();
Expand Down
5 changes: 5 additions & 0 deletions govtool/frontend/src/utils/checkIsWalletConnected.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { WALLET_LS_KEY, getItemFromLocalStorage } from "@/utils/localStorage";

export const checkIsWalletConnected = () =>
!getItemFromLocalStorage(`${WALLET_LS_KEY}_stake_key`) ||
!getItemFromLocalStorage(`${WALLET_LS_KEY}_name`);
3 changes: 2 additions & 1 deletion govtool/frontend/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export * from "./adaFormat";
export * from "./basicReducer";
export * from "./callAll";
export * from "./formatDate";
export * from "./getDRepId";
export * from "./getDRepID";
export * from "./getLengthInBytes";
export * from "./getProposalTypeLabel";
export * from "./isValidFormat";
Expand All @@ -11,3 +11,4 @@ export * from "./openInNewTab";
export * from "./getGovActionId";
export * from "./checkIsMaintenanceOn";
export * from "./removeDuplicatedProposals";
export * from "./checkIsWalletConnected";

0 comments on commit dd4c036

Please sign in to comment.