@capillarytech/creatives-library 7.17.47 → 7.17.48

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.
@@ -7,9 +7,9 @@
7
7
  import * as types from './constants';
8
8
  import { LINE, WHATSAPP, RCS, ZALO } from '../CreativesContainer/constants';
9
9
 
10
- export function getAllTemplates(channel, queryParams) {
10
+ export function getAllTemplates(channel, queryParams, intlCopyOf = '') {
11
11
  return {
12
- type: types.GET_ALL_TEMPLATES_REQUEST, channel, queryParams,
12
+ type: types.GET_ALL_TEMPLATES_REQUEST, channel, queryParams, intlCopyOf,
13
13
  };
14
14
  }
15
15
 
@@ -93,7 +93,8 @@ import {
93
93
  FACEBOOK as FACEBOOK_CHANNEL,
94
94
  CREATE,
95
95
  } from '../App/constants';
96
- import { MAX_WHATSAPP_TEMPLATES, WARNING_WHATSAPP_TEMPLATES } from './constants';
96
+ import {MAX_WHATSAPP_TEMPLATES, WARNING_WHATSAPP_TEMPLATES } from './constants';
97
+ import { COPY_OF } from '../../containers/App/constants';
97
98
  import {
98
99
  TWILIO_CATEGORY_OPTIONS,
99
100
  KARIX_GUPSHUP_CATEGORY_OPTIONS,
@@ -309,6 +310,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
309
310
  }
310
311
 
311
312
  componentDidMount() {
313
+ const {formatMessage} =this.props?.intl || {};
312
314
  if (this.props.location.query.type === 'embedded' && this.isEnabledInLibraryModule("setLocale")) {
313
315
  this.setLocale();
314
316
  }
@@ -334,7 +336,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
334
336
  if ((this.state.channel || '').toLowerCase() === "sms" && isTraiDltFeature) {
335
337
  queryParams.traiEnable = true;
336
338
  }
337
- this.props.actions.getAllTemplates(channel, queryParams);
339
+ this.props.actions.getAllTemplates(channel, queryParams,`${formatMessage(globalMessages.copyOf)}`);
338
340
  }
339
341
 
340
342
  window.addEventListener("message", this.handleFrameTasks);
@@ -757,6 +759,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
757
759
  if ((this.state.channel || '').toLowerCase() === "sms" && isTraiDltFeature) {
758
760
  queryParams.traiEnable = true;
759
761
  }
762
+ const copyOf = this.props?.intl?.formatMessage(globalMessages.copyOf);
760
763
  if (resetTemplates) {
761
764
  if(this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
762
765
  queryParams.name = this.state.searchText;
@@ -770,7 +773,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
770
773
  queryParams.originalId = this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier;
771
774
  }
772
775
  const channel = this.state.channel;
773
- this.props.actions.getAllTemplates(channel, queryParams);
776
+ this.props.actions.getAllTemplates(channel, queryParams,`${copyOf}`);
774
777
  } else if ((resetPage || (page === 1 && this.state.templatesCount === 0) || page <= (this.state.templatesCount / this.state.perPageLimit))) {
775
778
  if (getNextPage) {
776
779
  page += 1;
@@ -812,7 +815,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
812
815
  queryParams.page = page;
813
816
  queryParams.perPage = this.state.perPageLimit;
814
817
  const channel = this.state.channel;
815
- this.props.actions.getAllTemplates(channel, queryParams);
818
+ this.props.actions.getAllTemplates(channel, queryParams, `${copyOf}`);
816
819
  });
817
820
  }
818
821
  };
@@ -1756,7 +1759,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1756
1759
 
