flip logic (comment from PR #18)
This commit is contained in:
@@ -40,10 +40,11 @@ class Contact extends Component {
|
||||
}
|
||||
|
||||
handleEmailEdit(e){
|
||||
const isEmailInvalid = e.length >= EMAIL_MAX_LENGTH;
|
||||
if (isEmailInvalid) return;
|
||||
const isEmailValid = e.length < EMAIL_MAX_LENGTH;
|
||||
if (isEmailValid){
|
||||
this.setState({contactEmail: e});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Contact;
|
||||
|
||||
@@ -155,45 +155,49 @@ class IntentDetails extends Component {
|
||||
}
|
||||
|
||||
handleQuestionEdit (e, index) {
|
||||
const isQuestionInvalid = e.length >= QUESTION_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e);
|
||||
if (isQuestionInvalid) return;
|
||||
const isQuestionValid = e.length < QUESTION_MAX_LENGTH && /^[a-z,.' ]*$/i.test (e);
|
||||
if (isQuestionValid){
|
||||
let newIntent = this.state.intent;
|
||||
newIntent.questions[index] = e;
|
||||
this.setState ({intent: newIntent});
|
||||
}
|
||||
}
|
||||
|
||||
handleIntentExplanationEdit (e, index) {
|
||||
const isExplanationInvalid = e.length >= INTENT_EXPLANATION_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e);
|
||||
if (isExplanationInvalid)
|
||||
return;
|
||||
const isExplanationValid = e.length < INTENT_EXPLANATION_MAX_LENGTH && /^[a-z,.' ]*$/i.test (e);
|
||||
if (isExplanationValid){
|
||||
let newIntent = this.state.intent;
|
||||
newIntent.intentExplanation = e;
|
||||
this.setState ({intent: newIntent});
|
||||
}
|
||||
}
|
||||
|
||||
handleAnswerEdit (e) {
|
||||
const isAnswerInvalid = e.length >= ANSWER_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e);
|
||||
if (isAnswerInvalid) return;
|
||||
const isAnswerValid = e.length < ANSWER_MAX_LENGTH && /^[a-z,.' ]*$/i.test (e);
|
||||
if (isAnswerValid){
|
||||
let newIntent = this.state.intent;
|
||||
newIntent.answer = e;
|
||||
this.setState ({intent: newIntent});
|
||||
}
|
||||
}
|
||||
|
||||
handleAnswerSourceEdit (e) {
|
||||
const isAnswerSourceInvalid = e.length >= ANSWER_MAX_LENGTH;
|
||||
if (isAnswerSourceInvalid) return;
|
||||
const isAnswerSourceValid = e.length < ANSWER_MAX_LENGTH;
|
||||
if (isAnswerSourceValid){
|
||||
let newIntent = this.state.intent;
|
||||
newIntent.externalAnswerSource = e;
|
||||
this.setState ({intent: newIntent});
|
||||
}
|
||||
}
|
||||
|
||||
handleIntentNameEdit (e) {
|
||||
const isIntentNameInvalid = e.length >= INTENT_NAME_MAX_LENGTH || !/^[a-z]*$/i.test (e);
|
||||
if (isIntentNameInvalid) return;
|
||||
const isIntentNameValid = e.length < INTENT_NAME_MAX_LENGTH && /^[a-z]*$/i.test (e);
|
||||
if (isIntentNameValid){
|
||||
let newIntent = this.state.intent;
|
||||
newIntent.intentName = e;
|
||||
this.setState ({intent: newIntent});
|
||||
}
|
||||
}
|
||||
|
||||
handleExternalSourceSave (answerType) {
|
||||
let newIntent = this.state.intent;
|
||||
|
||||
@@ -52,16 +52,18 @@ class LaunchRequest extends Component {
|
||||
}
|
||||
|
||||
handleNameEdit(e){
|
||||
const isInvocationNameInvalid = e.length === INVOCATION_NAME_MAX_LENGTH || !(/^[a-z,.' ]*$/.test(e));
|
||||
if (isInvocationNameInvalid) return;
|
||||
const isInvocationNameValid = e.length < INVOCATION_NAME_MAX_LENGTH && (/^[a-z,.' ]*$/.test(e));
|
||||
if (isInvocationNameValid) {
|
||||
this.setState({invocationName: e});
|
||||
}
|
||||
}
|
||||
|
||||
handleAnswerEdit(e){
|
||||
const isInvocationAnswerInvalid = e.length === INVOCATION_ANSWER_MAX_LENGTH || !(/^[a-z,.' ]*$/i.test(e));
|
||||
if (isInvocationAnswerInvalid) return;
|
||||
const isInvocationAnswerValid = e.length < INVOCATION_ANSWER_MAX_LENGTH && (/^[a-z,.' ]*$/i.test(e));
|
||||
if (isInvocationAnswerValid){
|
||||
this.setState({invocationAnswer: e});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default LaunchRequest;
|
||||
|
||||
Reference in New Issue
Block a user