From b1dca46d9d37839f68827b66eab0f5903c2b382b Mon Sep 17 00:00:00 2001 From: Paulo Bernardo Date: Mon, 6 Nov 2023 17:03:39 -0300 Subject: [PATCH] feat: display error when button has variables --- src/components/BaseInput.vue | 13 +++++++++ .../whatsAppTemplates/FormTabContent.vue | 10 ++++++- .../FormTabContentButtons.vue | 28 +++++++++++++++++++ src/locales/en.json | 3 +- src/locales/es_es.json | 3 +- src/locales/pt_br.json | 3 +- 6 files changed, 56 insertions(+), 4 deletions(-) diff --git a/src/components/BaseInput.vue b/src/components/BaseInput.vue index 111593ce..80545c2e 100644 --- a/src/components/BaseInput.vue +++ b/src/components/BaseInput.vue @@ -6,6 +6,8 @@ :label="label" :placeholder="placeholder" :maxlength="maxlength" + :message="message" + :type="type" /> @@ -33,6 +35,17 @@ type: Number, default: 25, }, + message: { + type: String, + default: null, + }, + type: { + type: String, + default: 'normal', + validator(value) { + return ['normal', 'error'].indexOf(value) !== -1; + }, + }, replaceRegex: { type: RegExp, default: null, diff --git a/src/components/whatsAppTemplates/FormTabContent.vue b/src/components/whatsAppTemplates/FormTabContent.vue index dc293d52..cc93dc0d 100644 --- a/src/components/whatsAppTemplates/FormTabContent.vue +++ b/src/components/whatsAppTemplates/FormTabContent.vue @@ -172,6 +172,10 @@ value: false, message: '', }, + buttons: { + value: false, + message: '', + }, }, }; }, @@ -242,7 +246,11 @@ } this.updateTemplateForm({ fieldName, fieldValue }); }, - handleGenericInput({ fieldName, fieldValue }) { + handleGenericInput({ fieldName, fieldValue, hasIssue = false }) { + if (hasIssue) { + this.errorStates[fieldName].value = true; + } + this.updateTemplateTranslationForm({ formName: this.selectedForm, fieldName, diff --git a/src/components/whatsAppTemplates/FormTabContentButtons.vue b/src/components/whatsAppTemplates/FormTabContentButtons.vue index 2c429875..893e385a 100644 --- a/src/components/whatsAppTemplates/FormTabContentButtons.vue +++ b/src/components/whatsAppTemplates/FormTabContentButtons.vue @@ -57,6 +57,8 @@ :placeholder="$t('WhatsApp.templates.form_field.button_text_placeholder')" :maxlength="25" :replaceRegex="EMOJI_REGEX" + :message="errors[index] || null" + :type="errors[index] ? 'error' : 'normal'" @input="handleRepliesInput($event, index)" /> @@ -201,6 +203,7 @@