);
diff --git a/packages/interface/src/components/Info.tsx b/packages/interface/src/components/Info.tsx
index 78ad4db8..100f56e9 100644
--- a/packages/interface/src/components/Info.tsx
+++ b/packages/interface/src/components/Info.tsx
@@ -73,7 +73,7 @@ export const Info = ({
];
return (
-
+
{showRoundInfo && }
diff --git a/packages/interface/src/contexts/Maci.tsx b/packages/interface/src/contexts/Maci.tsx
index 35544e58..b38857f8 100644
--- a/packages/interface/src/contexts/Maci.tsx
+++ b/packages/interface/src/contexts/Maci.tsx
@@ -275,14 +275,19 @@ export const MaciProvider: React.FC = ({ children }: MaciProv
// function to be used to vote on a poll
const onVote = useCallback(
- async (votes: IVoteArgs[], pollId: string, onError: () => Promise, onSuccess: () => Promise) => {
+ async (
+ votes: IVoteArgs[],
+ pollId: string,
+ onError: (err: string) => Promise,
+ onSuccess: () => Promise,
+ ) => {
if (!signer || !stateIndex) {
return;
}
if (!votes.length) {
- onError();
setError("No votes provided");
+ onError("No votes provided");
return;
}
@@ -307,7 +312,7 @@ export const MaciProvider: React.FC = ({ children }: MaciProv
.then(() => onSuccess())
.catch((err: Error) => {
setError(err.message);
- return onError();
+ return onError(err.message);
})
.finally(() => {
setIsLoading(false);
diff --git a/packages/interface/src/contexts/types.ts b/packages/interface/src/contexts/types.ts
index 98f7b86f..3ea83fae 100644
--- a/packages/interface/src/contexts/types.ts
+++ b/packages/interface/src/contexts/types.ts
@@ -26,7 +26,7 @@ export interface MaciContextType {
onVote: (
args: IVoteArgs[],
pollId: string,
- onError: () => void | Promise,
+ onError: (err: string) => void | Promise,
onSuccess: () => void | Promise,
) => Promise;
}
diff --git a/packages/interface/src/features/ballot/components/SubmitBallotButton.tsx b/packages/interface/src/features/ballot/components/SubmitBallotButton.tsx
index f3420cbe..ba01be33 100644
--- a/packages/interface/src/features/ballot/components/SubmitBallotButton.tsx
+++ b/packages/interface/src/features/ballot/components/SubmitBallotButton.tsx
@@ -1,9 +1,9 @@
import { useRouter } from "next/router";
-import { useState, useCallback, useMemo } from "react";
+import { useCallback, useMemo } from "react";
import { toast } from "sonner";
import { Button } from "~/components/ui/Button";
-import { Dialog } from "~/components/ui/Dialog";
+import { Spinner } from "~/components/ui/Spinner";
import { useBallot } from "~/contexts/Ballot";
import { useMaci } from "~/contexts/Maci";
@@ -13,12 +13,11 @@ interface ISubmitBallotButtonProps {
export const SubmitBallotButton = ({ pollId }: ISubmitBallotButtonProps): JSX.Element => {
const router = useRouter();
- const [isOpen, setOpen] = useState(false);
const { onVote, isLoading, initialVoiceCredits } = useMaci();
const { getBallot, publishBallot, sumBallot } = useBallot();
- const onVotingError = useCallback(() => {
- toast.error("Voting error");
+ const onVotingError = useCallback((err: string) => {
+ toast.error(`Voting error: ${err}`);
}, []);
const ballot = useMemo(() => getBallot(pollId), [pollId, getBallot]);
@@ -28,6 +27,10 @@ export const SubmitBallotButton = ({ pollId }: ISubmitBallotButtonProps): JSX.El
);
const handleSubmitBallot = useCallback(async () => {
+ if (isLoading) {
+ return;
+ }
+
const votes = ballot.votes.map(({ amount, projectId, projectIndex }) => ({
projectId,
voteOptionIndex: BigInt(projectIndex),
@@ -44,36 +47,13 @@ export const SubmitBallotButton = ({ pollId }: ISubmitBallotButtonProps): JSX.El
});
}, [ballot, router, onVote, publishBallot, onVotingError, pollId, pollId]);
- const handleOpenDialog = useCallback(() => {
- setOpen(true);
- }, [setOpen]);
-
return (
- <>
-
+
);
};
diff --git a/packages/interface/src/layouts/DefaultLayout.tsx b/packages/interface/src/layouts/DefaultLayout.tsx
index 93b0a8d2..5225bd9b 100644
--- a/packages/interface/src/layouts/DefaultLayout.tsx
+++ b/packages/interface/src/layouts/DefaultLayout.tsx
@@ -104,7 +104,6 @@ export const LayoutWithSidebar = ({ ...props }: ILayoutProps): JSX.Element => {
return (