1757
1760
  duplicateTemplate(template) {
1758
1761
  const duplicateObj = cloneDeep(template);
1759
- duplicateObj.name = `${this.props.intl.formatMessage(globalMessages.copyOf)} ${template?.name} ${moment().format('MM-DD-YYYY HH:mm:ss')}`;
1762
+ duplicateObj.name = `${COPY_OF} ${template?.name} ${moment().format('MM-DD-YYYY HH:mm:ss')}`;
1760
1763
  delete duplicateObj._id;
1761
1764
 
1762
1765
  if (this.state.channel.toLowerCase() === "mobilepush") {
@@ -4,7 +4,7 @@ import { LOCATION_CHANGE } from 'react-router-redux';
4
4
  import * as Api from '../../services/api';
5
5
  import * as types from './constants';
6
6
  import { saveCdnConfigs, removeAllCdnLocalStorageItems } from '../../utils/cdnTransformation';
7
-
7
+ import { COPY_OF } from '../../containers/App/constants';
8
8
  // Individual exports for testing
9
9
  export function* getAllTemplates(channel, queryParams) {
10
10
  try {
@@ -20,6 +20,13 @@ export function* getAllTemplates(channel, queryParams) {
20
20
  } else if (channel.channel === 'wechat' && channel.queryParams && channel.queryParams.sortBy && channel.queryParams.sortBy.toLocaleLowerCase() === ("Alphabetically").toLocaleLowerCase()) {
21
21
  channelTemplates.templates.sort((a, b) => b.name - a.name);
22
22
  }
23
+ // Update the "name" property in each template
24
+ if (channel.intlCopyOf && channelTemplates?.templates) {
25
+ channelTemplates.templates = channelTemplates.templates.map((template) => ({
26
+ ...template,
27
+ name: template.name.replace(new RegExp(COPY_OF, 'g'), channel.intlCopyOf),
28
+ }));
29
+ }
23
30
  yield put({ type: types.GET_ALL_TEMPLATES_SUCCESS, data: channelTemplates, weCRMTemplate: result.response.unMapped, isReset: channel.queryParams.page === 1 });
24
31
  } catch (error) {
25
32
  yield put({ type: types.GET_ALL_TEMPLATES_FAILURE, error });
@@ -121,9 +128,7 @@ export function* sendZippedFile({selectedFile, errorHandler, successHandler}) {
121
128
  errorMessage = result.message;
122
129
  yield errorHandler(errorMessage);
123
130
  }
124
-
125
-
126
- console.log("Got decoded result", decodeURIComponent(result.response.metaEntity.htmlContent));
131
+
127
132
  yield [
128
133
  put({
129
134
  type: types.SEND_ZIPPED_FILE_SUCCESS,
@@ -144,7 +149,6 @@ export function* sendZippedFile({selectedFile, errorHandler, successHandler}) {
144
149
 
145
150
  export function* getDefaultBeeTemplates() {
146
151
  try {
147
-
148
152
  const result = yield call(Api.getDefaultBeeTemplates);
149
153
  const edmTemplates = result.response;
150
154
  yield put({ type: types.GET_DEAFULT_BEE_TEMPLATES_SUCCESS, data: edmTemplates });
@@ -155,7 +159,6 @@ export function* getDefaultBeeTemplates() {
155
159
 
156
160
  export function* getTemplateDetails(id, channel) {
157
161
  try {
158
-
159
162
  const result = yield call(Api.getTemplateDetails, id, channel);
160
163
  // const sidebar = result.response.sidebar;
161
164
  yield put({ type: types.GET_TEMPLATE_DETAILS_SUCCESS, data: result.response });
@@ -208,7 +211,6 @@ function* watchGetUserList() {
208
211
  }
209
212
 
210
213
  function* watchFetchWeCrmAccounts() {
211
-
212
214
  const watcher = yield takeLatest(types.GET_WECRM_ACCOUNTS_REQUEST, fetchWeCrmAccounts);
213
215
  yield take(LOCATION_CHANGE);
214
216
  yield cancel(watcher);
@@ -430,7 +430,7 @@ exports[`Test Templates container Should render temlates when Zalo templates are
430
430
  size="size-r"
431
431
  width={60}
432
432
  />
433
- <InjectIntl(Wrapper)
433
+ <Wrapper
434
434
  centered={true}
435
435
  className="delete-template-confirm"
436
436
  closeText="Cancel"
@@ -441,7 +441,7 @@ exports[`Test Templates container Should render temlates when Zalo templates are
441
441
  visible={false}
442
442
  >
443
443
  Are you sure you wish to delete this template?
444
- </InjectIntl(Wrapper)>
444
+ </Wrapper>
445
445
  </CapRow>
446
446
  </div>
447
447
  </Fragment>
@@ -668,7 +668,7 @@ exports[`Test Templates container Should render temlates when whatsapp templates
668
668
  size="size-r"
669
669
  width={60}
670
670
  />
671
- <InjectIntl(Wrapper)
671
+ <Wrapper
672
672
  centered={true}
673
673
  className="delete-template-confirm"
674
674
  closeText="Cancel"
@@ -679,7 +679,7 @@ exports[`Test Templates container Should render temlates when whatsapp templates
679
679
  visible={false}
680
680
  >
681
681
  Are you sure you wish to delete this template?
682
- </InjectIntl(Wrapper)>
682
+ </Wrapper>
683
683
  </CapRow>
684
684
  </div>
685
685
  </Fragment>
@@ -962,7 +962,7 @@ exports[`Test Templates container Should render temlates when whatsapp templates
962
962
  size="size-r"
963
963
  width={60}
964
964
  />
965
- <InjectIntl(Wrapper)
965
+ <Wrapper
966
966
  centered={true}
967
967
  className="delete-template-confirm"
968
968
  closeText="Cancel"
@@ -973,7 +973,7 @@ exports[`Test Templates container Should render temlates when whatsapp templates
973
973
  visible={false}
974
974
  >
975
975
  Are you sure you wish to delete this template?
976
- </InjectIntl(Wrapper)>
976
+ </Wrapper>
977
977
  </CapRow>
978
978
  </div>
979
979
  </Fragment>
@@ -1119,7 +1119,7 @@ exports[`Test Templates container Should render temlates when zalo templates are
1119
1119
  size="size-r"
1120
1120
  width={60}
1121
1121
  />
1122
- <InjectIntl(Wrapper)
1122
+ <Wrapper
1123
1123
  centered={true}
1124
1124
  className="delete-template-confirm"
1125
1125
  closeText="Cancel"
@@ -1130,7 +1130,7 @@ exports[`Test Templates container Should render temlates when zalo templates are
1130
1130
  visible={false}
1131
1131
  >
1132
1132
  Are you sure you wish to delete this template?
1133
- </InjectIntl(Wrapper)>
1133
+ </Wrapper>
1134
1134
  </CapRow>
1135
1135
  </div>
1136
1136
  </Fragment>
@@ -1592,7 +1592,7 @@ Click {{3}} to unsubscribe",
1592
1592
  size="size-r"
1593
1593
  width={60}
1594
1594
  />
1595
- <InjectIntl(Wrapper)
1595
+ <Wrapper
1596
1596
  centered={true}
1597
1597
  className="delete-template-confirm"
1598
1598
  closeText="Cancel"
@@ -1603,7 +1603,7 @@ Click {{3}} to unsubscribe",
1603
1603
  visible={false}
1604
1604
  >
1605
1605
  Are you sure you wish to delete this template?
1606
- </InjectIntl(Wrapper)>
1606
+ </Wrapper>
1607
1607
  </CapRow>
1608
1608
  </div>
1609
1609
  </Fragment>
@@ -2033,7 +2033,7 @@ Click {{3}} to unsubscribe",
2033
2033
  size="size-r"
2034
2034
  width={60}
2035
2035
  />
2036
- <InjectIntl(Wrapper)
2036
+ <Wrapper
2037
2037
  centered={true}
2038
2038
  className="delete-template-confirm"
2039
2039
  closeText="Cancel"
@@ -2044,7 +2044,7 @@ Click {{3}} to unsubscribe",
2044
2044
  visible={false}
2045
2045
  >
2046
2046
  Are you sure you wish to delete this template?
2047
- </InjectIntl(Wrapper)>
2047
+ </Wrapper>
2048
2048
  </CapRow>
2049
2049
  </div>
2050
2050
  </Fragment>
@@ -2474,7 +2474,7 @@ Click {{3}} to unsubscribe",
2474
2474
  size="size-r"
2475
2475
  width={60}
2476
2476
  />
2477
- <InjectIntl(Wrapper)
2477
+ <Wrapper
2478
2478
  centered={true}
2479
2479
  className="delete-template-confirm"
2480
2480
  closeText="Cancel"
@@ -2485,7 +2485,7 @@ Click {{3}} to unsubscribe",
2485
2485
  visible={false}
2486
2486
  >
2487
2487
  Are you sure you wish to delete this template?
2488
- </InjectIntl(Wrapper)>
2488
+ </Wrapper>
2489
2489
  </CapRow>
2490
2490
  </div>
2491
2491
  </Fragment>
@@ -2738,7 +2738,7 @@ exports[`Test Templates container Test removing all whatsapp filterss 1`] = `
2738
2738
  size="size-r"
2739
2739
  width={60}
2740
2740
  />
2741
- <InjectIntl(Wrapper)
2741
+ <Wrapper
2742
2742
  centered={true}
2743
2743
  className="delete-template-confirm"
2744
2744
  closeText="Cancel"
@@ -2749,7 +2749,7 @@ exports[`Test Templates container Test removing all whatsapp filterss 1`] = `
2749
2749
  visible={false}
2750
2750
  >
2751
2751
  Are you sure you wish to delete this template?
2752
- </InjectIntl(Wrapper)>
2752
+ </Wrapper>
2753
2753
  </CapRow>
2754
2754
  </div>
2755
2755
  </Fragment>
@@ -2976,7 +2976,7 @@ exports[`Test Templates container Test removing all whatsapp filterss 2`] = `
2976
2976
  size="size-r"
2977
2977
  width={60}
2978
2978
  />
2979
- <InjectIntl(Wrapper)
2979
+ <Wrapper
2980
2980
  centered={true}
2981
2981
  className="delete-template-confirm"
2982
2982
  closeText="Cancel"
@@ -2987,7 +2987,7 @@ exports[`Test Templates container Test removing all whatsapp filterss 2`] = `
2987
2987
  visible={false}
2988
2988
  >
2989
2989
  Are you sure you wish to delete this template?
2990
- </InjectIntl(Wrapper)>
2990
+ </Wrapper>
2991
2991
  </CapRow>
2992
2992
  </div>
2993
2993
  </Fragment>
@@ -3214,7 +3214,7 @@ exports[`Test Templates container Test removing single filter 1`] = `
3214
3214
  size="size-r"
3215
3215
  width={60}
3216
3216
  />
3217
- <InjectIntl(Wrapper)
3217
+ <Wrapper
3218
3218
  centered={true}
3219
3219
  className="delete-template-confirm"
3220
3220
  closeText="Cancel"
@@ -3225,7 +3225,7 @@ exports[`Test Templates container Test removing single filter 1`] = `
3225
3225
  visible={false}
3226
3226
  >
3227
3227
  Are you sure you wish to delete this template?
3228
- </InjectIntl(Wrapper)>
3228
+ </Wrapper>
3229
3229
  </CapRow>
3230
3230
  </div>
3231
3231
  </Fragment>
@@ -11,8 +11,9 @@ describe("Test zalo list actions", () => {
11
11
  const expected = {
12
12
  type: types.GET_ALL_TEMPLATES_REQUEST,
13
13
  channel,
14
+ intlCopyOf: "test",
14
15
  queryParams,
15
16
  };
16
- expect(getAllTemplates(channel, queryParams)).toEqual(expected);
17
+ expect(getAllTemplates(channel, queryParams, "test")).toEqual(expected);
17
18
  });
18
19
  });
@@ -55,6 +55,10 @@ export const getAllTemplatesListSuccess = {
55
55
  },
56
56
  },
57
57
  "type": "ZALO",
58
+ response: {
59
+ templates: [{name: '1', id: '2'}],
60
+ },
61
+ intlCopyOf: 'test',
58
62
  };
59
63
 
60
64
  export const getCdnTransformationConfigFailure = {
@@ -80,14 +80,36 @@ describe('watchForGetJourneyList saga', () => {
80
80
  describe('templateList saga', () => {
81
81
  it('handle valid response from api', () => {
82
82
  expectSaga(getAllTemplates, mockData.getAllTemplatesListSuccess)
83
- .provide([[matchers.call.fn(api.getAllTemplates, mockData.getAllTemplatesListSuccess)]])
84
- .put({
83
+ .provide([
84
+ [
85
+ matchers.call.fn(api.getAllTemplates),
86
+ mockData.getAllTemplatesListSuccess,
87
+ ],
88
+ ]).put({
85
89
  type: types.GET_ALL_TEMPLATES_SUCCESS,
86
- res: mockData.getAllTemplatesListSuccess,
90
+ data: mockData.getAllTemplatesListSuccess,
91
+ weCRMTemplate: mockData.getAllTemplatesListSuccess,
92
+ isReset: mockData.getAllTemplatesListSuccess?.queryParams?.page === 1,
87
93
  })
88
94
  .run();
89
95
  });
90
96
 
97
+ it('handle valid response from api', () => {
98
+ mockData.getAllTemplatesListSuccess.intlCopyOf = '';
99
+ expectSaga(getAllTemplates, mockData.getAllTemplatesListSuccess)
100
+ .provide([
101
+ [
102
+ matchers.call.fn(api.getAllTemplates),
103
+ mockData.getAllTemplatesListSuccess,
104
+ ],
105
+ ]).put({
106
+ type: types.GET_ALL_TEMPLATES_SUCCESS,
107
+ data: mockData.getAllTemplatesListSuccess,
108
+ weCRMTemplate: mockData.getAllTemplatesListSuccess,
109
+ isReset: mockData.getAllTemplatesListSuccess?.queryParams?.page === 1,
110
+ })
111
+ .run();
112
+ });
91
113
  it('handles error thrown from api', () => {
92
114
  expectSaga(getAllTemplates, mockData.getAllTemplatesListFailure)
93
115
  .provide([