From 9764cc5208a34a1a265c0206330d2e04cd676e70 Mon Sep 17 00:00:00 2001 From: yzernik Date: Sat, 25 Jul 2020 19:59:03 -0700 Subject: [PATCH] Validate form input on makesqueak submit --- .../src/pages/makesqueak/MakeSqueak.js | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/frontend/react-material-admin/src/pages/makesqueak/MakeSqueak.js b/frontend/react-material-admin/src/pages/makesqueak/MakeSqueak.js index 1db104cc..8262ae71 100644 --- a/frontend/react-material-admin/src/pages/makesqueak/MakeSqueak.js +++ b/frontend/react-material-admin/src/pages/makesqueak/MakeSqueak.js @@ -37,7 +37,15 @@ export default function MakeSqueakPage() { console.log( 'profileId:', profileId); console.log( 'content:', content); console.log( 'replyto:', replyto); - makeSqueak(profileId, content, replyto); + if (profileId == -1) { + alert('Signing profile must be selected.'); + return; + } + if (!content) { + alert('Content cannot be empty.'); + return; + } + makeSqueak(profileId, content, replyto); } const handleChange = (event) => { @@ -83,9 +91,19 @@ export default function MakeSqueakPage() { getSigningProfiles() }, []); + function MakeSqueakForm() { + return ( +
+ {MakeSelectSigningProfile()} + {MakeSqueakContentInput()} + {MakeSqueakButton()} +
+ ) + } + function MakeSelectSigningProfile() { return ( - + Signing Profile