@capillarytech/creatives-library 8.0.65-alpha.7 → 8.0.65

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-alpha.7",
4
+ "version": "8.0.65",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -94,13 +94,9 @@ describe("Creatives testing template creation", () => {
94
94
  name: globalMessages.email.defaultMessage,
95
95
  });
96
96
  await userEvent.click(whatsapp);
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 });
97
+ expect(await creativesScreen.findByText(
98
+ /Whatsapp accounts are not setup for your brand/i, undefined, { timeout: 10000 })
99
+ ).toBeInTheDocument();
104
100
  await userEvent.click(line);
105
101
  //assertions for template filters for line channel
106
102
  expect(creativesScreen.getByText(/rich video message/i)).toBeInTheDocument();
@@ -980,8 +980,8 @@ Click {{unsubscribe}} to unsubscribe
980
980
  "base": Object {
981
981
  "content": Object {
982
982
  "whatsapp": Object {
983
- "accessToken": "Bearer abcd",
984
- "accountId": "12345",
983
+ "accessToken": "Bearer gDwEuRIm9icV6phixociSw==",
984
+ "accountId": "107499611940863",
985
985
  "buttonType": "CTA",
986
986
  "buttons": Array [
987
987
  Object {
@@ -73,8 +73,3 @@ 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,7 +21,6 @@ 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';
25
24
  import {
26
25
  CapMenu,
27
26
  CapDropdown,
@@ -97,18 +96,16 @@ import {
97
96
  FACEBOOK as FACEBOOK_CHANNEL,
98
97
  CREATE,
99
98
  } from '../App/constants';
100
- import {MAX_WHATSAPP_TEMPLATES, WARNING_WHATSAPP_TEMPLATES , ACCOUNT_MAPPING_ON_CHANNEL} from './constants';
99
+ import {MAX_WHATSAPP_TEMPLATES, WARNING_WHATSAPP_TEMPLATES } from './constants';
101
100
  import { COPY_OF } from '../../containers/App/constants';
102
101
  import {
103
- TWILIO_CATEGORY_OPTIONS,
104
- KARIX_GUPSHUP_CATEGORY_OPTIONS,
105
102
  STATUS_OPTIONS,
106
103
  CATEGORY,
107
104
  WHATSAPP_CATEGORIES,
108
105
  STATUS as WHATSAPP_STATUS,
109
106
  WHATSAPP_STATUSES,
110
- HOST_TWILIO,
111
107
  HOST_GUPSHUP,
108
+ CATEGORY_OPTIONS_MAP,
112
109
  } from '../Whatsapp/constants';
113
110
  import { INAPP_LAYOUT_DETAILS } from '../InApp/constants';
114
111
  import { ZALO_STATUS_OPTIONS, ZALO_STATUSES } from '../Zalo/constants';
@@ -126,7 +123,6 @@ import emailIllustration from '../Assets/images/emailIllustration.svg';
126
123
  import smsIllustration from '../Assets/images/smsIllustration.svg';
127
124
  import pushIllustration from '../Assets/images/pushIllustration.svg';
128
125
  import whatsappIllustration from '../Assets/images/whatsappIllustration.png';
129
- import whatsappOrZaloAccountIllustration from '../Assets/images/whatsappOrZaloAccountIllustration.svg';
130
126
  import rcsIllustration from '../Assets/images/rcsIllustration.png';
131
127
  import zaloillustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
132
128
  import inAppIllustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
@@ -251,26 +247,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
251
247
  this.delayTimer = 0;
252
248
  }
253
249
 
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
-
274
250
  componentWillMount() {
275
251
  if (this.state.channel === '') {
276
252
  let channel = '';
@@ -633,65 +609,51 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
633
609
  if (!isEmpty(nextProps.Templates.templateDetails) && !isEqual(nextProps.Templates.templateDetails, this.props.Templates.templateDetails)) {
634
610
  this.setState({ previewTemplate: nextProps.Templates.templateDetails });
635
611
  }
636
- const { weCrmAccounts: weCrmAccountsList = [], senderDetails = {} } = get(nextProps, 'Templates', {});
637
- const weCrmChannels = [WHATSAPP_LOWERCASE, ZALO_LOWERCASE];
612
+ const { weCrmAccounts: weCrmAccountsList = [], senderDetails: { hostName = '' } = {} } = get(nextProps, 'Templates', {});
613
+ const weCrmChannels = ['wechat', WHATSAPP_LOWERCASE, ZALO_LOWERCASE];
638
614
 
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] || {};
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] || {};
642
625
  const {
626
+ token,
643
627
  wecrm_app_id,
644
628
  wecrm_token
645
629
  } = configs || {};
630
+ if (weCrmChannels.includes(selectedChannel)) {
631
+ if ([WHATSAPP_LOWERCASE, ZALO_LOWERCASE].includes(selectedChannel)) {
632
+ if (hostName === '') {
633
+ return;
634
+ }
646
635
 
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,
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
+
653
653
  }
654
- nextProps.actions.setWeChatAccount(weCrmAccountsList[0]);
655
654
  this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: weCrmAccountsList[0].name, hostName: weCrmAccountsList[0].hostName });
656
655
  this.getAllTemplates({params: paramsDefault}, true);
657
656
  }
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
- }
695
657
  const zaloPreviewUrl = get(nextProps, 'Zalo.zaloTemplatePreviewData.versions.base.content.zalo.previewUrl', '');
696
658
  if (zaloPreviewUrl && this.state.channel.toLowerCase() === ZALO_LOWERCASE) {
697
659
  handlePreviewInNewTab(zaloPreviewUrl);
@@ -716,7 +678,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
716
678
  params.sortBy = this.state.sortBy;
717
679
  }
718
680
  const selectedChannel = this.state.channel.toLowerCase();
719
- const isZaloOrWhatsapp = [ZALO_LOWERCASE, WHATSAPP_LOWERCASE].includes(selectedChannel);
720
681
  if (selectedChannel === 'wechat') {
721
682
  params.wecrmId = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})].configs.wecrm_app_id;
