From 89dea8a8a4a8d1c709e87c6dc010ed91fe595f86 Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Thu, 27 Jun 2024 21:40:57 +0100 Subject: [PATCH] fix: voice credits counter --- src/features/ballot/components/BallotOverview.tsx | 2 +- src/features/projects/components/AddToBallot.tsx | 2 +- src/pages/ballot/index.tsx | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/features/ballot/components/BallotOverview.tsx b/src/features/ballot/components/BallotOverview.tsx index da6ac32c..4c4b9d56 100644 --- a/src/features/ballot/components/BallotOverview.tsx +++ b/src/features/ballot/components/BallotOverview.tsx @@ -91,7 +91,7 @@ const SubmitBallotButton = ({ disabled = false }: ISubmitBallotButtonProps): JSX error: { title: "Error submitting vote", instructions: ( - + There was an error submitting the vote. ), diff --git a/src/features/projects/components/AddToBallot.tsx b/src/features/projects/components/AddToBallot.tsx index ae50a692..5df07067 100644 --- a/src/features/projects/components/AddToBallot.tsx +++ b/src/features/projects/components/AddToBallot.tsx @@ -64,7 +64,7 @@ const ProjectAllocation = ({ "text-primary-500": exceededProjectTokens, })} > - {formatNumber(total - amount)} + {formatNumber(initialVoiceCredits - total)} / diff --git a/src/pages/ballot/index.tsx b/src/pages/ballot/index.tsx index 34261506..cec67f7c 100644 --- a/src/pages/ballot/index.tsx +++ b/src/pages/ballot/index.tsx @@ -9,6 +9,7 @@ import { Dialog } from "~/components/ui/Dialog"; import { Form } from "~/components/ui/Form"; import { config } from "~/config"; import { useBallot } from "~/contexts/Ballot"; +import { useMaci } from "~/contexts/Maci"; import { AllocationFormWrapper } from "~/features/ballot/components/AllocationList"; import { BallotSchema, type Vote } from "~/features/ballot/types"; import { LayoutWithBallot } from "~/layouts/DefaultLayout"; @@ -79,11 +80,12 @@ const EmptyBallot = () => ( const TotalAllocation = () => { const { sumBallot } = useBallot(); + const { initialVoiceCredits } = useMaci(); const form = useFormContext<{ votes: Vote[] }>(); const votes = form.watch("votes"); const sum = sumBallot(votes); - return
{`${formatNumber(sum)} ${config.tokenName}`}
; + return
{`${formatNumber(sum)} / ${initialVoiceCredits} ${config.tokenName}`}
; }; const BallotAllocationForm = () => {