Skip to content

Commit

Permalink
[#1413] remove balance check on redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dyczka committed Jul 16, 2024
1 parent d29b93e commit 9dcf3a6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
5 changes: 0 additions & 5 deletions govtool/frontend/src/components/organisms/DashboardCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ import {
useGetAdaHolderCurrentDelegationQuery,
useGetVoterInfo,
} from "@hooks";
import { PROTOCOL_PARAMS_KEY, getItemFromLocalStorage } from "@utils";
import { DelegateDashboardCard } from "./DashboardCards/DelegateDashboardCard";
import { DRepDashboardCard } from "./DashboardCards/DRepDashboardCard";
import { DirectVoterDashboardCard } from "./DashboardCards/DirectVoterDashboardCard";
import { ListGovActionsDashboardCards } from "./DashboardCards/ListGovActionsDashboardCard";
import { ProposeGovActionDashboardCard } from "./DashboardCards/ProposeGovActionDashboardCard";

const protocolParams = getItemFromLocalStorage(PROTOCOL_PARAMS_KEY);

export const DashboardCards = () => {
const { dRepID, dRepIDBech32, pendingTransaction, stakeKey } = useCardano();
const { screenWidth } = useScreenDimension();
Expand Down Expand Up @@ -86,8 +83,6 @@ export const DashboardCards = () => {

<ProposeGovActionDashboardCard
createGovActionTx={pendingTransaction.createGovAction}
deposit={protocolParams?.gov_action_deposit}
votingPower={votingPower}
/>
</Box>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,29 @@ import { useNavigate } from "react-router-dom";

import { IMAGES, PATHS, PDF_PATHS } from "@consts";
import { PendingTransaction, useFeatureFlag } from "@context";
import { useTranslation, useWalletErrorModal } from "@hooks";
import { useTranslation } from "@hooks";
import { DashboardActionCard } from "@molecules";
import { correctAdaFormat, openInNewTab } from "@utils";
import { openInNewTab } from "@utils";
import { useCallback } from "react";

type ProposeGovActionDashboardCardProps = {
createGovActionTx: PendingTransaction["createGovAction"];
deposit: number;
votingPower: number;
};

export const ProposeGovActionDashboardCard = ({
createGovActionTx,
deposit,
votingPower,
}: ProposeGovActionDashboardCardProps) => {
const { isProposalDiscussionForumEnabled } = useFeatureFlag();
const navigate = useNavigate();
const { t } = useTranslation();
const openWalletErrorModal = useWalletErrorModal();

const onClickPropose = useCallback(() => {
if (votingPower <= deposit) {
openWalletErrorModal({
error: t("errors.insufficientBalanceDescription", {
ada: correctAdaFormat(deposit),
}),
title: t("errors.insufficientBalanceTitle"),
dataTestId: "insufficient-balance-error-modal",
});
return;
}

navigate(
isProposalDiscussionForumEnabled
? PDF_PATHS.proposalDiscussionPropose
: PATHS.createGovernanceAction,
);
}, [deposit, votingPower, isProposalDiscussionForumEnabled]);
}, [isProposalDiscussionForumEnabled]);

return (
<DashboardActionCard
Expand Down

0 comments on commit 9dcf3a6

Please sign in to comment.