722
683
  params.wecrmToken = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})].configs.wecrm_token;
@@ -736,41 +697,26 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
736
697
  } else {
737
698
  this.setState({ selectedAccountError: false });
738
699
  }
739
- } else if ([LINE.toLowerCase(), RCS_LOWERCASE, ZALO_LOWERCASE, WHATSAPP_LOWERCASE].includes(selectedChannel)) {
700
+ } else if ([LINE.toLowerCase(), RCS_LOWERCASE, ZALO_LOWERCASE].includes(selectedChannel)) {
740
701
  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
- }
747
702
  this.props.actions.setChannelAccount(selectedChannel?.toUpperCase(), setAcc);
748
-
749
- const {
750
- name = "",
751
- sourceAccountIdentifier = "",
752
- configs: { token = "" } = {},
753
- } = setAcc || {};
754
-
755
- if(selectedChannel === ZALO_LOWERCASE && hostName) {
703
+ if(selectedChannel === ZALO_LOWERCASE){
704
+ const {
705
+ name = "",
706
+ sourceAccountIdentifier = "",
707
+ configs: { token = "" } = {},
708
+ } = setAcc || {};
756
709
  params.username = name;
757
710
  params.oa_id = sourceAccountIdentifier;
758
711
  params.token = token;
759
712
  params.isAccountSelection = true;
760
- params.host = hostName;
761
- }
762
- if (selectedChannel === WHATSAPP_LOWERCASE && hostName) {
763
- params.accountId = sourceAccountIdentifier;
764
- params.host = hostName;
713
+ params.host = this.props.Templates?.senderDetails?.hostName || this.props.Templates?.selectedZaloAccount?.hostName || this.state.hostName;
765
714
  }
766
715
  }
767
716
 
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
- });
717
+ this.setState({activeMode: TEMPLATES_MODE});
718
+
719
+ this.getAllTemplates({params, resetPage: true});
774
720
  });
775
721
  }
