@capillarytech/creatives-library 8.0.330-alpha.0 → 8.0.331-alpha.0

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.
Files changed (111) hide show
  1. package/constants/unified.js +0 -18
  2. package/package.json +1 -1
  3. package/services/tests/api.test.js +0 -13
  4. package/utils/commonUtils.js +1 -19
  5. package/v2Components/CapTagList/index.js +0 -10
  6. package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +49 -70
  7. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +2 -8
  8. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +21 -207
  9. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -16
  10. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +10 -85
  11. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -30
  12. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +11 -79
  13. package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +1 -0
  14. package/v2Components/CommonTestAndPreview/SendTestMessage.js +5 -10
  15. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -20
  16. package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +4 -133
  17. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +0 -11
  18. package/v2Components/CommonTestAndPreview/constants.js +2 -38
  19. package/v2Components/CommonTestAndPreview/index.js +176 -672
  20. package/v2Components/CommonTestAndPreview/messages.js +3 -41
  21. package/v2Components/CommonTestAndPreview/reducer.js +3 -1
  22. package/v2Components/CommonTestAndPreview/sagas.js +8 -16
  23. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +284 -308
  24. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +65 -231
  25. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +5 -118
  26. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +0 -341
  27. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +13 -34
  28. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +1 -199
  29. package/v2Components/CommonTestAndPreview/tests/index.test.js +4 -132
  30. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +2 -2
  31. package/v2Components/FormBuilder/index.js +1 -7
  32. package/v2Components/TestAndPreviewSlidebox/index.js +1 -13
  33. package/v2Components/TestAndPreviewSlidebox/sagas.js +4 -11
  34. package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +1 -3
  35. package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -36
  36. package/v2Containers/CreativesContainer/SlideBoxFooter.js +1 -10
  37. package/v2Containers/CreativesContainer/SlideBoxHeader.js +4 -29
  38. package/v2Containers/CreativesContainer/constants.js +0 -9
  39. package/v2Containers/CreativesContainer/index.js +93 -292
  40. package/v2Containers/CreativesContainer/index.scss +1 -51
  41. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +34 -78
  42. package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +16 -79
  43. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +0 -8
  44. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +98 -357
  45. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +10 -20
  46. package/v2Containers/CreativesContainer/tests/index.test.js +9 -71
  47. package/v2Containers/Rcs/constants.js +3 -40
  48. package/v2Containers/Rcs/index.js +895 -1145
  49. package/v2Containers/Rcs/index.scss +6 -85
  50. package/v2Containers/Rcs/messages.js +2 -12
  51. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +1432 -40783
  52. package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +5 -0
  53. package/v2Containers/Rcs/tests/index.test.js +38 -41
  54. package/v2Containers/Rcs/tests/mockData.js +0 -38
  55. package/v2Containers/Rcs/tests/utils.test.js +1 -435
  56. package/v2Containers/Rcs/utils.js +10 -405
  57. package/v2Containers/Sms/Create/index.js +38 -100
  58. package/v2Containers/SmsTrai/Create/index.js +4 -9
  59. package/v2Containers/SmsTrai/Edit/constants.js +0 -2
  60. package/v2Containers/SmsTrai/Edit/index.js +128 -636
  61. package/v2Containers/SmsTrai/Edit/messages.js +4 -14
  62. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +2296 -4249
  63. package/v2Containers/SmsWrapper/index.js +8 -37
  64. package/v2Containers/TagList/index.js +11 -21
  65. package/v2Containers/Templates/_templates.scss +2 -63
  66. package/v2Containers/Templates/actions.js +0 -11
  67. package/v2Containers/Templates/constants.js +0 -2
  68. package/v2Containers/Templates/index.js +40 -90
  69. package/v2Containers/Templates/sagas.js +12 -57
  70. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1079 -1043
  71. package/v2Containers/Templates/tests/sagas.test.js +123 -193
  72. package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -72
  73. package/v2Containers/TemplatesV2/index.js +23 -86
  74. package/v2Containers/WebPush/Create/index.js +1 -1
  75. package/v2Containers/Whatsapp/index.js +20 -3
  76. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +34 -578
  77. package/utils/templateVarUtils.js +0 -201
  78. package/utils/tests/templateVarUtils.test.js +0 -204
  79. package/v2Components/CommonTestAndPreview/previewApiUtils.js +0 -59
  80. package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +0 -67
  81. package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +0 -87
  82. package/v2Components/SmsFallback/constants.js +0 -73
  83. package/v2Components/SmsFallback/index.js +0 -955
  84. package/v2Components/SmsFallback/index.scss +0 -265
  85. package/v2Components/SmsFallback/messages.js +0 -78
  86. package/v2Components/SmsFallback/smsFallbackUtils.js +0 -118
  87. package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +0 -50
  88. package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +0 -147
  89. package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +0 -304
  90. package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +0 -197
  91. package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +0 -277
  92. package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +0 -422
  93. package/v2Components/SmsFallback/useLocalTemplateList.js +0 -92
  94. package/v2Components/VarSegmentMessageEditor/constants.js +0 -2
  95. package/v2Components/VarSegmentMessageEditor/index.js +0 -125
  96. package/v2Components/VarSegmentMessageEditor/index.scss +0 -46
  97. package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +0 -43
  98. package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +0 -67
  99. package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +0 -90
  100. package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +0 -258
  101. package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +0 -125
  102. package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +0 -225
  103. package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +0 -318
  104. package/v2Containers/Sms/smsFormDataHelpers.js +0 -67
  105. package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +0 -253
  106. package/v2Containers/SmsTrai/Edit/index.scss +0 -121
  107. package/v2Containers/Templates/TemplatesActionBar.js +0 -101
  108. package/v2Containers/Templates/tests/TemplatesActionBar.test.js +0 -120
  109. package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +0 -180
  110. package/v2Containers/Templates/utils/smsTemplatesListApi.js +0 -79
  111. package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +0 -131
