From 8b7f6c691aea399e6244c9a73377c2a5e325fbbb Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Fri, 24 Sep 2021 20:37:30 +0530 Subject: [PATCH] bug: fixes error in creating a new one off campaign (#3067) * bug: fixes error in creating a new one off campaign * Review fixes Co-authored-by: Muhsin Keloth --- .../routes/dashboard/settings/campaigns/AddCampaign.vue | 2 +- .../routes/dashboard/settings/campaigns/EditCampaign.vue | 2 +- app/javascript/dashboard/store/modules/inboxes.js | 5 +++++ .../dashboard/store/modules/specs/inboxes/fixtures.js | 2 +- .../dashboard/store/modules/specs/inboxes/getters.spec.js | 5 +++++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/javascript/dashboard/routes/dashboard/settings/campaigns/AddCampaign.vue b/app/javascript/dashboard/routes/dashboard/settings/campaigns/AddCampaign.vue index cf56f66e9..267188592 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/campaigns/AddCampaign.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/campaigns/AddCampaign.vue @@ -237,7 +237,7 @@ export default { if (this.isOngoingType) { return this.$store.getters['inboxes/getWebsiteInboxes']; } - return this.$store.getters['inboxes/getTwilioInboxes']; + return this.$store.getters['inboxes/getTwilioSMSInboxes']; }, sendersAndBotList() { return [ diff --git a/app/javascript/dashboard/routes/dashboard/settings/campaigns/EditCampaign.vue b/app/javascript/dashboard/routes/dashboard/settings/campaigns/EditCampaign.vue index 592a09fe7..deb3b56b6 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/campaigns/EditCampaign.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/campaigns/EditCampaign.vue @@ -161,7 +161,7 @@ export default { if (this.isOngoingType) { return this.$store.getters['inboxes/getWebsiteInboxes']; } - return this.$store.getters['inboxes/getTwilioInboxes']; + return this.$store.getters['inboxes/getTwilioSMSInboxes']; }, pageTitle() { return `${this.$t('CAMPAIGN.EDIT.TITLE')} - ${ diff --git a/app/javascript/dashboard/store/modules/inboxes.js b/app/javascript/dashboard/store/modules/inboxes.js index 6094608e6..b02d35f3f 100644 --- a/app/javascript/dashboard/store/modules/inboxes.js +++ b/app/javascript/dashboard/store/modules/inboxes.js @@ -73,6 +73,11 @@ export const getters = { item => item.channel_type === INBOX_TYPES.TWILIO ); }, + getTwilioSMSInboxes($state) { + return $state.records.filter( + item => item.channel_type === INBOX_TYPES.TWILIO && item.medium === 'sms' + ); + }, }; export const actions = { diff --git a/app/javascript/dashboard/store/modules/specs/inboxes/fixtures.js b/app/javascript/dashboard/store/modules/specs/inboxes/fixtures.js index 3a245aa2f..9db92b00a 100644 --- a/app/javascript/dashboard/store/modules/specs/inboxes/fixtures.js +++ b/app/javascript/dashboard/store/modules/specs/inboxes/fixtures.js @@ -49,10 +49,10 @@ export default [ name: 'Test Widget 5', channel_type: 'Channel::TwilioSms', avatar_url: null, + medium: 'sms', page_id: null, widget_color: '#68BC00', website_token: 'randomid125', enable_auto_assignment: true, }, - ]; diff --git a/app/javascript/dashboard/store/modules/specs/inboxes/getters.spec.js b/app/javascript/dashboard/store/modules/specs/inboxes/getters.spec.js index f70e372cb..f49d68e89 100644 --- a/app/javascript/dashboard/store/modules/specs/inboxes/getters.spec.js +++ b/app/javascript/dashboard/store/modules/specs/inboxes/getters.spec.js @@ -19,6 +19,11 @@ describe('#getters', () => { expect(getters.getTwilioInboxes(state).length).toEqual(1); }); + it('getTwilioSMSInboxes', () => { + const state = { records: inboxList }; + expect(getters.getTwilioSMSInboxes(state).length).toEqual(1); + }); + it('getInbox', () => { const state = { records: inboxList,