776
722
  onPaginationChange = () => {
@@ -848,12 +794,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
848
794
 
849
795
  moment.locale(locale);
850
796
  };
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
-
857
797
  getAllTemplates = ({params, getNextPage, resetPage}, resetTemplates) => {
858
798
  let queryParams = params || {};
859
799
  let page = this.state.page;
@@ -882,9 +822,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
882
822
  if (([MOBILE_PUSH_LOWERCASE, INAPP_LOWERCASE].includes(channel.toLowerCase())) && !isEmpty(this.props.Templates.selectedWeChatAccount)) {
883
823
  queryParams.accountId = this.props.Templates?.selectedWeChatAccount?.id;
884
824
  }
885
- if (this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE) {
886
- this.setWhatsappQueryParams(queryParams, params);
887
- }
888
825
  this.props.actions.getAllTemplates(channel, queryParams,`${copyOf}`);
889
826
  } else if ((resetPage || (page === 1 && this.state.templatesCount === 0) || page <= (this.state.templatesCount / this.state.perPageLimit))) {
890
827
  if (getNextPage) {
@@ -934,9 +871,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
934
871
  queryParams.token = token;
935
872
  queryParams.host = hostName || this.props.Templates?.senderDetails?.hostName ||this.state.hostName;
936
873
  }
937
- if (this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE) {
938
- this.setWhatsappQueryParams(queryParams, params);
939
- }
940
874
  this.setState({ page, templatesCount }, () => {
941
875
  queryParams.page = page;
942
876
  queryParams.perPage = this.state.perPageLimit;
@@ -1083,7 +1017,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1083
1017
  filteredTemplates = this.filterWechatTemplates(templates);
1084
1018
  break;
1085
1019
  case WHATSAPP:
1086
- filteredTemplates = this.state?.hostName ? this.filterWhatsappTemplates(templates) : [];
1020
+ filteredTemplates = this.filterWhatsappTemplates(templates);
1087
1021
  break;
1088
1022
  case LINE:
1089
1023
  filteredTemplates = this.filterLineTemplates(templates);
@@ -1444,16 +1378,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1444
1378
 
1445
1379
  const accountId = get(this.props, 'Templates.selectedWeChatAccount.uuid');
1446
1380
  const accounts = get(this.props, 'Templates.weCrmAccounts');
1447
- const noWhatsappZaloTemplates = this.isFullMode() && isEmpty(templates) || !this.state.hostName;
1381
+ const noWhatsappZaloTemplates = this.isFullMode() && isEmpty(templates);
1448
1382
  const noFilteredWhatsappZaloTemplates = this.isFullMode() && !isEmpty(templates) && isEmpty(filteredTemplates);
1449
- const noApprovedWhatsappZaloTemplates = !this.isFullMode() && isEmpty(filteredTemplates) && !isEmpty(this.state?.hostName);;
1450
- const showWhatsappIllustration = (!isEmpty(this.props.Templates.selectedWhatsappAccount) && [WHATSAPP_LOWERCASE].includes(channelLowerCase)) || !this.state?.hostName ;
1383
+ const noApprovedWhatsappZaloTemplates = !this.isFullMode() && isEmpty(filteredTemplates);
1384
+ const showWhatsappIllustration = !isEmpty(this.props.Templates.selectedWhatsappAccount) && [WHATSAPP_LOWERCASE].includes(channelLowerCase);
1451
1385
  const showZaloIllustration = !isEmpty(this.props.Templates.selectedZaloAccount) && [ZALO_LOWERCASE].includes(channelLowerCase);
1452
1386
  const showRcsIllustration = channelLowerCase === RCS_LOWERCASE && isEmpty(templates);
1453
1387
  const showInAppIllustration = channelLowerCase === INAPP_LOWERCASE && isEmpty(templates);
1454
1388
  const noLoaderAndSearchText = isEmpty(this.state.searchText) && !isLoading;
1455
1389
  return (<div>
1456
- {[WECHAT, MOBILE_PUSH, INAPP, WHATSAPP, ZALO].includes(currentChannel) && this.showAccountName()}
1390
+ {[WECHAT, MOBILE_PUSH, INAPP].includes(currentChannel) && this.showAccountName()}
1457
1391
  {filterContent}
1458
1392
  {[WHATSAPP, ZALO].includes(currentChannel) && this.selectedFilters()}
1459
1393
  <CapCustomSkeleton loader={isLoading}>
@@ -1490,15 +1424,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1490
1424
  isEmpty(filteredTemplates) &&
1491
1425
  isEmpty(this.state.searchText) &&
1492
1426
  <div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto'} : {}}>
1493
- <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel, this.state?.hostName)} />
1427
+ <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />
1494
1428
  </div>
1495
1429
  )
1496
1430
  }
