diff --git a/components/keys/VoteModal.tsx b/components/keys/VoteModal.tsx index 09ef691..60dccf5 100644 --- a/components/keys/VoteModal.tsx +++ b/components/keys/VoteModal.tsx @@ -44,13 +44,18 @@ export function VoteModal({ const handleSubmit = async () => { if (!address || selectedOption === null) return; - await voteMutation.mutateAsync({ - proposalId: proposal.id, - optionIndex: selectedOption, - walletAddress: address, - token: jwt, - }); - setRecorded(true); + try { + await voteMutation.mutateAsync({ + proposalId: proposal.id, + optionIndex: selectedOption, + walletAddress: address, + token: jwt, + }); + setRecorded(true); + } catch { + // react-query exposes the rejection as voteMutation.error so the error + // message below can be rendered; nothing else to do here. + } }; return ( @@ -109,6 +114,17 @@ export function VoteModal({

)} + {voteMutation.isError && ( +

+ {voteMutation.error instanceof Error + ? voteMutation.error.message + : "Vote submission failed. Please try again."} +

+ )} +