@capillarytech/creatives-library 8.0.65 → 8.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.65",
4
+ "version": "8.0.67",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -94,9 +94,13 @@ describe("Creatives testing template creation", () => {
94
94
  name: globalMessages.email.defaultMessage,
95
95
  });
96
96
  await userEvent.click(whatsapp);
97
- expect(await creativesScreen.findByText(
98
- /Whatsapp accounts are not setup for your brand/i, undefined, { timeout: 10000 })
99
- ).toBeInTheDocument();
97
+ waitFor(() => {
98
+ expect(
99
+ creativesScreen.getByText(
100
+ /Whatsapp accounts are not setup for your brand/i
101
+ )
102
+ ).toBeInTheDocument();
103
+ }, { timeout: 50000, interval: 500 });
100
104
  await userEvent.click(line);
101
105
  //assertions for template filters for line channel
102
106
  expect(creativesScreen.getByText(/rich video message/i)).toBeInTheDocument();
@@ -0,0 +1,11 @@
1
+ <svg width="152" height="152" viewBox="0 0 152 152" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M86.9122 17.3023C106.492 7.08226 130.722 14.6223 141.322 44.7423C148.432 64.9823 149.082 88.5923 137.812 106.942C132.312 115.902 123.992 123.602 112.212 129.052C107.701 131.125 102.981 132.707 98.1322 133.772C97.6822 133.882 97.1622 133.992 96.6822 134.072C78.9322 137.702 59.5622 135.072 43.2022 128.072L42.8522 127.912C28.4122 121.622 16.3222 111.892 9.85221 99.9723C9.83606 99.944 9.8199 99.9125 9.80309 99.8796C9.77827 99.8312 9.75202 99.78 9.72221 99.7323C-0.927788 79.8523 8.75221 66.6223 16.0722 60.1623C18.7689 57.8105 21.8026 55.8757 25.0722 54.4223C34.0723 50.3945 42.7163 45.6142 50.9122 40.1323C62.9722 31.8323 75.7522 23.1323 86.9122 17.3023ZM35.1022 30.6523C35.1022 30.6523 27.7822 38.6523 32.4922 42.8423C36.1322 46.1023 47.4922 40.2323 48.1222 34.7123C48.6322 30.7523 42.4222 23.6723 35.1322 30.6523H35.1022ZM25.2122 46.1223C25.2122 46.1223 21.8422 45.2723 21.9622 49.1923C22.0822 53.1123 25.7522 51.3623 26.8322 50.5823C27.9122 49.8023 29.6322 46.9623 25.2122 46.1223Z" fill="#FFD24B"/>
3
+ <path d="M57.0425 61.592C53.7025 61.502 55.3525 61.242 59.4725 60.382C62.9825 59.652 67.6325 58.492 70.1325 56.702C79.1325 50.262 88.1325 50.122 93.2325 62.242C104.012 87.922 114.522 113.502 99.8525 134.772C99.8525 134.772 103.963 115.032 100.222 104.772C100.222 104.772 93.3525 114.152 82.9025 113.462C82.9025 113.462 99.9025 90.822 91.9025 83.042C91.9025 83.042 72.5125 73.042 74.4325 91.732C74.4325 91.732 76.6125 103.852 80.9825 109.802C80.9825 109.802 73.3325 109.342 69.1225 103.632C69.1225 103.632 66.7425 112.902 69.8825 135.632C69.8825 135.632 55.2025 118.202 68.1125 84.102C70.4025 78.122 84.2125 62.362 57.0425 61.592Z" fill="#103344"/>
4
+ <path d="M69.4523 132.793C66.3123 110.103 69.2123 103.603 69.2123 103.603C72.1223 107.543 76.6723 108.983 79.2123 109.503C79.5447 109.528 79.8631 109.364 80.0346 109.078C80.2061 108.792 80.2014 108.434 80.0223 108.153C76.3623 101.873 74.5323 91.7027 74.5323 91.7027C72.0523 72.0127 89.9823 77.7027 92.6923 81.8127C98.4323 90.6527 87.6323 106.813 83.9723 112.013C83.7754 112.277 83.7369 112.628 83.8718 112.928C84.0067 113.229 84.2938 113.434 84.6223 113.463C94.1323 113.123 100.272 104.743 100.272 104.743C104.012 115.033 99.8023 134.473 99.8023 134.473L99.3723 138.563L69.9123 135.623L69.4523 132.793Z" fill="white"/>
5
+ <path d="M90.2121 132.703C90.2068 135.463 88.2475 137.833 85.5375 138.357C82.8275 138.881 80.1259 137.412 79.0921 134.853C78.8219 134.182 78.6828 133.466 78.6821 132.743C78.6821 129.563 81.2721 123.643 84.4521 123.643C85.7743 123.783 86.9599 124.52 87.6721 125.643C88.0469 126.142 88.3813 126.67 88.6721 127.223C88.698 127.288 88.7281 127.351 88.7621 127.413C89.6281 129.048 90.1231 130.854 90.2121 132.703Z" fill="#A61426"/>
6
+ <path d="M89.8224 131.882C89.822 134.474 88.0962 136.749 85.6001 137.447C83.104 138.146 80.4481 137.097 79.1024 134.882C78.8322 134.211 78.693 133.495 78.6924 132.772C78.6924 129.592 81.2824 123.672 84.4624 123.672C85.7845 123.813 86.9702 124.549 87.6824 125.672C88.0571 126.171 88.3915 126.7 88.6824 127.252C88.7083 127.317 88.7383 127.381 88.7724 127.442C89.3938 128.844 89.7498 130.35 89.8224 131.882Z" fill="#D5192E"/>
7
+ <path d="M89.2124 130.993C89.2124 132.523 88.6045 133.99 87.5224 135.073C86.4403 136.155 84.9727 136.763 83.4424 136.763C81.7946 136.765 80.2265 136.054 79.1424 134.813C78.8722 134.142 78.7331 133.426 78.7324 132.703C78.7324 129.523 81.3224 123.603 84.5024 123.603C85.8246 123.743 87.0102 124.48 87.7224 125.603C88.6118 127.267 89.1207 129.108 89.2124 130.993Z" fill="#ED1D34"/>
8
+ <circle cx="78.2624" cy="58.3127" r="1.34" fill="white"/>
9
+ <circle cx="78.262" cy="58.3118" r="0.68" fill="black"/>
10
+ <ellipse cx="82.5535" cy="126.552" rx="1.51" ry="0.9" transform="rotate(-62.05 82.5535 126.552)" fill="#F47988"/>
11
+ </svg>
@@ -980,8 +980,8 @@ Click {{unsubscribe}} to unsubscribe
980
980
  "base": Object {
981
981
  "content": Object {
982
982
  "whatsapp": Object {
983
- "accessToken": "Bearer gDwEuRIm9icV6phixociSw==",
984
- "accountId": "107499611940863",
983
+ "accessToken": "Bearer abcd",
984
+ "accountId": "12345",
985
985
  "buttonType": "CTA",
986
986
  "buttons": Array [
987
987
  Object {
@@ -73,3 +73,8 @@ export const GET_SENDER_DETAILS_FAILURE =
73
73
  export const GET_CDN_TRANSFORMATION_CONFIG_REQUEST = 'app/v2Containers/Templates/GET_CDN_TRANSFORMATION_CONFIG_REQUEST';
74
74
  export const GET_CDN_TRANSFORMATION_CONFIG_SUCCESS = 'app/v2Containers/Templates/GET_CDN_TRANSFORMATION_CONFIG_SUCCESS';
75
75
  export const GET_CDN_TRANSFORMATION_CONFIG_FAILURE = 'app/v2Containers/Templates/GET_CDN_TRANSFORMATION_CONFIG_FAILURE';
76
+
77
+ export const ACCOUNT_MAPPING_ON_CHANNEL = {
78
+ whatsapp: 'selectedWhatsappAccount',
79
+ zalo: 'selectedZaloAccount',
80
+ };
@@ -21,6 +21,7 @@ import cloneDeep from 'lodash/cloneDeep';
21
21
  import find from 'lodash/find';
22
22
  import map from 'lodash/map';
23
23
  import { bindActionCreators } from 'redux';
24
+ import { Modal, Form} from 'antd';
24
25
  import {
25
26
  CapMenu,
26
27
  CapDropdown,
@@ -96,16 +97,18 @@ import {
96
97
  FACEBOOK as FACEBOOK_CHANNEL,
97
98
  CREATE,
98
99
  } from '../App/constants';
99
- import {MAX_WHATSAPP_TEMPLATES, WARNING_WHATSAPP_TEMPLATES } from './constants';
100
+ import {MAX_WHATSAPP_TEMPLATES, WARNING_WHATSAPP_TEMPLATES , ACCOUNT_MAPPING_ON_CHANNEL} from './constants';
100
101
  import { COPY_OF } from '../../containers/App/constants';
101
102
  import {
103
+ TWILIO_CATEGORY_OPTIONS,
104
+ KARIX_GUPSHUP_CATEGORY_OPTIONS,
102
105
  STATUS_OPTIONS,
103
106
  CATEGORY,
104
107
  WHATSAPP_CATEGORIES,
105
108
  STATUS as WHATSAPP_STATUS,
106
109
  WHATSAPP_STATUSES,
110
+ HOST_TWILIO,
107
111
  HOST_GUPSHUP,
108
- CATEGORY_OPTIONS_MAP,
109
112
  } from '../Whatsapp/constants';
110
113
  import { INAPP_LAYOUT_DETAILS } from '../InApp/constants';
111
114
  import { ZALO_STATUS_OPTIONS, ZALO_STATUSES } from '../Zalo/constants';
@@ -123,6 +126,7 @@ import emailIllustration from '../Assets/images/emailIllustration.svg';
123
126
  import smsIllustration from '../Assets/images/smsIllustration.svg';
124
127
  import pushIllustration from '../Assets/images/pushIllustration.svg';
125
128
  import whatsappIllustration from '../Assets/images/whatsappIllustration.png';
129
+ import whatsappOrZaloAccountIllustration from '../Assets/images/whatsappOrZaloAccountIllustration.svg';
126
130
  import rcsIllustration from '../Assets/images/rcsIllustration.png';
127
131
  import zaloillustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
128
132
  import inAppIllustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
@@ -247,6 +251,26 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
247
251
  this.delayTimer = 0;
248
252
  }
249
253
 
254
+ // This function is to map the selected source account identifier and the connectionProperties data of domainPropertiesData object to get the hostName.
255
+ getHostName(selectedSourceAccountIdentifier, domainPropertiesData = []) {
256
+ if (!selectedSourceAccountIdentifier || isEmpty(domainPropertiesData)) {
257
+ this.setState({ hostName: '' });
258
+ return '';
259
+ }
260
+
261
+ const domainHostName = domainPropertiesData?.find(({ domainProperties }) => {
262
+ const {
263
+ connectionProperties: { account_sid, wabaId, userid, sourceAccountIdentifier, oa_id } = {},
264
+ } = domainProperties || {};
265
+ // If sourceAccountIdentifier is not present in the domainProperties object, then it will try to find in account_sid, wabaId, user_id.
266
+ // wabaId, user_id, account_sid are for Karix, Gupshup, and Twilio (Whatsapp) respectively and oa_id is for Zalo.
267
+ return [account_sid, wabaId, userid, oa_id, sourceAccountIdentifier].includes(selectedSourceAccountIdentifier);
268
+ })?.domainProperties?.hostName || '';
269
+
270
+ this.setState({ hostName: domainHostName });
271
+ return domainHostName;
272
+ }
273
+
250
274
  componentWillMount() {
251
275
  if (this.state.channel === '') {
252
276
  let channel = '';
@@ -609,51 +633,65 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
609
633
  if (!isEmpty(nextProps.Templates.templateDetails) && !isEqual(nextProps.Templates.templateDetails, this.props.Templates.templateDetails)) {
610
634
  this.setState({ previewTemplate: nextProps.Templates.templateDetails });
611
635
  }
612
- const { weCrmAccounts: weCrmAccountsList = [], senderDetails: { hostName = '' } = {} } = get(nextProps, 'Templates', {});
613
- const weCrmChannels = ['wechat', WHATSAPP_LOWERCASE, ZALO_LOWERCASE];
636
+ const { weCrmAccounts: weCrmAccountsList = [], senderDetails = {} } = get(nextProps, 'Templates', {});
637
+ const weCrmChannels = [WHATSAPP_LOWERCASE, ZALO_LOWERCASE];
614
638
 
615
- if (weCrmAccountsList.length === 1 && this.state.defaultAccount && (weCrmChannels.indexOf(selectedChannel) > -1) && !isEmpty(hostName)) {
616
- let paramsDefault = {};
617
- if (this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
618
- paramsDefault = {
619
- name: this.state.searchText,
620
- sortBy: this.state.sortBy,
621
- };
622
- }
623
-
624
- const {name, sourceAccountIdentifier, configs } = weCrmAccountsList?.[0] || {};
639
+ // Keeping the wechat flow separate as it has different logic for setting the account. Currently we don't support wechat but still keeping the flow.
640
+ if (weCrmAccountsList?.length === 1 && this.state?.defaultAccount && selectedChannel === WECHAT_LOWERCASE && !isEmpty(senderDetails?.hostName)) {
641
+ const { sourceAccountIdentifier, configs } = weCrmAccountsList?.[0] || {};
625
642
  const {
626
- token,
627
643
  wecrm_app_id,
628
644
  wecrm_token
629
645
  } = configs || {};
630
- if (weCrmChannels.includes(selectedChannel)) {
631
- if ([WHATSAPP_LOWERCASE, ZALO_LOWERCASE].includes(selectedChannel)) {
632
- if (hostName === '') {
633
- return;
634
- }
635
646
 
636
- weCrmAccountsList[0].hostName = hostName;
637
- nextProps.actions.setChannelAccount(selectedChannel.toUpperCase(), weCrmAccountsList[0]);
638
- if (selectedChannel === ZALO_LOWERCASE) {
639
- paramsDefault.username = name;
640
- paramsDefault.oa_id = sourceAccountIdentifier;
641
- paramsDefault.token = token;
642
- paramsDefault.host = hostName || this.props.Templates?.senderDetails?.hostName || this.props.Templates?.selectedZaloAccount?.hostName || this.state.hostName;
643
- }
644
- } else {
645
- paramsDefault.wecrmId = wecrm_app_id;
646
- paramsDefault.wecrmToken = wecrm_token;
647
- paramsDefault.originalId = sourceAccountIdentifier;
648
- nextProps.actions.setWeChatAccount(
649
- weCrmAccountsList[0],
650
- );
651
- }
652
-
647
+ const paramsDefault = {
648
+ wecrmId: wecrm_app_id,
649
+ wecrmToken: wecrm_token,
650
+ originalId: sourceAccountIdentifier,
651
+ name: this.state.searchText,
652
+ sortBy: this.state.sortBy,
653
653
  }
654
+ nextProps.actions.setWeChatAccount(weCrmAccountsList[0]);
654
655
  this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: weCrmAccountsList[0].name, hostName: weCrmAccountsList[0].hostName });
655
656
  this.getAllTemplates({params: paramsDefault}, true);
656
657
  }
658
+
659
+ if (weCrmAccountsList?.length && this.state?.defaultAccount && (weCrmChannels.includes(selectedChannel))) {
660
+ const isSingleAccount = weCrmAccountsList?.length === 1;
661
+ const selectedAccount = this.props.Templates[ACCOUNT_MAPPING_ON_CHANNEL[selectedChannel]] || {};
662
+ const hostName = this.getHostName(isSingleAccount ? weCrmAccountsList[0]?.sourceAccountIdentifier : selectedAccount?.sourceAccountIdentifier, senderDetails?.domainProperties);
663
+
664
+ if (!isEmpty(hostName)) {
665
+ const paramsDefault = {};
666
+ const {name, sourceAccountIdentifier, configs } = weCrmAccountsList?.[0] || {};
667
+ if (isSingleAccount) {
668
+ weCrmAccountsList[0].hostName = hostName;
669
+ } else {
670
+ selectedAccount.hostName = hostName;
671
+ }
672
+ nextProps.actions.setChannelAccount(selectedChannel?.toUpperCase(), isSingleAccount ? weCrmAccountsList[0] : selectedAccount);
673
+ if (selectedChannel === ZALO_LOWERCASE) {
674
+ paramsDefault.username = name;
675
+ paramsDefault.oa_id = sourceAccountIdentifier;
676
+ paramsDefault.token = configs?.token;
677
+ paramsDefault.host = hostName || this.props.Templates?.selectedZaloAccount?.hostName;
678
+ }
679
+ if (selectedChannel === WHATSAPP_LOWERCASE) {
680
+ paramsDefault.accountId = sourceAccountIdentifier;
681
+ paramsDefault.host = hostName || this.props.Templates?.selectedWhatsappAccount?.hostName;
682
+ paramsDefault.name = this.state.searchText;
683
+ paramsDefault.sortBy = this.state.sortBy;
684
+ }
685
+ this.setState({ defaultAccount: false });
686
+ /**
687
+ * Incase of multiple accounts, getAllTemplates is called on selecting the account. It's handled in onAccountSelect function.
688
+ * But for single account, onAccountSelect function won't get executed and getAllTemplates will be excuted.
689
+ */
690
+ if (weCrmAccountsList?.length === 1) {
691
+ this.getAllTemplates({ params: paramsDefault }, true);
692
+ }
693
+ }
694
+ }
657
695
  const zaloPreviewUrl = get(nextProps, 'Zalo.zaloTemplatePreviewData.versions.base.content.zalo.previewUrl', '');
658
696
  if (zaloPreviewUrl && this.state.channel.toLowerCase() === ZALO_LOWERCASE) {
659
697
  handlePreviewInNewTab(zaloPreviewUrl);
@@ -678,6 +716,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
678
716
  params.sortBy = this.state.sortBy;
679
717
  }
680
718
  const selectedChannel = this.state.channel.toLowerCase();
719
+ const isZaloOrWhatsapp = [ZALO_LOWERCASE, WHATSAPP_LOWERCASE].includes(selectedChannel);
681
720
  if (selectedChannel === 'wechat') {
682
721
  params.wecrmId = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})].configs.wecrm_app_id;
683
722
  params.wecrmToken = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})].configs.wecrm_token;
@@ -697,26 +736,41 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
697
736
  } else {
698
737
  this.setState({ selectedAccountError: false });
699
738
  }
700
- } else if ([LINE.toLowerCase(), RCS_LOWERCASE, ZALO_LOWERCASE].includes(selectedChannel)) {
739
+ } else if ([LINE.toLowerCase(), RCS_LOWERCASE, ZALO_LOWERCASE, WHATSAPP_LOWERCASE].includes(selectedChannel)) {
701
740
  const setAcc = this.props?.Templates?.weCrmAccounts?.find((item) => item?.name === this.state.selectedAccount);
741
+ const { domainProperties = [] } = this.props?.Templates?.senderDetails || {};
742
+ let hostName = '';
743
+ if (isZaloOrWhatsapp) {
744
+ hostName = this.getHostName(setAcc?.sourceAccountIdentifier, domainProperties);
745
+ setAcc.hostName = hostName;
746
+ }
702
747
  this.props.actions.setChannelAccount(selectedChannel?.toUpperCase(), setAcc);
703
- if(selectedChannel === ZALO_LOWERCASE){
704
- const {
705
- name = "",
706
- sourceAccountIdentifier = "",
707
- configs: { token = "" } = {},
708
- } = setAcc || {};
748
+
749
+ const {
750
+ name = "",
751
+ sourceAccountIdentifier = "",
752
+ configs: { token = "" } = {},
753
+ } = setAcc || {};
754
+
755
+ if(selectedChannel === ZALO_LOWERCASE && hostName) {
709
756
  params.username = name;
710
757
  params.oa_id = sourceAccountIdentifier;
711
758
  params.token = token;
712
759
  params.isAccountSelection = true;
713
- params.host = this.props.Templates?.senderDetails?.hostName || this.props.Templates?.selectedZaloAccount?.hostName || this.state.hostName;
760
+ params.host = hostName;
761
+ }
762
+ if (selectedChannel === WHATSAPP_LOWERCASE && hostName) {
763
+ params.accountId = sourceAccountIdentifier;
764
+ params.host = hostName;
714
765
  }
715
766
  }
716
767
 
717
- this.setState({activeMode: TEMPLATES_MODE});
718
-
719
- this.getAllTemplates({params, resetPage: true});
768
+ this.setState({ activeMode: TEMPLATES_MODE }, () => {
769
+ // Restrict getAllTemplates call only if selectedChannel is ZALO or WHATSAPP and hostName is empty
770
+ if (!(isZaloOrWhatsapp && !params?.host)) {
771
+ this.getAllTemplates({ params, resetPage: true });
772
+ }
773
+ });
720
774
  });
