From 4ac728472416e636335131d0d8ba03779eaaf0a5 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 11 Apr 2018 10:49:12 +0200 Subject: [PATCH] improved code readability (comment from PR #18) --- web/src/components/Contact.js | 3 ++- web/src/components/LaunchRequest.js | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/web/src/components/Contact.js b/web/src/components/Contact.js index 669945b..4d8e141 100644 --- a/web/src/components/Contact.js +++ b/web/src/components/Contact.js @@ -40,7 +40,8 @@ class Contact extends Component { } handleEmailEdit(e){ - if (e.length === EMAIL_MAX_LENGTH) return; + const isEmailInvalid = e.length >= EMAIL_MAX_LENGTH; + if (isEmailInvalid) return; this.setState({contactEmail: e}); } } diff --git a/web/src/components/LaunchRequest.js b/web/src/components/LaunchRequest.js index a5337ea..a141dc6 100644 --- a/web/src/components/LaunchRequest.js +++ b/web/src/components/LaunchRequest.js @@ -52,12 +52,14 @@ class LaunchRequest extends Component { } handleNameEdit(e){ - if (e.length === INVOCATION_NAME_MAX_LENGTH || !(/^[a-z,.' ]*$/.test(e))) return; + const isInvocationNameInvalid = e.length === INVOCATION_NAME_MAX_LENGTH || !(/^[a-z,.' ]*$/.test(e)); + if (isInvocationNameInvalid) return; this.setState({invocationName: e}); } handleAnswerEdit(e){ - if (e.length === INVOCATION_ANSWER_MAX_LENGTH || !(/^[a-z,.' ]*$/i.test(e))) return; + const isInvocationAnswerInvalid = e.length === INVOCATION_ANSWER_MAX_LENGTH || !(/^[a-z,.' ]*$/i.test(e)); + if (isInvocationAnswerInvalid) return; this.setState({invocationAnswer: e}); } }