@@ -10,14 +10,12 @@ import { isTraiDLTEnable } from '../../utils/common';
10
10
  import SmsEdit from '../Sms/Edit';
11
11
  import SmsTraiCreate from '../SmsTrai/Create';
12
12
  import SmsTraiEdit from '../SmsTrai/Edit';
13
-
14
13
  const SmsWrapper = (props) => {
15
14
  const {
16
15
  isCreateSms,
17
16
  isEditSms,
18
17
  setIsLoadingContent,
19
18
  location,
20
- route: routeFromProps,
21
19
  isGetFormData,
22
20
  getFormSubscriptionData,
23
21
  isFullMode,
@@ -39,33 +37,15 @@ const SmsWrapper = (props) => {
39
37
  handleCloseTestAndPreview,
40
38
  isTestAndPreviewMode,
41
39
  onValidationFail,
42
- embeddedSmsFallback = false,
43
- onEmbeddedSmsFooterValidity,
44
- forceFullTagContext = false,
45
40
  } = props;
46
41
 
47
- /** FormBuilder / SMS Create assume `location.query`; connected-router shapes may omit it. */
48
- const smsLocation = (() => {
49
- const loc = location || {};
50
- const q = loc.query;
51
- if (q && typeof q === 'object') {
52
- return { ...loc, query: { ...q } };
53
- }
54
- return {
55
- pathname: loc.pathname || '/sms/create',
56
- search: loc.search || '',
57
- query: { type: 'embedded', module: 'library' },
58
- };
59
- })();
60
-
61
42
  const smsProps = {
62
43
  onCreateComplete,
63
44
  setIsLoadingContent,
64
- location: smsLocation,
65
- route: routeFromProps || { name: 'sms' },
45
+ location,
46
+ route: { name: 'sms' },
66
47
  isGetFormData,
67
48
  getFormSubscriptionData,
68
- templateData,
69
49
  getDefaultTags,
70
50
  isFullMode,
71
51
  forwardedTags,
@@ -80,33 +60,24 @@ const SmsWrapper = (props) => {
80
60
  handleCloseTestAndPreview,
81
61
  isTestAndPreviewMode,
82
62
  onValidationFail,
83
- forceFullTagContext,
84
- embeddedSmsFallback,
85
- onEmbeddedSmsFooterValidity,
86
- ...(embeddedSmsFallback
87
- ? {
88
- tagListGetPopupContainer: () => document.body,
89
- tagListPopoverOverlayStyle: { zIndex: 10020 },
90
- tagListPopoverOverlayClassName: 'sms-fallback-taglist-popover rcs-sms-fallback-taglist-popover',
91
- }
92
- : {}),
93
63
  };
94
- const useTraiSmsFlow = isTraiDLTEnable(isFullMode, smsRegister);
64
+ const isTraiDlt = isTraiDLTEnable(isFullMode, smsRegister);
95
65
  return <>
96
66
  {
97
- isCreateSms && (useTraiSmsFlow ?
67
+ isCreateSms && (isTraiDlt ?
98
68
  <SmsTraiCreate
99
69
  isComponent
100
70
  {...smsProps}
101
71
  onShowTemplates={onShowTemplates}
102
72
  /> :
103
73
  <SmsCreate
104
- isComponent
105
- {...smsProps}
74
+ isComponent {
75
+ ...smsProps
76
+ }
106
77
  />
107
78
  )
108
79
  }
109
- {isEditSms && (useTraiSmsFlow ?
80
+ {isEditSms && (isTraiDlt ?
110
81
  <SmsTraiEdit
111
82
  {...smsProps}
112
83
  params={{id: templateData._id}}
@@ -22,7 +22,7 @@ import messages, { scope } from './messages';
22
22
  // import styled from styled-components;
23
23
  import CapTagList from '../../v2Components/CapTagList';
24
24
  import './_tagList.scss';
25
- import { selectCurrentOrgDetails, makeSelectFetchingSchemaError } from '../Cap/selectors';
25
+ import { selectCurrentOrgDetails, makeSelectFetchingSchemaError, makeSelectFetchingSchema } from '../Cap/selectors';
26
26
  import {
27
27
  handleInjectedData, hasGiftVoucherFeature, hasPromoFeature, hasBadgesFeature, transformBadgeTags,
28
28
  } from '../../utils/common';
@@ -35,12 +35,14 @@ const {TreeNode} = Tree;
35
35
  export class TagList extends React.Component { // eslint-disable-line react/prefer-stateless-function
36
36
  constructor(props) {
37
37
  super(props);
38
+ const { tags, injectedTags } = props;
39
+ const hasInitialData = (tags && tags.length > 0) || !_.isEmpty(injectedTags);
38
40
  this.state = {
39
41
  loading: false,
40
42
  tags: [],
41
43
  tagsError: false,
42
44
  currentContext: null, // Track current context to detect changes
43
- hasTriggeredInitialApiCall: false, // Track if we've triggered API call when popover opens
45
+ hasTriggeredInitialApiCall: hasInitialData, // Seed from initial props to avoid duplicate fetch on popover open
44
46
  };
45
47
  this.renderTags = this.renderTags.bind(this);
46
48
  this.populateTags = this.populateTags.bind(this);
@@ -52,14 +54,8 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
52
54
 
53
55
  componentDidMount() {
54
56
  this.generateTags(this.props);
55
- // Trigger initial API call if tags are empty (similar to Email/SMS behavior)
56
- const { tags, injectedTags, onContextChange } = this.props;
57
- const hasNoTags = (!tags || tags.length === 0) && _.isEmpty(injectedTags);
58
- if (hasNoTags && onContextChange) {
59
- // Trigger API call with default 'Outbound' context to match CapTagList default
60
- // This ensures tags are loaded when component mounts
61
- this.getTagsforContext('Outbound');
62
- }
57
+ // Initial schema fetch is the parent's responsibility (useTagManagement hook handles it)
58
+ // This avoids duplicate requests when both parent and child try to fetch on mount
63
59
  }
64
60
 
65
61
  componentWillReceiveProps(nextProps) {
@@ -85,9 +81,10 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
85
81
  if (!_.isEqual(nextTags, currentTags)) {
86
82
  this.setState({loading: false});
87
83
  this.clearLoadingTimeout();
88
- // Reset the flag when tags are received, so we can trigger API call again if needed
84
+ // Tags received (from prefetch or button-click API call) mark as triggered
85
+ // so handlePopoverVisibilityChange won't fire a duplicate call on popover open
89
86
  if (nextTags && nextTags.length > 0) {
90
- this.setState({ hasTriggeredInitialApiCall: false });
87
+ this.setState({ hasTriggeredInitialApiCall: true });
91
88
  }
92
89
  }
93
90
  if (fetchingSchemaError) {
@@ -155,9 +152,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
155
152
  if ((hasNoTags || hasNoStateTags || hasNotTriggeredApiCall)) {
156
153
  // Mark that we've triggered the API call
157
154
  this.setState({ hasTriggeredInitialApiCall: true });
158
- // Trigger API call with default 'Outbound' context to match CapTagList default
159
- // This will call onContextChange which triggers handleOnTagsContextChange in InApp
160
- this.getTagsforContext('Outbound');
155
+ this.getTagsforContext('Outbound'); // Default to Outbound context
161
156
  }
162
157
  }
163
158
  };
@@ -427,9 +422,6 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
427
422
  disableTooltipMsg={tooltipMsg}
428
423
  fetchingSchemaError={this?.state?.tagsError}
429
424
  popoverPlacement={this.props.popoverPlacement}
430
- overlayStyle={this.props.popoverOverlayStyle}
431
- overlayClassName={this.props.popoverOverlayClassName}
432
- getPopupContainer={this.props.getPopupContainer}
433
425
  />
434
426
  </div>
435
427
  );
@@ -464,9 +456,6 @@ TagList.propTypes = {
464
456
  // message to show when Add Label button is disabled (e.g. personalization restriction)
465
457
  disableTooltipMsg: PropTypes.string,
466
458
  restrictPersonalization: PropTypes.bool,
467
- popoverOverlayStyle: PropTypes.object,
468
- popoverOverlayClassName: PropTypes.string,
469
- getPopupContainer: PropTypes.func,
470
459
  intl: PropTypes.shape({
471
460
  formatMessage: PropTypes.func.isRequired,
472
461
  locale: PropTypes.string,
@@ -477,6 +466,7 @@ const mapStateToProps = createStructuredSelector({
477
466
  TagList: makeSelectTagList(),
478
467
  currentOrgDetails: selectCurrentOrgDetails(),
479
468
  fetchingSchemaError: makeSelectFetchingSchemaError(),
469
+ fetchingSchema: makeSelectFetchingSchema(),
480
470
  });
481
471
 
482
472
  function mapDispatchToProps(dispatch) {
@@ -659,29 +659,11 @@
659
659
  }
660
660
 
661
661
  .action-container{
662
- margin-top: $CAP_SPACE_08;
663
- margin-bottom: $CAP_SPACE_16;
662
+ margin-top: 8px;
663
+ margin-bottom: 16px;
664
664
  display: flex;
665
665
  justify-content: space-between;
666
666
  align-items: center;
667
-
668
- &__toolbar-row {
669
- display: flex;
670
- align-items: center;
671
- gap: 0.75rem;
672
- }
673
-
674
- &__toolbar-row .search-text {
675
- width: 13.125rem;
676
- min-width: 13.125rem;
677
- flex: 1;
678
- }
679
-
680
- &__create-row {
681
- display: flex;
682
- justify-content: space-between;
683
- align-items: center;
684
- }
685
667
  }
686
668
 
687
669
  .popover-action-container:hover{
@@ -1119,47 +1101,4 @@
1119
1101
  .inapp-illustration-parent {
1120
1102
  height: "calc(100vh - 325px)";
1121
1103
  overflow: 'auto';
1122
- }
1123
-
1124
- /* Local SMS / slidebox: viewport-based .v2-pagination-container-half height leaves empty space below and clips cards */
1125
- .creatives-templates-container--local-sms.library-mode {
1126
- .creatives-templates-list.library-mode > .cap-row:first-of-type > div {
1127
- display: flex;
1128
- flex-direction: column;
1129
- flex: 1 1 auto;
1130
- min-height: 0;
1131
- overflow: hidden;
1132
- }
1133
-
1134
- .creatives-templates-list.library-mode > .cap-row:first-of-type > div > div:first-child {
1135
- display: flex;
1136
- flex-direction: column;
1137
- flex: 1 1 auto;
1138
- min-height: 0;
1139
- overflow: hidden;
1140
- }
1141
-
1142
- /* Block below search/filter: grid + skeletons — must grow to use space above footer */
1143
- .creatives-templates-list.library-mode > .cap-row:first-of-type > div > div:first-child > div:nth-child(2) {
1144
- flex: 1 1 auto;
1145
- min-height: 0;
1146
- display: flex;
1147
- flex-direction: column;
1148
- overflow: hidden;
1149
- }
1150
-
1151
- /*
1152
- * Scroll needs a definite height. Pure flex + height:auto + max-height:100% often won’t bound (no % base), so no scrollbar.
1153
- * Use a taller slice than global 100vh-20rem so the grid uses space under search; still overflow-y:auto for long lists.
1154
- */
1155
- .v2-pagination-container,
1156
- .v2-pagination-container-half {
1157
- flex: 0 1 auto;
1158
- min-height: 0;
1159
- height: calc(100vh - 12rem);
1160
- max-height: calc(100vh - 12rem);
1161
- overflow-y: auto;
1162
- overflow-x: hidden;
1163
- -webkit-overflow-scrolling: touch;
1164
- }
1165
1104
  }
@@ -15,17 +15,6 @@ export function getAllTemplates(channel, queryParams, intlCopyOf = '') {
15
15
  };
16
16
  }
17
17
 
18
-
19
- export function getLocalSmsTemplates(queryParams, intlCopyOf = '', onSuccess, onFailure) {
20
- return {
21
- type: types.GET_LOCAL_SMS_TEMPLATES_REQUEST,
22
- queryParams,
23
- intlCopyOf,
24
- onSuccess,
25
- onFailure,
26
- };
27
- }
28
-
29
18
  export function resetTemplate() {
30
19
  return {
31
20
  type: types.RESET_TEMPLATE,
@@ -10,8 +10,6 @@ export const GET_ALL_TEMPLATES_REQUEST = 'app/v2Containers/Templates/GET_ALL_TEM
10
10
  export const GET_ALL_TEMPLATES_SUCCESS = 'app/v2Containers/Templates/GET_ALL_TEMPLATES_SUCCESS';
11
11
  export const GET_ALL_TEMPLATES_FAILURE = 'app/v2Containers/Templates/GET_ALL_TEMPLATES_FAILURE';
12
12
 
13
- export const GET_LOCAL_SMS_TEMPLATES_REQUEST = 'app/v2Containers/Templates/GET_LOCAL_SMS_TEMPLATES_REQUEST';
14
-
15
13
  export const DELETE_TEMPLATE_REQUEST = 'app/v2Containers/Templates/DELETE_TEMPLATE_REQUEST';
16
14
  export const DELETE_RCS_TEMPLATE_REQUEST = 'app/v2Containers/Templates/DELETE_RCS_TEMPLATE_REQUEST';
17
15
  export const DELETE_TEMPLATE_SUCCESS = 'app/v2Containers/Templates/DELETE_TEMPLATE_SUCCESS';
@@ -468,13 +468,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
468
468
  if (this.props.location.query.type === 'embedded') {
469
469
  this.props.actions.resetAccount();
470
470
  }
471
- // When using local templates (e.g. SMS fallback selector), do not fetch from API or we overwrite global store and break background RCS list
472
- const useLocalTemplates = get(
473
- this.props,
474
- 'localTemplatesConfig.useLocalTemplates',
475
- get(this.props, 'useLocalTemplates', false),
476
- );
477
- if (!useLocalTemplates && ['line', VIBER_CHANNEL, FACEBOOK_CHANNEL, 'sms', 'email', 'ebill'].includes((this.state.channel || '').toLowerCase())) {
471
+ if (['line', VIBER_CHANNEL, FACEBOOK_CHANNEL, 'sms', 'email', 'ebill'].includes((this.state.channel || '').toLowerCase())) {
478
472
  const queryParams = {
479
473
  // name: this.state.searchText,
480
474
  // sortBy: this.state.sortBy,
@@ -987,16 +981,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
987
981
 
988
982
  componentWillUnmount() {
989
983
  window.removeEventListener("message", this.handleFrameTasks);
990
- // When using local templates (e.g. SMS fallback selector), do not clear global store or background RCS list is wiped
991
- const useLocalTemplates = get(
992
- this.props,
993
- 'localTemplatesConfig.useLocalTemplates',
994
- get(this.props, 'useLocalTemplates', false),
995
- );
996
- if (!useLocalTemplates) {
997
- this.props.actions.resetTemplateStoreData();
998
- this.props.globalActions.clearMetaEntities();
999
- }
984
+ this.props.actions.resetTemplateStoreData();
985
+ this.props.globalActions.clearMetaEntities();
1000
986
  // Clear any pending timeouts to prevent memory leaks
1001
987
  if (this._clearEditTimeout) {
1002
988
  clearTimeout(this._clearEditTimeout);
@@ -1961,7 +1947,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1961
1947
  style={{ marginRight: "16px" }}
1962
1948
  type="eye"
1963
1949
  onClick={() => {
1964
- if (!this.props.isFullMode || this.props.isDltFromRcs || this.props.isSmsFallbackFromRcs) {
1950
+ if (!this.props.isFullMode || this.props.isDltFromRcs) {
1965
1951
  if (!get(template, "versions.base.content.zalo.previewUrl", "")) {
1966
1952
  this.setState({ zaloPreviewItemId: template?._id });
1967
1953
  }
@@ -3296,13 +3282,6 @@ return (<div>
3296
3282
  this.setState({modeType});
3297
3283
  }
3298
3284
  const { _id: id } = template;
3299
- const {
3300
- localTemplatesConfig,
3301
- fbAdManager,
3302
- isDltFromRcs,
3303
- isSmsFallbackFromRcs,
3304
- onSelectTemplate,
3305
- } = this.props;
3306
3285
  const type = this.props.location.query.type;
3307
3286
  const module = this.props.location.query.module;
3308
3287
  const isLanguageSupport = (this.props.location.query.isLanguageSupport) ? this.props.location.query.isLanguageSupport : false;
@@ -3388,12 +3367,10 @@ return (<div>
3388
3367
  }
3389
3368
  if (this.isEnabledInLibraryModule("callSelectFromProps")) {
3390
3369
  let data = id;
3391
- if (localTemplatesConfig?.useLocalTemplates) {
3392
- data = template;
3393
- } else if (fbAdManager || isDltFromRcs || isSmsFallbackFromRcs) {
3370
+ if (this.props.fbAdManager || this.props.isDltFromRcs) {
3394
3371
  data = this.selectTemplate(id);
3395
3372
  }
3396
- onSelectTemplate(data, fbAdManager);
3373
+ this.props.onSelectTemplate(data, this.props.fbAdManager);
3397
3374
  } else {
3398
3375
  timeTracker.startTimer(CHANNEL_EDIT_TRACK_MAPPING[this.state.channel.toLowerCase()]);
3399
3376
  if (this.state.channel.toLowerCase() === 'ebill') {
@@ -4237,23 +4214,17 @@ return (<div>
4237
4214
  if (([WHATSAPP_LOWERCASE, ZALO_LOWERCASE, RCS_LOWERCASE].includes(this.state?.channel?.toLocaleLowerCase()) && isEmpty(this.state?.hostName))) {
4238
4215
  isfilterContentVisisble = false;
4239
4216
  }
4240
-
4241
- const useLocalTemplates = this.props.localTemplatesConfig?.useLocalTemplates;
4242
- const builtFilterContent = ((isfilterContentVisisble || [WECHAT, MOBILE_PUSH, INAPP].includes(this.state.channel.toUpperCase())) && (
4243
- <div className="action-container">
4244
- <div className="action-container__toolbar-row">
4245
- {isfilterContentVisisble ? (
4246
- <CapInput.Search
4247
- className="search-text"
4248
- placeholder={this.props.intl.formatMessage(messages.searchText)}
4249
- value={this.state.searchText}
4250
- onChange={(e) => this.searchTemplate(e.target.value, this.state.channel)}
4251
- onSearch={() => this.searchTemplate(this.state.searchText, this.state.channel)}
4252
- onClear={() => this.searchTemplate('', this.state.channel)}
4253
- onScroll={(e) => e.stopPropagation()}
4254
- disabled={this.checkSearchDisabled()}
4255
- />
4256
- ) : null}
4217
+ const filterContent = (( isfilterContentVisisble || [WECHAT, MOBILE_PUSH, INAPP].includes(this.state.channel.toUpperCase())) && <div className="action-container">
4218
+ {isfilterContentVisisble && <CapInput.Search
4219
+ className="search-text"
4220
+ style={{width: '210px'}}
4221
+ placeholder={this.props.intl.formatMessage(messages.searchText)}
4222
+ value={this.state.searchText}
4223
+ onChange={(e) => this.searchTemplate(e.target.value, this.state.channel)}
4224
+ disabled={this.checkSearchDisabled()}
4225
+ onClear={() => this.searchTemplate('', this.state.channel)}
4226
+ onScroll={(e) => e.stopPropagation()}
4227
+ />}
4257
4228
  {
4258
4229
  channel.toUpperCase() === WECHAT && <CapRadio.CapRadioGroup className="wechat-filters" defaultValue={wechatFilter} onChange={this.setWechatFilter}>
4259
4230
  <CapRadio.Button value={WECHAT_FILTERS.ALL}><CapLabel type="label2">
@@ -4399,27 +4370,20 @@ return (<div>
4399
4370
  </div>
4400
4371
  )
4401
4372
  }
4402
- </div>
4403
- <div>
4404
- <div className="action-container__create-row">
4405
- {
4406
- this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE && (isWhatsappCountExeeded) ? (
4407
- <CapTooltip title={whatsappCountExceedText}>
4408
- <div className="button-disabled-tooltip-wrapper">
4409
- {createButton}
4410
- </div>
4411
- </CapTooltip>
4412
- )
4413
- : isfilterContentVisisble && !isWechatEmbedded && !this.props.isDltFromRcs && !this.props.isSmsFallbackFromRcs && createButton
4414
- }
4415
- </div>
4416
- </div>
4373
+ <div style={{display: "flex", justifyContent: "space-between", alignItems: 'center'}}>
4374
+ {
4375
+ this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE && (isWhatsappCountExeeded)? (
4376
+ <CapTooltip title={whatsappCountExceedText}>
4377
+ <div className="button-disabled-tooltip-wrapper">
4378
+ {createButton}
4379
+ </div>
4380
+ </CapTooltip>
4381
+ )
4382
+ : isfilterContentVisisble && !isWechatEmbedded && !this.props.isDltFromRcs && createButton
4383
+ }
4417
4384
  </div>
4418
- ));
4419
- const localTemplatesFilterContent = get(this.props, 'localTemplatesConfig.localTemplatesFilterContent', null);
4420
- const filterContent = (useLocalTemplates && localTemplatesFilterContent) != null
4421
- ? localTemplatesFilterContent
4422
- : builtFilterContent;
4385
+
4386
+ </div>);
4423
4387
  let htmlPreviewContent = "";
4424
4388
  if (this.state.channel.toLowerCase() === 'ebill') {
4425
4389
  htmlPreviewContent = this.state.previewTemplate && this.state.previewTemplate.versions && this.state.previewTemplate.versions.base && this.state.previewTemplate.versions.base['ebill-editor'];
@@ -4429,10 +4393,7 @@ return (<div>
4429
4393
 
4430
4394
 
4431
4395
  const creativesParams = this.getCreativesParams();
4432
- const templates = useLocalTemplates
4433
- ? (this.props.localTemplatesConfig?.localTemplates || [])
4434
- : (this.props.TemplatesList || []);
4435
- const isLoadingWhenLocal = useLocalTemplates && !!this.props.localTemplatesConfig?.localTemplatesLoading;
4396
+ const templates = this.props.TemplatesList || [];
4436
4397
  const {route} = this.props;
4437
4398
  const loadingTipMap = {
4438
4399
  sendingFile: 'uploadingFile',
@@ -4447,11 +4408,9 @@ return (<div>
4447
4408
  (deleteRcsTemplateInProgress && 'deletingTemplate') ||
4448
4409
  (this.props.EmailCreate.duplicateTemplateInProgress && 'duplicatingTemplate');
4449
4410
 
4450
- const loadingTip = useLocalTemplates && this.props.localTemplatesConfig?.localTemplatesLoadingTip
4451
- ? this.props.localTemplatesConfig.localTemplatesLoadingTip
4452
- : (messages[loadingTipIntl] ? this.props.intl.formatMessage(messages[loadingTipIntl]) : this.props.intl.formatMessage(messages.gettingAllTemplates));
4411
+ const loadingTip = messages[loadingTipIntl] ? this.props.intl.formatMessage(messages[loadingTipIntl]) : this.props.intl.formatMessage(messages.gettingAllTemplates);
4453
4412
  const showNoTemplatesFoundZalo = this.state.channel.toUpperCase() === ZALO && isEmpty(this.state.searchedZaloTemplates) && this.state.searchingZaloTemplate;
4454
- const showNoTemplatesFoundOther = ![ZALO].includes(this.state.channel.toUpperCase()) && isEmpty(templates) && (useLocalTemplates ? !isLoadingWhenLocal : !this.props.Templates.getAllTemplatesInProgress) && (useLocalTemplates || !isEmpty(this.state.searchText));
4413
+ const showNoTemplatesFoundOther = ![ZALO].includes(this.state.channel.toUpperCase()) && isEmpty(this.props.TemplatesList) && !this.props.Templates.getAllTemplatesInProgress && !isEmpty(this.state.searchText);
4455
4414
  const showNoTemplatesFound = showNoTemplatesFoundZalo || showNoTemplatesFoundOther;
4456
4415
 
4457
4416
  return (
@@ -4496,22 +4455,22 @@ return (<div>
4496
4455
  ) : null}
4497
4456
  <CapRow>
4498
4457
  <Pagination
4499
- templateInProgress={useLocalTemplates ? isLoadingWhenLocal : this.props.Templates.getAllTemplatesInProgress}
4458
+ templateInProgress={
4459
+ this.props.Templates.getAllTemplatesInProgress
4460
+ }
4500
4461
  onPageChange={
4501
- templates.length
4502
- ? (useLocalTemplates ? (this.props.localTemplatesConfig?.localTemplatesOnPageChange || (() => {})) : this.onPaginationChange)
4503
- : () => {}
4462
+ templates.length ? this.onPaginationChange : () => {}
4504
4463
  }
4505
4464
  >
4506
4465
  {this.getTemplateDataForGrid({
4507
4466
  previewTemplateId: this.state.zaloPreviewItemId,
4508
- isLoading: useLocalTemplates ? isLoadingWhenLocal : isLoading,
4509
- isInitialLoading: useLocalTemplates ? isLoadingWhenLocal && templates.length === 0 : isInitialLoading,
4467
+ isLoading,
4468
+ isInitialLoading,
4510
4469
  loadingTip,
4511
4470
  channel: this.state.channel,
4512
4471
  templates: this.state.searchingZaloTemplate
4513
4472
  ? this.state.searchedZaloTemplates
4514
- : templates,
4473
+ : this.props.TemplatesList,
4515
4474
  filterContent,
4516
4475
  handlers: {
4517
4476
  handlePreviewClick: this.handlePreviewClick,
@@ -4694,15 +4653,6 @@ Templates.propTypes = {
4694
4653
  WebPush: PropTypes.object,
4695
4654
  smsRegister: PropTypes.any,
4696
4655
  isDltFromRcs: PropTypes.bool,
4697
- isSmsFallbackFromRcs: PropTypes.bool,
4698
- localTemplatesConfig: PropTypes.shape({
4699
- useLocalTemplates: PropTypes.bool,
4700
- localTemplates: PropTypes.arrayOf(PropTypes.object),
4701
- localTemplatesLoading: PropTypes.bool,
4702
- localTemplatesLoadingTip: PropTypes.string,
4703
- localTemplatesFilterContent: PropTypes.node,
4704
- localTemplatesOnPageChange: PropTypes.func,
4705
- }),
4706
4656
  };
4707
4657
 
4708
4658
  const mapStateToProps = createStructuredSelector({
@@ -1,5 +1,5 @@
1
1
  import {
2
- call, put, takeLatest, takeEvery, all,
2
+ call, put, takeLatest, all,
3
3
  } from 'redux-saga/effects';
4
4
  import get from 'lodash/get';
5
5
  // import { schema, normalize } from 'normalizr';
@@ -7,69 +7,31 @@ import * as Api from '../../services/api';
7
7
  import * as types from './constants';
8
8
  import { saveCdnConfigs, removeAllCdnLocalStorageItems } from '../../utils/cdnTransformation';
9
9
  import { COPY_OF } from '../../constants/unified';
10
- import { fetchSmsTemplatesFromQuery } from './utils/smsTemplatesListApi';
11
10
  import { ZALO_TEMPLATE_INFO_REQUEST } from '../Zalo/constants';
12
11
  import { getTemplateInfoById } from '../Zalo/saga';
13
-
14
- export function* getLocalSmsTemplates(action) {
15
- try {
16
- const fetched = yield call(
17
- fetchSmsTemplatesFromQuery,
18
- action.queryParams,
19
- action.intlCopyOf,
20
- );
21
- if (typeof action.onSuccess === 'function') {
22
- yield call(action.onSuccess, fetched);
23
- }
24
- } catch (error) {
25
- if (typeof action.onFailure === 'function') {
26
- yield call(action.onFailure, error);
27
- }
28
- }
29
- }
30
-
31
- export function* getAllTemplates(action) {
12
+ // Individual exports for testing
13
+ export function* getAllTemplates(channel, queryParams) {
32
14
  try {
33
- if (action.channel && String(action.channel).toLowerCase() === 'sms') {
34
- const fetched = yield call(
35
- fetchSmsTemplatesFromQuery,
36
- action.queryParams,
37
- action.intlCopyOf,
38
- );
39
- yield put({
40
- type: types.GET_ALL_TEMPLATES_SUCCESS,
41
- data: fetched.channelTemplates,
42
- weCRMTemplate: fetched.weCRMTemplate,
43
- isReset: get(action, 'queryParams.page') === 1,
44
- });
45
- return;
46
- }
47
-
48
- const result = yield call(Api.getAllTemplates, action);
49
- const channelTemplates = (action.channel === 'wechat')
50
- ? { templates: [...result.response.mapped, ...result.response.richmedia] }
51
- : result.response;
52
- if (action.channel === 'wechat' && action.queryParams && action.queryParams.sortBy && action.queryParams.sortBy.toLocaleLowerCase() === ("Most Recent").toLocaleLowerCase()) {
15
+ const result = yield call(Api.getAllTemplates, channel, queryParams);
16
+ const channelTemplates = (channel.channel === 'wechat') ? { templates: [...result.response.mapped, ...result.response.richmedia] } : result.response;
17
+ // const sidebar = result.response.sidebar;
18
+ if (channel.channel === 'wechat' && channel.queryParams && channel.queryParams.sortBy && channel.queryParams.sortBy.toLocaleLowerCase() === ("Most Recent").toLocaleLowerCase()) {
53
19
  channelTemplates.templates.sort((a, b) => {
54
20
  const dateA = new Date(a.updatedAt);
55
21
  const dateB = new Date(b.updatedAt);
56
22
  return dateB - dateA;
57
23
  });
58
- } else if (action.channel === 'wechat' && action.queryParams && action.queryParams.sortBy && action.queryParams.sortBy.toLocaleLowerCase() === ("Alphabetically").toLocaleLowerCase()) {
24
+ } else if (channel.channel === 'wechat' && channel.queryParams && channel.queryParams.sortBy && channel.queryParams.sortBy.toLocaleLowerCase() === ("Alphabetically").toLocaleLowerCase()) {
59
25
  channelTemplates.templates.sort((a, b) => b.name - a.name);
60
26
  }
61
- if (action.intlCopyOf && channelTemplates?.templates) {
27
+ // Update the "name" property in each template
28
+ if (channel.intlCopyOf && channelTemplates?.templates) {
62
29
  channelTemplates.templates = channelTemplates.templates.map((template) => ({
63
30
  ...template,
64
- name: template.name.replace(new RegExp(COPY_OF, 'g'), action.intlCopyOf),
31
+ name: template.name.replace(new RegExp(COPY_OF, 'g'), channel.intlCopyOf),
65
32
  }));
66
33
  }
67
- yield put({
68
- type: types.GET_ALL_TEMPLATES_SUCCESS,
69
- data: channelTemplates,
70
- weCRMTemplate: result.response.unMapped,
71
- isReset: get(action, 'queryParams.page') === 1,
72
- });
34
+ yield put({ type: types.GET_ALL_TEMPLATES_SUCCESS, data: channelTemplates, weCRMTemplate: result.response.unMapped, isReset: channel.queryParams.page === 1 });
73
35
  } catch (error) {
74
36
  yield put({ type: types.GET_ALL_TEMPLATES_FAILURE, error });
75
37
  }
@@ -243,11 +205,6 @@ export function* watchGetAllTemplates() {
243
205
  yield takeLatest(types.GET_ALL_TEMPLATES_REQUEST, getAllTemplates);
244
206
  }
245
207
 
246
-
247
- export function* watchGetLocalSmsTemplates() {
248
- yield takeEvery(types.GET_LOCAL_SMS_TEMPLATES_REQUEST, getLocalSmsTemplates);
249
- }
250
-
251
208
  export function* watchDeleteTemplate() {
252
209
  yield takeLatest(types.DELETE_TEMPLATE_REQUEST, deleteTemplate);
253
210
  }
@@ -301,7 +258,6 @@ export function* watchForGetTemplateInfoById() {
301
258
  // All sagas to be loaded
302
259
  export default [
303
260
  watchGetAllTemplates,
304
- watchGetLocalSmsTemplates,
305
261
  watchDeleteTemplate,
306
262
  watchDeleteRcsTemplate,
307
263
  watchGetUserList,
@@ -318,7 +274,6 @@ export default [
318
274
  export function* v2TemplateSaga() {
319
275
  yield all([
320
276
  watchGetAllTemplates(),
321
- watchGetLocalSmsTemplates(),
322
277
  watchDeleteTemplate(),
323
278
  watchDeleteRcsTemplate(),
324
279
  watchGetUserList(),