From d8cd88a7abb978eed75e6354dcdb3f40cc2c2a3c Mon Sep 17 00:00:00 2001 From: Anshul Kahar <22511126.dypit@dypvp.edu.in> Date: Thu, 22 Aug 2024 14:08:46 +0530 Subject: [PATCH] fix the donate input bug --- public/locales/en/translation.json | 4 +++- src/screens/UserPortal/Donate/Donate.tsx | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 3b7b875821..8ba2734390 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -854,7 +854,9 @@ "yourPreviousDonations": "Your Previous Donations", "donate": "Donate", "nothingToShow": "Nothing to show here.", - "success": "Donation Successful" + "success": "Donation Successful", + "invalidAmount": "Please enter a numerical value for the donation amount.", + "donationAmountDescription": "Please enter the numerical value for the donation amount." }, "userEvents": { "title": "Events", diff --git a/src/screens/UserPortal/Donate/Donate.tsx b/src/screens/UserPortal/Donate/Donate.tsx index 4a87bd2490..869784ce1b 100644 --- a/src/screens/UserPortal/Donate/Donate.tsx +++ b/src/screens/UserPortal/Donate/Donate.tsx @@ -128,6 +128,11 @@ export default function donate(): JSX.Element { }, [donationData]); const donateToOrg = (): void => { + // check if the amount is non empty and is a number + if (amount === '' || Number.isNaN(Number(amount))) { + toast.error(t(`invalidAmount`)); + return; + } try { donate({ variables: { @@ -216,6 +221,9 @@ export default function donate(): JSX.Element { /> +