721
775
  }
722
776
  onPaginationChange = () => {
@@ -794,6 +848,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
794
848
 
795
849
  moment.locale(locale);
796
850
  };
851
+
852
+ setWhatsappQueryParams = (queryParams, params) => {
853
+ queryParams.accountId = params?.accountId || this.props.Templates?.selectedWhatsappAccount?.sourceAccountIdentifier;
854
+ queryParams.host = params?.host || this.state?.hostName;
855
+ };
856
+
797
857
  getAllTemplates = ({params, getNextPage, resetPage}, resetTemplates) => {
798
858
  let queryParams = params || {};
799
859
  let page = this.state.page;
@@ -822,6 +882,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
822
882
  if (([MOBILE_PUSH_LOWERCASE, INAPP_LOWERCASE].includes(channel.toLowerCase())) && !isEmpty(this.props.Templates.selectedWeChatAccount)) {
823
883
  queryParams.accountId = this.props.Templates?.selectedWeChatAccount?.id;
824
884
  }
885
+ if (this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE) {
886
+ this.setWhatsappQueryParams(queryParams, params);
887
+ }
825
888
  this.props.actions.getAllTemplates(channel, queryParams,`${copyOf}`);
826
889
  } else if ((resetPage || (page === 1 && this.state.templatesCount === 0) || page <= (this.state.templatesCount / this.state.perPageLimit))) {
827
890
  if (getNextPage) {
@@ -871,6 +934,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
871
934
  queryParams.token = token;
872
935
  queryParams.host = hostName || this.props.Templates?.senderDetails?.hostName ||this.state.hostName;
873
936
  }
937
+ if (this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE) {
938
+ this.setWhatsappQueryParams(queryParams, params);
939
+ }
874
940
  this.setState({ page, templatesCount }, () => {
875
941
  queryParams.page = page;
876
942
  queryParams.perPage = this.state.perPageLimit;
@@ -1017,7 +1083,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1017
1083
  filteredTemplates = this.filterWechatTemplates(templates);
1018
1084
  break;
1019
1085
  case WHATSAPP:
1020
- filteredTemplates = this.filterWhatsappTemplates(templates);
1086
+ filteredTemplates = this.state?.hostName ? this.filterWhatsappTemplates(templates) : [];
1021
1087
  break;
1022
1088
  case LINE:
1023
1089
  filteredTemplates = this.filterLineTemplates(templates);
@@ -1378,19 +1444,20 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1378
1444
 
1379
1445
  const accountId = get(this.props, 'Templates.selectedWeChatAccount.uuid');
1380
1446
  const accounts = get(this.props, 'Templates.weCrmAccounts');
1381
- const noWhatsappZaloTemplates = this.isFullMode() && isEmpty(templates);
1447
+ const getAllTemplatesInProgress = get(this.props, 'Templates.getAllTemplatesInProgress');
1448
+ const noWhatsappZaloTemplates = this.isFullMode() && isEmpty(templates) || !this.state.hostName;
1382
1449
  const noFilteredWhatsappZaloTemplates = this.isFullMode() && !isEmpty(templates) && isEmpty(filteredTemplates);
1383
- const noApprovedWhatsappZaloTemplates = !this.isFullMode() && isEmpty(filteredTemplates);
1384
- const showWhatsappIllustration = !isEmpty(this.props.Templates.selectedWhatsappAccount) && [WHATSAPP_LOWERCASE].includes(channelLowerCase);
1450
+ const noApprovedWhatsappZaloTemplates = !this.isFullMode() && isEmpty(filteredTemplates) && !isEmpty(this.state?.hostName);;
1451
+ const showWhatsappIllustration = (!isEmpty(this.props.Templates.selectedWhatsappAccount) && [WHATSAPP_LOWERCASE].includes(channelLowerCase)) || !this.state?.hostName ;
1385
1452
  const showZaloIllustration = !isEmpty(this.props.Templates.selectedZaloAccount) && [ZALO_LOWERCASE].includes(channelLowerCase);
1386
1453
  const showRcsIllustration = channelLowerCase === RCS_LOWERCASE && isEmpty(templates);
1387
1454
  const showInAppIllustration = channelLowerCase === INAPP_LOWERCASE && isEmpty(templates);
1388
1455
  const noLoaderAndSearchText = isEmpty(this.state.searchText) && !isLoading;
1389
1456
  return (<div>
1390
- {[WECHAT, MOBILE_PUSH, INAPP].includes(currentChannel) && this.showAccountName()}
1457
+ {[WECHAT, MOBILE_PUSH, INAPP, WHATSAPP, ZALO].includes(currentChannel) && this.showAccountName()}
1391
1458
  {filterContent}
1392
1459
  {[WHATSAPP, ZALO].includes(currentChannel) && this.selectedFilters()}
1393
- <CapCustomSkeleton loader={isLoading}>
1460
+ <CapCustomSkeleton loader={isLoading || getAllTemplatesInProgress}>
1394
1461
  {<div>
1395
1462
  {!isEmpty(filteredTemplates) || !isEmpty(this.state.searchText) || !isEmpty(this.props.Templates.templateError) ? (
1396
1463
  <div className={!isEmpty(this.state.searchText) && isEmpty(cardDataList) ? '' : "pagination-container"}>
@@ -1424,15 +1491,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1424
1491
  isEmpty(filteredTemplates) &&
1425
1492
  isEmpty(this.state.searchText) &&
1426
1493
  <div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto'} : {}}>
1427
- <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />
1494
+ <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel, this.state?.hostName)} />
1428
1495
  </div>
1429
1496
  )
1430
1497
  }
1431
1498
  {(showWhatsappIllustration || showZaloIllustration) && (
1432
1499
  noLoaderAndSearchText &&
1433
1500
  <div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto' } : {}}>
1434
- {noWhatsappZaloTemplates && <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />}
1435
- {noFilteredWhatsappZaloTemplates && this.whatsappZaloIllustrationText('noFilteredWhatsappZaloTemplatesTitle', 'noFilteredWhatsappZaloTemplatesDesc')}
1501
+ {noWhatsappZaloTemplates && <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel, isEmpty(this.state?.hostName))} />}
1502
+ {noFilteredWhatsappZaloTemplates && this.state?.hostName && this.whatsappZaloIllustrationText('noFilteredWhatsappZaloTemplatesTitle', 'noFilteredWhatsappZaloTemplatesDesc')}
1436
1503
  {noApprovedWhatsappZaloTemplates && this.whatsappZaloIllustrationText('noApprovedWhatsappZaloTemplatesTitle', showWhatsappIllustration ? 'noApprovedWhatsappTemplatesDesc' : 'zaloDescIllustration')}
1437
1504
  </div>
1438
1505
  )
@@ -1577,6 +1644,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1577
1644
  prepareWeChatPreviewData(template) {
1578
1645
  if (template && template.versions && template.versions.base && !isEmpty(template.versions.base)) {
1579
1646
  if (template.definition && template.definition.msgcontent && template.definition.msgcontent === "RICH_MEDIA_WECHAT") {
1647
+ console.log("prepareWeChatPreviewData", template, JSON.stringify(template), template.versions.base.mediaList, JSON.stringify(template.versions.base.mediaList));
1580
1648
  return template.versions.base.mediaList;
1581
1649
  }
1582
1650
  return this.prepareWeChatMappedPreviewData(template.versions.base.content, template.versions.base.Tag, template.versions.base.data);
@@ -1836,6 +1904,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1836
1904
  }
1837
1905
  if (this.state.channel.toLowerCase() === MOBILE_PUSH_LOWERCASE) {
1838
1906
  params.accountId = this.props.Templates.selectedWeChatAccount.id;
1907
+ } else if (this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE) {
1908
+ params.accountId = this.props.Templates?.selectedWhatsappAccount?.sourceAccountIdentifier;
1909
+ params.host = this.state?.hostName;
1839
1910
  }
1840
1911
  this.delay(() => {
1841
1912
  this.getAllTemplates({params, resetPage: true});
@@ -2439,7 +2510,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2439
2510
  (rcsLoader !== undefined ? rcsLoader : false);
2440
2511
  return isLoading;
2441
2512
  }
2442
- getChannelTypeIllustrationInfo = (type) => {
2513
+ getChannelTypeIllustrationInfo = (type, hostNameNotFound) => {
2443
2514
  const { isFullMode, intl } = this.props;
2444
2515
  const templateIntlMsg = intl.formatMessage(messages.template);
2445
2516
  const templateText = isFullMode ? templateIntlMsg : '';
@@ -2465,16 +2536,28 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2465
2536
  illustrationImage: pushIllustration,
2466
2537
  title: <FormattedMessage {...messages.pushTitleIllustartion} values={{ template: templateText }} />,
2467
2538
  };
2468
- case WHATSAPP:
2469
- return {
2470
- buttonLabel: <FormattedMessage {...messages.newWhatsappTemplate} values={{ template: templateText }} />,
2471
- onClick: this.createTemplate,
2472
- illustrationImage: whatsappIllustration,
2473
- title: <FormattedMessage {...messages.whatsappTitleIllustration} values={{ template: templateText }} />,
2474
- description: <FormattedMessage {...messages.whatsappDescIllustration} />,
2475
- descriptionPosition: 'bottom',
2476
- descriptionClassName: 'illustration-desc',
2477
- };
2539
+ case WHATSAPP: {
2540
+ if (hostNameNotFound) {
2541
+ return {
2542
+ illustrationImage: whatsappOrZaloAccountIllustration,
2543
+ title: <FormattedMessage {...messages.whatsappAccountNotConfiguredTitle} />,
2544
+ description: <FormattedMessage {...messages.accountNotConfiguredDescription} />,
2545
+ descriptionPosition: 'bottom',
2546
+ descriptionClassName: 'illustration-desc zalo-illustration',
2547
+ buttonClassName: "zalo-illustration-button",
2548
+ };
2549
+ } else {
2550
+ return {
2551
+ buttonLabel: <FormattedMessage {...messages.newWhatsappTemplate} values={{ template: templateText }} />,
2552
+ onClick: this.createTemplate,
2553
+ illustrationImage: whatsappIllustration,
2554
+ title: <FormattedMessage {...messages.whatsappTitleIllustration} values={{ template: templateText }} />,
2555
+ description: <FormattedMessage {...messages.whatsappDescIllustration} />,
2556
+ descriptionPosition: 'bottom',
2557
+ descriptionClassName: 'illustration-desc',
2558
+ };
2559
+ }
2560
+ }
2478
2561
  case RCS:
2479
2562
  return {
2480
2563
  buttonLabel: <FormattedMessage {...messages.newRCSTemplate} values={{ template: templateText }} />,
@@ -2485,15 +2568,27 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2485
2568
  descriptionPosition: 'bottom',
2486
2569
  descriptionClassName: 'illustration-desc rcs-illustration',
2487
2570
  };
2488
- case ZALO:
2489
- return {
2490
- illustrationImage: zaloillustration,
2491
- title: <FormattedMessage {...messages.zaloTitleIllustration} />,
2492
- description: <FormattedMessage {...messages.zaloDescIllustration} />,
2493
- descriptionPosition: 'bottom',
2494
- descriptionClassName: 'illustration-desc zalo-illustration',
2495
- buttonClassName: "zalo-illustration-button",
2496
- };
2571
+ case ZALO:{
2572
+ if (hostNameNotFound) {
2573
+ return {
2574
+ illustrationImage: whatsappOrZaloAccountIllustration,
2575
+ title: <FormattedMessage {...messages.zaloAccountNotConfiguredTitle} />,
2576
+ description: <FormattedMessage {...messages.accountNotConfiguredDescription} />,
2577
+ descriptionPosition: 'bottom',
2578
+ descriptionClassName: 'illustration-desc zalo-illustration',
2579
+ buttonClassName: "zalo-illustration-button",
2580
+ };
2581
+ } else {
2582
+ return {
2583
+ illustrationImage: zaloillustration,
2584
+ title: <FormattedMessage {...messages.zaloTitleIllustration} />,
2585
+ description: <FormattedMessage {...messages.zaloDescIllustration} />,
2586
+ descriptionPosition: 'bottom',
2587
+ descriptionClassName: 'illustration-desc zalo-illustration',
2588
+ buttonClassName: "zalo-illustration-button",
2589
+ };
2590
+ }
2591
+ }
2497
2592
  case INAPP:
2498
2593
  return {
2499
2594
  illustrationImage: inAppIllustration,
@@ -2555,15 +2650,14 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2555
2650
  channel = channel.toUpperCase();
2556
2651
  const { Templates: templates = {}, location = {} } = this.props;
2557
2652
  const { query = {} } = location;
2558
- const { weCrmAccounts = [], fetchingWeCrmAccounts = false, campaignSettings = {} } = templates;
2653
+ const { weCrmAccounts = [], fetchingWeCrmAccounts = false, campaignSettings = {}, senderDetails } = templates;
2559
2654
  const isWechatChannel = channel === WECHAT;
2560
2655
  const isMobilePushChannel = channel === MOBILE_PUSH;
2561
2656
  const isInAppChannel = channel === INAPP;
2562
2657
  const isFacebookChannel = channel === FACEBOOK;
2563
-
2564
- if ([WECHAT, MOBILE_PUSH, INAPP, LINE, ZALO].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
2658
+ if ([WECHAT, MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
2565
2659
  forEach(weCrmAccounts, (account) => {
2566
- if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, INAPP, LINE, ZALO].includes(channel)) {
2660
+ if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP].includes(channel)) {
2567
2661
  if (query.type === 'embedded' && (!query.module || (query.module && query.module !== 'library'))) {
2568
2662
  if (query.source_account_id && account.sourceAccountIdentifier === query.source_account_id) {
2569
2663
  accountOptions.push(
@@ -2646,9 +2740,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2646
2740
  break;
2647
2741
  }
2648
2742
  let showNoAccountHeader = isEmpty(weCrmAccounts) && !fetchingWeCrmAccounts;
2649
- if (channel === WHATSAPP && this.state.hostName === '') {
2650
- showNoAccountHeader = true;
2651
- }
2743
+ // Zalo and Whatsapp has dependencies on domainProperties to get the hostName. Show loader until the domainProperties are fetched.
2744
+ const isDomainPropertiesLoading = [WHATSAPP, ZALO].includes(channel) && senderDetails?.status === "REQUEST";
2652
2745
  if (channel === FACEBOOK && !isEmpty(campaignSettings) ) {
2653
2746
  const fbSetting = get(campaignSettings, 'accountSettings.socialAccountSettings.facebookAccountSettings', []);
2654
2747
  const { orgUnitFacebookPageSettingsMap } = fbSetting[0] || {};
@@ -2667,7 +2760,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2667
2760
  if (channel === WECHAT && !commonUtil.hasWechatFeatureEnabled()) {
2668
2761
  showNoAccountHeader = true;
2669
2762
  }
2670
- return (<CapSkeleton loading={fetchingWeCrmAccounts} active paragraph={{ rows: 10 }}>
2763
+ return (<CapSkeleton loading={fetchingWeCrmAccounts || isDomainPropertiesLoading} active paragraph={{ rows: 10 }}>
2671
2764
  {showNoAccountHeader ? <FormattedMessage {...noAccountHeader} /> :
2672
2765
  <div style={{ overflowX: "auto", paddingBottom: CAP_SPACE_16 }}>
2673
2766
  <CapHeader
@@ -2857,10 +2950,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2857
2950
  }
2858
2951
  }
2859
2952
 
2860
- const getCategoryOptions = (hostName) => {
2861
- return CATEGORY_OPTIONS_MAP[hostName];
2862
- };
2863
-
2864
2953
  const cmsTemplateSelectionContent = (
2865
2954
  <CardGrid
2866
2955
  className={""}
@@ -2874,7 +2963,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2874
2963
  );
2875
2964
  //TODO -> uncomment the following line
2876
2965
  // const isfilterContentVisisble = !isEmpty(this.props.TemplatesList) || !isEmpty(this.state.searchText) || !isEmpty(this.props.Templates.templateError);
2877
- const isfilterContentVisisble = true;
2966
+ let isfilterContentVisisble = true;
2878
2967
  const isWechatEmbedded = !this.props.isFullMode && channel.toUpperCase() === WECHAT;
2879
2968
  const channelLowerCase = (channel || '').toLowerCase();
2880
2969
  const isTraiDltFeature = this.checkDLTfeatureEnable();
@@ -2889,7 +2978,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2889
2978
  className="create-new-link"
2890
2979
  />
2891
2980
  )
2892
- : this.state.channel.toLowerCase() === ZALO_LOWERCASE ? <></> : (
2981
+ : this.state?.channel?.toLowerCase() === ZALO_LOWERCASE || (channelLowerCase === WHATSAPP_LOWERCASE && isEmpty(this.state?.hostName)) ? <></> : (
2893
2982
  <CapButton
2894
2983
  className={`create-new-${channelLowerCase} margin-l-8 margin-b-12`}
2895
2984
  type={"primary"}
@@ -2903,7 +2992,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2903
2992
  const isWhatsappCountExeeded = templatesCount >= MAX_WHATSAPP_TEMPLATES;
2904
2993
  const showWhatsappCountWarning = templatesCount >= WARNING_WHATSAPP_TEMPLATES;
2905
2994
  const whatsappCountExceedText = <FormattedMessage {...messages.whatsappMaxTemplates} values={{ maxCount: MAX_WHATSAPP_TEMPLATES }}/>;
2906
-
2995
+ if (([WHATSAPP_LOWERCASE, ZALO_LOWERCASE].includes(this.state?.channel?.toLocaleLowerCase()) && isEmpty(this.state?.hostName))) {
2996
+ isfilterContentVisisble = false;
2997
+ }
2907
2998
  const filterContent = (( isfilterContentVisisble || [WECHAT, MOBILE_PUSH, INAPP].includes(this.state.channel.toUpperCase())) && <div className="action-container">
2908
2999
  {isfilterContentVisisble && <CapInput.Search
2909
3000
  className="search-text"
@@ -2932,7 +3023,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2932
3023
  channel.toUpperCase() === ZALO && (
2933
3024
  <div className="zalo-filters">
2934
3025
  {
2935
- this.props.isFullMode ? (
3026
+ this.props?.isFullMode && this.state?.hostName ? (
2936
3027
  <CapSelectFilter
2937
3028
  placement="bottomLeft"
2938
3029
  data={ZALO_STATUS_OPTIONS}
@@ -2951,7 +3042,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2951
3042
  channel.toUpperCase() === WHATSAPP && (
2952
3043
  <div className="whatsapp-filters">
2953
3044
  {
2954
- this.props.isFullMode ? (
3045
+ this.props?.isFullMode && this.state?.hostName ? (
2955
3046
  <CapSelectFilter
2956
3047
  placement="bottomLeft"
2957
3048
  data={STATUS_OPTIONS}
@@ -2963,16 +3054,20 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2963
3054
  />
2964
3055
  ) : null
2965
3056
  }
2966
- <CapSelectFilter
2967
- placement="bottomLeft"
2968
- data={getCategoryOptions(this.state.hostName)}
2969
- onSelect={this.setWhatsappCategory}
2970
- selectedValue={this.state.selectedWhatsappCategory}
2971
- placeholder="Category"
2972
- showBadge
2973
- width="105px"
2974
- overlayStyle={{ overflowY: "hidden" }}
2975
- />
3057
+ {this.state?.hostName ? (
3058
+ <CapSelectFilter
3059
+ placement="bottomLeft"
3060
+ data={this.state.hostName === HOST_TWILIO
3061
+ ? TWILIO_CATEGORY_OPTIONS
3062
+ : KARIX_GUPSHUP_CATEGORY_OPTIONS}
3063
+ onSelect={this.setWhatsappCategory}
3064
+ selectedValue={this.state.selectedWhatsappCategory}
3065
+ placeholder="Category"
3066
+ showBadge
3067
+ width="105px"
3068
+ overlayStyle={{ overflowY: "hidden" }}
3069
+ />
3070
+ ) : null}
2976
3071
  </div>
2977
3072
 
2978
3073
  )
@@ -3045,7 +3140,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
3045
3140
  }
3046
3141
  <div style={{display: "flex", justifyContent: "space-between", alignItems: 'center'}}>
3047
3142
  {
3048
- this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE && isWhatsappCountExeeded ? (
3143
+ this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE && (isWhatsappCountExeeded)? (
3049
3144
  <CapTooltip title={whatsappCountExceedText}>
3050
3145
  <div className="button-disabled-tooltip-wrapper">
3051
3146
  {createButton}
@@ -354,6 +354,18 @@ export default defineMessages({
354
354
  id: `${scope}.whatsappDescIllustration`,
355
355
  defaultMessage: 'These templates can be reused when creating a\nnew message content.',
356
356
  },
357
+ "whatsappAccountNotConfiguredTitle": {
358
+ id: `${scope}.whatsappAccountNotConfiguredTitle`,
359
+ defaultMessage: 'Whatsapp account is not configured',
360
+ },
361
+ "accountNotConfiguredDescription": {
362
+ id: `${scope}.accountNotConfiguredDescription`,
363
+ defaultMessage: 'Please contact your Customer Success Manager to fix the issue.',
364
+ },
365
+ "zaloAccountNotConfiguredTitle": {
366
+ id: `${scope}.zaloAccountNotConfiguredTitle`,
367
+ defaultMessage: 'Zalo account is not configured',
368
+ },
357
369
  "zaloTitleIllustration": {
358
370
  id: `${scope}.zaloTitleIllustration`,
359
371
  defaultMessage: 'There are no approved templates available',