+
+
+
+ {{ $t('INBOX_MGMT.SETTINGS_POPUP.WHATSAPP_SECTION_UPDATE_BUTTON') }}
+
+
+
@@ -114,6 +139,7 @@ import SettingsSection from '../../../../../components/SettingsSection';
import ImapSettings from '../ImapSettings';
import SmtpSettings from '../SmtpSettings';
import MicrosoftReauthorize from '../channels/microsoft/Reauthorize';
+import { required } from 'vuelidate/lib/validators';
export default {
components: {
@@ -132,8 +158,12 @@ export default {
data() {
return {
hmacMandatory: false,
+ whatsAppInboxAPIKey: '',
};
},
+ validations: {
+ whatsAppInboxAPIKey: { required },
+ },
watch: {
inbox() {
this.setDefaults();
@@ -161,9 +191,45 @@ export default {
await this.$store.dispatch('inboxes/updateInbox', payload);
this.showAlert(this.$t('INBOX_MGMT.EDIT.API.SUCCESS_MESSAGE'));
} catch (error) {
+ this.showAlert(this.$t('INBOX_MGMT.EDIT.API.ERROR_MESSAGE'));
+ }
+ },
+ async updateWhatsAppInboxAPIKey() {
+ try {
+ const payload = {
+ id: this.inbox.id,
+ formData: false,
+ channel: {},
+ };
+
+ payload.channel.provider_config = {
+ ...this.inbox.provider_config,
+ api_key: this.whatsAppInboxAPIKey,
+ };
+
+ await this.$store.dispatch('inboxes/updateInbox', payload);
this.showAlert(this.$t('INBOX_MGMT.EDIT.API.SUCCESS_MESSAGE'));
+ } catch (error) {
+ this.showAlert(this.$t('INBOX_MGMT.EDIT.API.ERROR_MESSAGE'));
}
},
},
};
+