From 7c7f91e70fb506452aa4d5404b9d21fb62c97778 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Tue, 4 May 2021 15:08:41 +0530 Subject: [PATCH] feat: Add campaign (#2177) --- app/javascript/dashboard/api/campaigns.js | 9 + .../dashboard/i18n/locale/en/campaign.json | 44 ++- .../dashboard/settings/inbox/Settings.vue | 8 +- .../settings/inbox/components/AddCampaign.vue | 205 +++++++++++ .../settings/inbox/components/Campaign.vue | 51 ++- app/javascript/dashboard/store/index.js | 2 + .../dashboard/store/modules/campaigns.js | 65 ++++ .../modules/specs/campaigns/actions.spec.js | 30 ++ .../store/modules/specs/campaigns/fixtures.js | 348 ++++++++++++++++++ .../modules/specs/campaigns/getters.spec.js | 22 ++ .../modules/specs/campaigns/mutations.spec.js | 21 ++ .../dashboard/store/mutation-types.js | 5 + package.json | 1 + 13 files changed, 792 insertions(+), 19 deletions(-) create mode 100644 app/javascript/dashboard/api/campaigns.js create mode 100644 app/javascript/dashboard/routes/dashboard/settings/inbox/components/AddCampaign.vue create mode 100644 app/javascript/dashboard/store/modules/campaigns.js create mode 100644 app/javascript/dashboard/store/modules/specs/campaigns/actions.spec.js create mode 100644 app/javascript/dashboard/store/modules/specs/campaigns/fixtures.js create mode 100644 app/javascript/dashboard/store/modules/specs/campaigns/getters.spec.js create mode 100644 app/javascript/dashboard/store/modules/specs/campaigns/mutations.spec.js diff --git a/app/javascript/dashboard/api/campaigns.js b/app/javascript/dashboard/api/campaigns.js new file mode 100644 index 000000000..1c73a3360 --- /dev/null +++ b/app/javascript/dashboard/api/campaigns.js @@ -0,0 +1,9 @@ +import ApiClient from './ApiClient'; + +class CampaignsAPI extends ApiClient { + constructor() { + super('campaigns', { accountScoped: true }); + } +} + +export default new CampaignsAPI(); diff --git a/app/javascript/dashboard/i18n/locale/en/campaign.json b/app/javascript/dashboard/i18n/locale/en/campaign.json index 675fe0cd8..0d111b265 100644 --- a/app/javascript/dashboard/i18n/locale/en/campaign.json +++ b/app/javascript/dashboard/i18n/locale/en/campaign.json @@ -1,9 +1,49 @@ { "CAMPAIGN": { "HEADER": "Campaigns", - "HEADER_BTN_TXT": "Create Campaign", + "SIDEBAR_TXT": "Proactive messages allow the customer to send outbound messages to their contacts which would trigger more conversations. Click on Add Campaign to create a new campaign. You can also edit or delete an existing campaign by clicking on the Edit or Delete button.", + "HEADER_BTN_TXT": "Create a campaign", "LIST": { - "404": "There are no campaigns attached to this inbox" + "404": "There are no campaigns created for this inbox." + }, + "ADD": { + "TITLE": "Create a campaign", + "DESC": "Proactive messages allow the customer to send outbound messages to their contacts which would trigger more conversations.", + "CANCEL_BUTTON_TEXT": "Cancel", + "CREATE_BUTTON_TEXT": "Create", + "FORM": { + "TITLE": { + "LABEL": "Title", + "PLACEHOLDER": "Please enter the title of campaign", + "ERROR": "Title is required" + }, + "MESSAGE": { + "LABEL": "Message", + "PLACEHOLDER": "Please enter the message of campaign", + "ERROR": "Message is required" + }, + "SENT_BY": { + "LABEL": "Sent by", + "PLACEHOLDER": "Please select the the content of campaign", + "ERROR": "Sender is required" + }, + "END_POINT": { + "LABEL": "URL", + "PLACEHOLDER": "Please enter the URL", + "ERROR": "Please enter a valid URL" + }, + "TIME_ON_PAGE": { + "LABEL": "Time on page(Seconds)", + "PLACEHOLDER": "Please enter the time", + "ERROR": "Time on page is required" + }, + "ENABLED": "Enable campaign", + "SUBMIT": "Add Campaign" + }, + "API": { + "SUCCESS_MESSAGE": "Campaign created successfully", + "ERROR_MESSAGE": "There was an error. Please try again." + } } } } diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue index 2105101bb..69d4fe205 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue @@ -335,10 +335,10 @@ export default { if (this.isAWebWidgetInbox) { return [ ...visibleToAllChannelTabs, - { - key: 'campaign', - name: this.$t('INBOX_MGMT.TABS.CAMPAIGN'), - }, + // { + // key: 'campaign', + // name: this.$t('INBOX_MGMT.TABS.CAMPAIGN'), + // }, { key: 'preChatForm', name: this.$t('INBOX_MGMT.TABS.PRE_CHAT_FORM'), diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/components/AddCampaign.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/components/AddCampaign.vue new file mode 100644 index 000000000..47a6af4ba --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/components/AddCampaign.vue @@ -0,0 +1,205 @@ +