From e3efe396229e334cf35b1fa8423813b3c46d3861 Mon Sep 17 00:00:00 2001 From: Joanna Dyczka Date: Fri, 9 Aug 2024 10:52:04 +0200 Subject: [PATCH] [#1183] Remove unused components --- .../organisms/RegisterAsDirectVoterBox.tsx | 80 ------------------- .../RegisterAsDirectVoterBoxContent.tsx | 48 ----------- .../src/components/organisms/index.ts | 2 - 3 files changed, 130 deletions(-) delete mode 100644 govtool/frontend/src/components/organisms/RegisterAsDirectVoterBox.tsx delete mode 100644 govtool/frontend/src/components/organisms/RegisterAsDirectVoterBoxContent.tsx diff --git a/govtool/frontend/src/components/organisms/RegisterAsDirectVoterBox.tsx b/govtool/frontend/src/components/organisms/RegisterAsDirectVoterBox.tsx deleted file mode 100644 index a820edf80..000000000 --- a/govtool/frontend/src/components/organisms/RegisterAsDirectVoterBox.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { useCallback, useState, useEffect } from "react"; -import { useNavigate } from "react-router-dom"; -import { useTranslation } from "react-i18next"; -import * as Sentry from "@sentry/react"; - -import { PATHS } from "@consts"; -import { RegisterAsDirectVoterBoxContent } from "@organisms"; -import { CenteredBoxBottomButtons } from "@molecules"; -import { useAppContext, useCardano, useModal } from "@context"; -import { useGetVoterInfo, useWalletErrorModal } from "@hooks"; - -export const RegisterAsDirectVoterBox = () => { - const { cExplorerBaseUrl } = useAppContext(); - const [isLoading, setIsLoading] = useState(false); - - const { buildSignSubmitConwayCertTx, buildDRepRegCert, buildDRepUpdateCert } = - useCardano(); - const navigate = useNavigate(); - const { openModal, closeModal } = useModal(); - const { t } = useTranslation(); - const { voter } = useGetVoterInfo(); - const openWalletErrorModal = useWalletErrorModal(); - - useEffect(() => { - Sentry.setTag("component_name", "RegisterAsDirectVoterBox"); - }, []); - - const onRegister = useCallback(async () => { - setIsLoading(true); - - try { - const certBuilder = voter?.isRegisteredAsDRep - ? await buildDRepUpdateCert() - : await buildDRepRegCert(); - const result = await buildSignSubmitConwayCertTx({ - certBuilder, - type: "registerAsDirectVoter", - }); - if (result) { - openModal({ - type: "statusModal", - state: { - status: "success", - title: t("modals.registration.title"), - message: t("modals.registration.message"), - link: `${cExplorerBaseUrl}/tx/${result}`, - buttonText: t("modals.common.goToDashboard"), - onSubmit: () => { - navigate(PATHS.dashboard); - closeModal(); - }, - dataTestId: "registration-transaction-submitted-modal", - }, - }); - } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (error: any) { - Sentry.captureException(error); - openWalletErrorModal({ - error, - buttonText: t("modals.common.goToDashboard"), - onSumbit: () => navigate(PATHS.dashboard), - dataTestId: "registration-transaction-error-modal", - }); - } finally { - setIsLoading(false); - } - }, [buildSignSubmitConwayCertTx, buildDRepRegCert, openModal]); - - return ( - <> - - navigate(PATHS.dashboard)} - onActionButton={onRegister} - isLoading={isLoading} - /> - - ); -}; diff --git a/govtool/frontend/src/components/organisms/RegisterAsDirectVoterBoxContent.tsx b/govtool/frontend/src/components/organisms/RegisterAsDirectVoterBoxContent.tsx deleted file mode 100644 index b183c7ef2..000000000 --- a/govtool/frontend/src/components/organisms/RegisterAsDirectVoterBoxContent.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { Link } from "@mui/material"; -import { Trans } from "react-i18next"; - -import { Typography } from "@atoms"; -import { useScreenDimension, useTranslation } from "@hooks"; -import { - PROTOCOL_PARAMS_KEY, - correctAdaFormat, - getItemFromLocalStorage, - openInNewTab, -} from "@utils"; - -export const RegisterAsDirectVoterBoxContent = () => { - const { isMobile } = useScreenDimension(); - const { t } = useTranslation(); - - const epochParams = getItemFromLocalStorage(PROTOCOL_PARAMS_KEY); - - return ( - <> - - {t("directVoter.registerHeading")} - - - openInNewTab("https://sancho.network/")} - sx={{ cursor: "pointer" }} - key="0" - />, - ]} - /> - - - ); -}; diff --git a/govtool/frontend/src/components/organisms/index.ts b/govtool/frontend/src/components/organisms/index.ts index 3bdcb82df..19da922ae 100644 --- a/govtool/frontend/src/components/organisms/index.ts +++ b/govtool/frontend/src/components/organisms/index.ts @@ -21,8 +21,6 @@ export * from "./GovernanceActionsToVote"; export * from "./Hero"; export * from "./HomeCards"; export * from "./RegisterAsDRepSteps"; -export * from "./RegisterAsDirectVoterBox"; -export * from "./RegisterAsDirectVoterBoxContent"; export * from "./Slider"; export * from "./TopNav"; export * from "./VoteContext";