1497
1431
  {(showWhatsappIllustration || showZaloIllustration) && (
1498
1432
  noLoaderAndSearchText &&
1499
1433
  <div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto' } : {}}>
1500
- {noWhatsappZaloTemplates && <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel, isEmpty(this.state?.hostName))} />}
1501
- {noFilteredWhatsappZaloTemplates && this.state?.hostName && this.whatsappZaloIllustrationText('noFilteredWhatsappZaloTemplatesTitle', 'noFilteredWhatsappZaloTemplatesDesc')}
1434
+ {noWhatsappZaloTemplates && <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />}
1435
+ {noFilteredWhatsappZaloTemplates && this.whatsappZaloIllustrationText('noFilteredWhatsappZaloTemplatesTitle', 'noFilteredWhatsappZaloTemplatesDesc')}
1502
1436
  {noApprovedWhatsappZaloTemplates && this.whatsappZaloIllustrationText('noApprovedWhatsappZaloTemplatesTitle', showWhatsappIllustration ? 'noApprovedWhatsappTemplatesDesc' : 'zaloDescIllustration')}
1503
1437
  </div>
1504
1438
  )
@@ -1643,7 +1577,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1643
1577
  prepareWeChatPreviewData(template) {
1644
1578
  if (template && template.versions && template.versions.base && !isEmpty(template.versions.base)) {
1645
1579
  if (template.definition && template.definition.msgcontent && template.definition.msgcontent === "RICH_MEDIA_WECHAT") {
1646
- console.log("prepareWeChatPreviewData", template, JSON.stringify(template), template.versions.base.mediaList, JSON.stringify(template.versions.base.mediaList));
1647
1580
  return template.versions.base.mediaList;
1648
1581
  }
1649
1582
  return this.prepareWeChatMappedPreviewData(template.versions.base.content, template.versions.base.Tag, template.versions.base.data);
@@ -1903,9 +1836,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1903
1836
  }
1904
1837
  if (this.state.channel.toLowerCase() === MOBILE_PUSH_LOWERCASE) {
1905
1838
  params.accountId = this.props.Templates.selectedWeChatAccount.id;
1906
- } else if (this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE) {
1907
- params.accountId = this.props.Templates?.selectedWhatsappAccount?.sourceAccountIdentifier;
1908
- params.host = this.state?.hostName;
1909
1839
  }
1910
1840
  this.delay(() => {
1911
1841
  this.getAllTemplates({params, resetPage: true});
@@ -2509,7 +2439,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2509
2439
  (rcsLoader !== undefined ? rcsLoader : false);
2510
2440
  return isLoading;
2511
2441
  }
2512
- getChannelTypeIllustrationInfo = (type, hostNameNotFound) => {
2442
+ getChannelTypeIllustrationInfo = (type) => {
2513
2443
  const { isFullMode, intl } = this.props;
2514
2444
  const templateIntlMsg = intl.formatMessage(messages.template);
2515
2445
  const templateText = isFullMode ? templateIntlMsg : '';
@@ -2535,28 +2465,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2535
2465
  illustrationImage: pushIllustration,
2536
2466
  title: <FormattedMessage {...messages.pushTitleIllustartion} values={{ template: templateText }} />,
2537
2467
  };
2538
- case WHATSAPP: {
2539
- if (hostNameNotFound) {
2540
- return {
2541
- illustrationImage: whatsappOrZaloAccountIllustration,
2542
- title: <FormattedMessage {...messages.whatsappAccountNotConfiguredTitle} />,
2543
- description: <FormattedMessage {...messages.accountNotConfiguredDescription} />,
2544
- descriptionPosition: 'bottom',
2545
- descriptionClassName: 'illustration-desc zalo-illustration',
2546
- buttonClassName: "zalo-illustration-button",
2547
- };
2548
- } else {
2549
- return {
2550
- buttonLabel: <FormattedMessage {...messages.newWhatsappTemplate} values={{ template: templateText }} />,
2551
- onClick: this.createTemplate,
2552
- illustrationImage: whatsappIllustration,
2553
- title: <FormattedMessage {...messages.whatsappTitleIllustration} values={{ template: templateText }} />,
2554
- description: <FormattedMessage {...messages.whatsappDescIllustration} />,
2555
- descriptionPosition: 'bottom',
2556
- descriptionClassName: 'illustration-desc',
2557
- };
2558
- }
2559
- }
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
+ };
2560
2478
  case RCS:
2561
2479
  return {
2562
2480
  buttonLabel: <FormattedMessage {...messages.newRCSTemplate} values={{ template: templateText }} />,
@@ -2567,27 +2485,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2567
2485
  descriptionPosition: 'bottom',
2568
2486
  descriptionClassName: 'illustration-desc rcs-illustration',
2569
2487
  };
2570
- case ZALO:{
2571
- if (hostNameNotFound) {
2572
- return {
2573
- illustrationImage: whatsappOrZaloAccountIllustration,
2574
- title: <FormattedMessage {...messages.zaloAccountNotConfiguredTitle} />,
2575
- description: <FormattedMessage {...messages.accountNotConfiguredDescription} />,
2576
- descriptionPosition: 'bottom',
2577
- descriptionClassName: 'illustration-desc zalo-illustration',
2578
- buttonClassName: "zalo-illustration-button",
2579
- };
2580
- } else {
2581
- return {
2582
- illustrationImage: zaloillustration,
2583
- title: <FormattedMessage {...messages.zaloTitleIllustration} />,
2584
- description: <FormattedMessage {...messages.zaloDescIllustration} />,
2585
- descriptionPosition: 'bottom',
2586
- descriptionClassName: 'illustration-desc zalo-illustration',
2587
- buttonClassName: "zalo-illustration-button",
2588
- };
2589
- }
2590
- }
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
+ };
2591
2497
  case INAPP:
2592
2498
  return {
2593
2499
  illustrationImage: inAppIllustration,
@@ -2649,14 +2555,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2649
2555
  channel = channel.toUpperCase();
2650
2556
  const { Templates: templates = {}, location = {} } = this.props;
2651
2557
  const { query = {} } = location;
2652
- const { weCrmAccounts = [], fetchingWeCrmAccounts = false, campaignSettings = {}, senderDetails } = templates;
2558
+ const { weCrmAccounts = [], fetchingWeCrmAccounts = false, campaignSettings = {} } = templates;
2653
2559
  const isWechatChannel = channel === WECHAT;
2654
2560
  const isMobilePushChannel = channel === MOBILE_PUSH;
2655
2561
  const isInAppChannel = channel === INAPP;
2656
2562
  const isFacebookChannel = channel === FACEBOOK;
2657
- if ([WECHAT, MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
2563
+
2564
+ if ([WECHAT, MOBILE_PUSH, INAPP, LINE, ZALO].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
2658
2565
  forEach(weCrmAccounts, (account) => {
2659
- if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP].includes(channel)) {
2566
+ if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, INAPP, LINE, ZALO].includes(channel)) {
2660
2567
  if (query.type === 'embedded' && (!query.module || (query.module && query.module !== 'library'))) {
2661
2568
  if (query.source_account_id && account.sourceAccountIdentifier === query.source_account_id) {
2662
2569
  accountOptions.push(
@@ -2739,8 +2646,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2739
2646
  break;
2740
2647
  }
2741
2648
  let showNoAccountHeader = isEmpty(weCrmAccounts) && !fetchingWeCrmAccounts;
2742
- // Zalo and Whatsapp has dependencies on domainProperties to get the hostName. Show loader until the domainProperties are fetched.
2743
- const isDomainPropertiesLoading = [WHATSAPP, ZALO].includes(channel) && senderDetails?.status === "REQUEST";
2649
+ if (channel === WHATSAPP && this.state.hostName === '') {
2650
+ showNoAccountHeader = true;
2651
+ }
2744
2652
  if (channel === FACEBOOK && !isEmpty(campaignSettings) ) {
2745
2653
  const fbSetting = get(campaignSettings, 'accountSettings.socialAccountSettings.facebookAccountSettings', []);
2746
2654
  const { orgUnitFacebookPageSettingsMap } = fbSetting[0] || {};
@@ -2759,7 +2667,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2759
2667
  if (channel === WECHAT && !commonUtil.hasWechatFeatureEnabled()) {
2760
2668
  showNoAccountHeader = true;
2761
2669
  }
2762
- return (<CapSkeleton loading={fetchingWeCrmAccounts || isDomainPropertiesLoading} active paragraph={{ rows: 10 }}>
2670
+ return (<CapSkeleton loading={fetchingWeCrmAccounts} active paragraph={{ rows: 10 }}>
2763
2671
  {showNoAccountHeader ? <FormattedMessage {...noAccountHeader} /> :
2764
2672
  <div style={{ overflowX: "auto", paddingBottom: CAP_SPACE_16 }}>
2765
2673
  <CapHeader
@@ -2949,6 +2857,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2949
2857
  }
2950
2858
  }
2951
2859
 
2860
+ const getCategoryOptions = (hostName) => {
2861
+ return CATEGORY_OPTIONS_MAP[hostName];
2862
+ };
2863
+
2952
2864
  const cmsTemplateSelectionContent = (
2953
2865
  <CardGrid
2954
2866
  className={""}
@@ -2962,7 +2874,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2962
2874
  );
2963
2875
  //TODO -> uncomment the following line
2964
2876
  // const isfilterContentVisisble = !isEmpty(this.props.TemplatesList) || !isEmpty(this.state.searchText) || !isEmpty(this.props.Templates.templateError);
2965
- let isfilterContentVisisble = true;
2877
+ const isfilterContentVisisble = true;
2966
2878
  const isWechatEmbedded = !this.props.isFullMode && channel.toUpperCase() === WECHAT;
2967
2879
  const channelLowerCase = (channel || '').toLowerCase();
2968
2880
  const isTraiDltFeature = this.checkDLTfeatureEnable();
@@ -2977,7 +2889,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2977
2889
  className="create-new-link"
2978
2890
  />
2979
2891
  )
2980
- : this.state?.channel?.toLowerCase() === ZALO_LOWERCASE || (channelLowerCase === WHATSAPP_LOWERCASE && isEmpty(this.state?.hostName)) ? <></> : (
2892
+ : this.state.channel.toLowerCase() === ZALO_LOWERCASE ? <></> : (
2981
2893
  <CapButton
2982
2894
  className={`create-new-${channelLowerCase} margin-l-8 margin-b-12`}
2983
2895
  type={"primary"}
@@ -2991,9 +2903,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2991
2903
  const isWhatsappCountExeeded = templatesCount >= MAX_WHATSAPP_TEMPLATES;
2992
2904
  const showWhatsappCountWarning = templatesCount >= WARNING_WHATSAPP_TEMPLATES;
2993
2905
  const whatsappCountExceedText = <FormattedMessage {...messages.whatsappMaxTemplates} values={{ maxCount: MAX_WHATSAPP_TEMPLATES }}/>;
2994
- if (([WHATSAPP_LOWERCASE, ZALO_LOWERCASE].includes(this.state?.channel?.toLocaleLowerCase()) && isEmpty(this.state?.hostName))) {
2995
- isfilterContentVisisble = false;
2996
- }
2906
+
2997
2907
  const filterContent = (( isfilterContentVisisble || [WECHAT, MOBILE_PUSH, INAPP].includes(this.state.channel.toUpperCase())) && <div className="action-container">
2998
2908
  {isfilterContentVisisble && <CapInput.Search
2999
2909
  className="search-text"
@@ -3022,7 +2932,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
3022
2932
  channel.toUpperCase() === ZALO && (
3023
2933
  <div className="zalo-filters">
3024
2934
  {
3025
- this.props?.isFullMode && this.state?.hostName ? (
2935
+ this.props.isFullMode ? (
3026
2936
  <CapSelectFilter
3027
2937
  placement="bottomLeft"
3028
2938
  data={ZALO_STATUS_OPTIONS}
@@ -3041,7 +2951,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
3041
2951
  channel.toUpperCase() === WHATSAPP && (
3042
2952
  <div className="whatsapp-filters">
3043
2953
  {
3044
- this.props?.isFullMode && this.state?.hostName ? (
2954
+ this.props.isFullMode ? (
3045
2955
  <CapSelectFilter
3046
2956
  placement="bottomLeft"
3047
2957
  data={STATUS_OPTIONS}
@@ -3053,20 +2963,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
3053
2963
  />
3054
2964
  ) : null
3055
2965
  }
3056
- {this.state?.hostName ? (
3057
- <CapSelectFilter
3058
- placement="bottomLeft"
3059
- data={this.state.hostName === HOST_TWILIO
3060
- ? TWILIO_CATEGORY_OPTIONS
3061
- : KARIX_GUPSHUP_CATEGORY_OPTIONS}
3062
- onSelect={this.setWhatsappCategory}
3063
- selectedValue={this.state.selectedWhatsappCategory}
3064
- placeholder="Category"
3065
- showBadge
3066
- width="105px"
3067
- overlayStyle={{ overflowY: "hidden" }}
3068
- />
3069
- ) : null}
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
+ />
3070
2976
  </div>
3071
2977
 
3072
2978
  )
@@ -3139,7 +3045,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
3139
3045
  }
3140
3046
  <div style={{display: "flex", justifyContent: "space-between", alignItems: 'center'}}>
3141
3047
  {
3142
- this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE && (isWhatsappCountExeeded)? (
3048
+ this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE && isWhatsappCountExeeded ? (
3143
3049
  <CapTooltip title={whatsappCountExceedText}>
3144
3050
  <div className="button-disabled-tooltip-wrapper">
3145
3051
  {createButton}
@@ -354,18 +354,6 @@ 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
- },
369
357
  "zaloTitleIllustration": {
370
358
  id: `${scope}.zaloTitleIllustration`,
371
359
  defaultMessage: 'There are no approved templates available',
@@ -180,17 +180,12 @@ function templatesReducer(state = initialState, action) {
180
180
  return state.set('fetchedOrgLevelCampaignSettings', false);
181
181
  case types.GET_SENDER_DETAILS_REQUEST:
182
182
  return state.set('senderDetails', { status: 'REQUEST' });
183
- case types.GET_SENDER_DETAILS_SUCCESS: {
184
- const { channel, domainProperties = {} } = action?.payload || {};
185
- const isMultiAccountChannel = ['WHATSAPP', 'ZALO'].includes(channel);
186
- const senderDetailsKey = isMultiAccountChannel ? 'domainProperties' : 'hostName';
187
- // For Whatsapp and Zalo we need to store domainProperties instead of only hostName
183
+ case types.GET_SENDER_DETAILS_SUCCESS:
188
184
  return state.set('senderDetails', {
189
185
  status: 'SUCCESS',
190
- [senderDetailsKey]: isMultiAccountChannel ? domainProperties : action?.payload,
186
+ hostName: action.payload,
191
187
  errors: [],
192
188
  });
193
- }
194
189
  case types.GET_SENDER_DETAILS_FAILURE:
195
190
  return state.set('senderDetails', {
196
191
  status: 'FAILURE',
@@ -161,13 +161,8 @@ export function* getSenderDetails({
161
161
  if (!apiResponse?.errors?.length) {
162
162
  yield put({
163
163
  type: types.GET_SENDER_DETAILS_SUCCESS,
164
- payload: ['WHATSAPP', 'ZALO'].includes(channel) ?
165
- { channel,
166
- domainProperties: get(apiResponse, `entity.${channel}`, '')
167
- } :
168
- get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
164
+ payload: get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
169
165
  });
170
-
171
166
  } else {
172
167
  yield put({
173
168
  type: types.GET_SENDER_DETAILS_FAILURE,