Skip to content

Commit

Permalink
Merge pull request #188 from privacy-scaling-explorations/fix/qv-non-qv
Browse files Browse the repository at this point in the history
fix: voice credits counter
  • Loading branch information
ctrlc03 authored Jun 28, 2024
2 parents 885153e + 89dea8a commit 13ba63a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/features/ballot/components/BallotOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const SubmitBallotButton = ({ disabled = false }: ISubmitBallotButtonProps): JSX
error: {
title: "Error submitting vote",
instructions: (
<Alert title={(submit.error as { message?: string }).message} variant="warning">
<Alert title={submit.error ? (submit.error as { message?: string }).message : ""} variant="warning">
There was an error submitting the vote.
</Alert>
),
Expand Down
2 changes: 1 addition & 1 deletion src/features/projects/components/AddToBallot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const ProjectAllocation = ({
"text-primary-500": exceededProjectTokens,
})}
>
{formatNumber(total - amount)}
{formatNumber(initialVoiceCredits - total)}
</span>

<span className="text-gray-600 dark:text-gray-400">/</span>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/ballot/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 <div>{`${formatNumber(sum)} ${config.tokenName}`}</div>;
return <div>{`${formatNumber(sum)} / ${initialVoiceCredits} ${config.tokenName}`}</div>;
};

const BallotAllocationForm = () => {
Expand Down

0 comments on commit 13ba63a

Please sign in to comment.