diff --git a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json index daaae8062..669f07946 100644 --- a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json +++ b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json @@ -472,7 +472,11 @@ "ALLOW_MESSAGES_AFTER_RESOLVED": "Allow messages after conversation resolved", "ALLOW_MESSAGES_AFTER_RESOLVED_SUB_TEXT": "Allow the end-users to send messages even after the conversation is resolved.", "WHATSAPP_SECTION_SUBHEADER": "This API Key is used for the integration with the WhatsApp APIs.", - "WHATSAPP_SECTION_TITLE": "API Key" + "WHATSAPP_SECTION_UPDATE_SUBHEADER": "Enter the updated key to be used for the integration with the WhatsApp APIs.", + "WHATSAPP_SECTION_TITLE": "API Key", + "WHATSAPP_SECTION_UPDATE_TITLE": "Update API Key", + "WHATSAPP_SECTION_UPDATE_PLACEHOLDER": "Enter the new API Key here", + "WHATSAPP_SECTION_UPDATE_BUTTON": "Update" }, "AUTO_ASSIGNMENT": { "MAX_ASSIGNMENT_LIMIT": "Auto assignment limit", diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/settingsPage/ConfigurationPage.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/settingsPage/ConfigurationPage.vue index 0229f03b3..2206ae7d1 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/settingsPage/ConfigurationPage.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/settingsPage/ConfigurationPage.vue @@ -103,6 +103,31 @@ > + +
+ + + {{ $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')); } }, }, }; +