From d34464487d5383af692a135bad5effbc6d3120bf Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Fri, 3 May 2024 13:34:29 -0400 Subject: [PATCH] Show proper message to user and don't move forward, when proposal function encoding doesn't work --- src/components/ProposalBuilder/index.tsx | 9 ++++++++- src/i18n/locales/en/proposal.json | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/ProposalBuilder/index.tsx b/src/components/ProposalBuilder/index.tsx index 57e2fc3038..4a36fe4492 100644 --- a/src/components/ProposalBuilder/index.tsx +++ b/src/components/ProposalBuilder/index.tsx @@ -4,6 +4,7 @@ import { Formik, FormikProps } from 'formik'; import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; +import { toast } from 'react-toastify'; import { BACKGROUND_SEMI_TRANSPARENT } from '../../constants/common'; import { DAO_ROUTES, BASE_ROUTES } from '../../constants/routes'; import useSubmitProposal from '../../hooks/DAO/proposal/useSubmitProposal'; @@ -61,7 +62,11 @@ export default function ProposalBuilder({ initialValues={initialValues} enableReinitialize onSubmit={async values => { - if (canUserCreateProposal) { + if (!false) { + toast(t('errorNotProposer', { ns: 'common' })); + } + + try { const proposalData = await prepareProposalData(values); if (proposalData) { submitProposal({ @@ -73,6 +78,8 @@ export default function ProposalBuilder({ successCallback, }); } + } catch { + toast(t('encodingFailedMessage', { ns: 'proposal' })); } }} > diff --git a/src/i18n/locales/en/proposal.json b/src/i18n/locales/en/proposal.json index fe1656b144..44af3c0e58 100644 --- a/src/i18n/locales/en/proposal.json +++ b/src/i18n/locales/en/proposal.json @@ -104,6 +104,7 @@ "multisigMetadataMessage": "This transaction contains the proposal's encoded metadata.", "multisigMetadataWarning": "Adding metadata (title, description, url) to a multisig proposal will add execution cost.", "decodingFailedMessage": "Unable to decode transaction's data.", + "encodingFailedMessage": "Unable to encode proposal data.", "customNonce": "Custom Nonce", "customNonceTooltip": "Set a custom proposal nonce if necessary to prevent nonce collisions", "nonce": "Nonce",