@capillarytech/creatives-library 8.0.347 → 8.0.348

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 (38) hide show
  1. package/package.json +1 -1
  2. package/services/api.js +0 -20
  3. package/services/tests/api.test.js +0 -59
  4. package/utils/tests/v2Common.test.js +1 -46
  5. package/utils/v2common.js +0 -18
  6. package/v2Components/CapCustomSkeleton/index.js +1 -1
  7. package/v2Components/CapCustomSkeleton/tests/__snapshots__/index.test.js.snap +12 -12
  8. package/v2Components/CommonTestAndPreview/UnifiedPreview/WhatsAppPreviewContent.js +18 -6
  9. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +27 -0
  10. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/WhatsAppPreviewContent.test.js +48 -0
  11. package/v2Components/TemplatePreview/_templatePreview.scss +21 -0
  12. package/v2Components/TemplatePreview/index.js +18 -6
  13. package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +1 -0
  14. package/v2Containers/CreativesContainer/SlideBoxFooter.js +1 -3
  15. package/v2Containers/CreativesContainer/index.js +9 -6
  16. package/v2Containers/CreativesContainer/messages.js +0 -4
  17. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -3
  18. package/v2Containers/Templates/ChannelTypeIllustration.js +6 -23
  19. package/v2Containers/Templates/_templates.scss +24 -179
  20. package/v2Containers/Templates/actions.js +0 -44
  21. package/v2Containers/Templates/constants.js +0 -23
  22. package/v2Containers/Templates/index.js +58 -378
  23. package/v2Containers/Templates/messages.js +0 -88
  24. package/v2Containers/Templates/reducer.js +1 -84
  25. package/v2Containers/Templates/sagas.js +0 -64
  26. package/v2Containers/Templates/selectors.js +0 -12
  27. package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +0 -12
  28. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1122 -1345
  29. package/v2Containers/Templates/tests/index.test.js +0 -6
  30. package/v2Containers/Templates/tests/reducer.test.js +0 -178
  31. package/v2Containers/Templates/tests/sagas.test.js +8 -390
  32. package/v2Containers/Templates/tests/selector.test.js +0 -32
  33. package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -1
  34. package/v2Containers/Whatsapp/constants.js +8 -0
  35. package/v2Containers/Whatsapp/index.js +142 -5
  36. package/v2Containers/Whatsapp/index.scss +8 -0
  37. package/v2Containers/Whatsapp/messages.js +16 -0
  38. package/v2Containers/Assets/images/archive_Empty_Illustration.svg +0 -9
@@ -618,92 +618,4 @@ export default defineMessages({
618
618
  id: `${scope}.templateUpdateSuccess`,
619
619
  defaultMessage: 'Template updated successfully',
620
620
  },
621
- "archiveTemplates": {
622
- id: `${scope}.archiveTemplates`,
623
- defaultMessage: 'Archive templates',
624
- },
625
- "archiveTemplateContent": {
626
- id: `${scope}.archiveTemplateContent`,
627
- defaultMessage: 'These templates will be archived and unavailable for use. You can restore them anytime.',
628
- },
629
- "archiveTemplateSingleContent": {
630
- id: `${scope}.archiveTemplateSingleContent`,
631
- defaultMessage: 'This template will be archived and unavailable for use. You can restore it anytime.',
632
- },
633
- "unarchiveTemplates": {
634
- id: `${scope}.unarchiveTemplates`,
635
- defaultMessage: 'Unarchive templates',
636
- },
637
- "unarchiveTemplateContent": {
638
- id: `${scope}.unarchiveTemplateContent`,
639
- defaultMessage: 'These templates will be unarchived and available for use again.',
640
- },
641
- "unarchiveTemplateSingleContent": {
642
- id: `${scope}.unarchiveTemplateSingleContent`,
643
- defaultMessage: 'This template will be unarchived and available for use again.',
644
- },
645
- "archiveConfirmOk": {
646
- id: `${scope}.archiveConfirmOk`,
647
- defaultMessage: 'Confirm',
648
- },
649
- "archiveConfirmCancel": {
650
- id: `${scope}.archiveConfirmCancel`,
651
- defaultMessage: 'Cancel',
652
- },
653
- "archiveButton": {
654
- id: `${scope}.archiveButton`,
655
- defaultMessage: 'Archive',
656
- },
657
- "unarchiveButton": {
658
- id: `${scope}.unarchiveButton`,
659
- defaultMessage: 'Unarchive',
660
- },
661
- "archivedTag": {
662
- id: `${scope}.archivedTag`,
663
- defaultMessage: 'Archived',
664
- },
665
- "archivedTemplates": {
666
- id: `${scope}.archivedTemplates`,
667
- defaultMessage: 'Archived templates',
668
- },
669
- "searchArchivedTemplates": {
670
- id: `${scope}.searchArchivedTemplates`,
671
- defaultMessage: 'Search archived templates...',
672
- },
673
- "templatesSelected": {
674
- id: `${scope}.templatesSelected`,
675
- defaultMessage: '{count} {count, plural, one {template} other {templates}} selected',
676
- },
677
- "cannotEditArchivedTemplate": {
678
- id: `${scope}.cannotEditArchivedTemplate`,
679
- defaultMessage: 'Cannot edit an archived template. Please unarchive it first.',
680
- },
681
- "noArchivedCreatives": {
682
- id: `${scope}.noArchivedCreatives`,
683
- defaultMessage: 'No archived creatives',
684
- },
685
- "noArchivedCreativesDesc": {
686
- id: `${scope}.noArchivedCreativesDesc`,
687
- defaultMessage: 'Creatives you archive will appear here',
688
- },
689
- "templateNameLabel": {
690
- id: `${scope}.templateNameLabel`,
691
- defaultMessage: 'Template name ',
692
- },
693
- "archiveTemplateSuccess": {
694
- id: `${scope}.archiveTemplateSuccess`,
695
- defaultMessage: 'Template archived successfully',
696
- },
697
- "unarchiveTemplateSuccess": {
698
- id: `${scope}.unarchiveTemplateSuccess`,
699
- defaultMessage: 'Template unarchived successfully',
700
- },
701
- "bulkArchiveSuccess": {
702
- id: `${scope}.bulkArchiveSuccess`,
703
- defaultMessage: '{count} {count, plural, one {template} other {templates}} archived successfully',
704
- },
705
- "bulkUnarchiveSuccess": {
706
- id: `${scope}.bulkUnarchiveSuccess`,
707
- defaultMessage: '{count} {count, plural, one {template} other {templates}} unarchived successfully',
708
- },
709
621
  });
@@ -26,14 +26,6 @@ export const initialState = fromJS({
26
26
  reportsSettings: {},
27
27
  },
28
28
  senderDetails: {},
29
- archiveFilter: 'active',
30
- isArchivedMode: false,
31
- selectedTemplateIds: fromJS([]),
32
- archiveInProgress: false,
33
- unarchiveInProgress: false,
34
- bulkArchiveInProgress: false,
35
- bulkUnarchiveInProgress: false,
36
- archiveListingRefreshType: null,
37
29
  });
38
30
 
39
31
  function templatesReducer(state = initialState, action) {
@@ -45,18 +37,16 @@ function templatesReducer(state = initialState, action) {
45
37
  case types.GET_ALL_TEMPLATES_SUCCESS:
46
38
  if (action.isReset) {
47
39
  return state.set('getAllTemplatesInProgress', false)
48
- .set('archiveListingRefreshType', null)
49
40
  .set('templates', action.data ? action.data.templates : [])
50
41
  .set('isSearch', action.data ? action.data.search : false)
51
42
  .set('weCRMtemplates', action.weCRMTemplate ? action.weCRMTemplate : []).set('templateError', {});
52
43
  }
53
44
  return state.set('getAllTemplatesInProgress', false)
54
- .set('archiveListingRefreshType', null)
55
45
  .set('templates', action.data ? state.get('templates').concat(action.data.templates) : [])
56
46
  .set('isSearch', action.data ? action.data.search : false)
57
47
  .set('weCRMtemplates', action.weCRMTemplate ? state.get('weCRMtemplates').concat(action.weCRMTemplate) : []);
58
48
  case types.GET_ALL_TEMPLATES_FAILURE:
59
- return state.set('getAllTemplatesInProgress', false).set('archiveListingRefreshType', null).set('templateError', action.error);
49
+ return state.set('getAllTemplatesInProgress', false).set('templateError', action.error);
60
50
  case types.DELETE_TEMPLATE_REQUEST:
61
51
  return state.set('deleteTemplateInProgress', true)
62
52
  .set('deleteTemplateError', null);
@@ -241,79 +231,6 @@ function templatesReducer(state = initialState, action) {
241
231
  hostName: '',
242
232
  errors: action.payload,
243
233
  });
244
- case types.SET_ARCHIVE_FILTER:
245
- return state
246
- .set('archiveFilter', action.filter)
247
- .set('templates', [])
248
- .set('selectedTemplateIds', fromJS([]));
249
- case types.SET_ARCHIVED_MODE:
250
- return state
251
- .set('isArchivedMode', action.isArchived)
252
- .set('archiveFilter', action.isArchived ? 'archived' : 'active')
253
- .set('templates', [])
254
- .set('selectedTemplateIds', fromJS([]));
255
- case types.TOGGLE_TEMPLATE_SELECTION: {
256
- const rawSelected = state.get('selectedTemplateIds');
257
- // Defensive: handle undefined (stale persisted state) or plain array (pre-fromJS migration)
258
- const currentSelected = rawSelected && typeof rawSelected.toJS === 'function'
259
- ? rawSelected.toJS()
260
- : (Array.isArray(rawSelected) ? rawSelected : []);
261
- const idx = currentSelected.indexOf(action.id);
262
- const newSelected = idx === -1
263
- ? [...currentSelected, action.id]
264
- : currentSelected.filter((id) => id !== action.id);
265
- return state.set('selectedTemplateIds', fromJS(newSelected));
266
- }
267
- case types.SELECT_ALL_TEMPLATES:
268
- return state.set('selectedTemplateIds', fromJS(action.ids));
269
- case types.CLEAR_TEMPLATE_SELECTION:
270
- return state.set('selectedTemplateIds', fromJS([]));
271
- case types.ARCHIVE_TEMPLATE_REQUEST:
272
- return state.set('archiveInProgress', true).set('archiveError', null);
273
- case types.ARCHIVE_TEMPLATE_SUCCESS: {
274
- const afterArchive = state.get('selectedTemplateIds');
275
- const archiveSelected = afterArchive && typeof afterArchive.toJS === 'function' ? afterArchive.toJS() : [];
276
- return state
277
- .set('archiveInProgress', false)
278
- .set('archiveError', null)
279
- .set('archiveSuccessPayload', { successMessage: action.successMessage, description: action.description })
280
- .set('selectedTemplateIds', fromJS(archiveSelected.filter((sid) => sid !== action.id)));
281
- }
282
- case types.ARCHIVE_TEMPLATE_FAILURE:
283
- return state.set('archiveInProgress', false).set('archiveError', action.error);
284
- case types.UNARCHIVE_TEMPLATE_REQUEST:
285
- return state.set('unarchiveInProgress', true).set('unarchiveError', null);
286
- case types.UNARCHIVE_TEMPLATE_SUCCESS: {
287
- const afterUnarchive = state.get('selectedTemplateIds');
288
- const unarchiveSelected = afterUnarchive && typeof afterUnarchive.toJS === 'function' ? afterUnarchive.toJS() : [];
289
- return state
290
- .set('unarchiveInProgress', false)
291
- .set('unarchiveError', null)
292
- .set('unarchiveSuccessPayload', { successMessage: action.successMessage, description: action.description })
293
- .set('selectedTemplateIds', fromJS(unarchiveSelected.filter((sid) => sid !== action.id)));
294
- }
295
- case types.UNARCHIVE_TEMPLATE_FAILURE:
296
- return state.set('unarchiveInProgress', false).set('unarchiveError', action.error);
297
- case types.BULK_ARCHIVE_REQUEST:
298
- return state.set('bulkArchiveInProgress', true).set('bulkArchiveError', null);
299
- case types.BULK_ARCHIVE_SUCCESS:
300
- return state
301
- .set('bulkArchiveInProgress', false)
302
- .set('bulkArchiveError', null)
303
- .set('bulkArchiveSuccessPayload', { successMessage: action.successMessage, count: action.count })
304
- .set('selectedTemplateIds', fromJS([]));
305
- case types.BULK_ARCHIVE_FAILURE:
306
- return state.set('bulkArchiveInProgress', false).set('bulkArchiveError', action.error);
307
- case types.BULK_UNARCHIVE_REQUEST:
308
- return state.set('bulkUnarchiveInProgress', true).set('bulkUnarchiveError', null);
309
- case types.BULK_UNARCHIVE_SUCCESS:
310
- return state
311
- .set('bulkUnarchiveInProgress', false)
312
- .set('bulkUnarchiveError', null)
313
- .set('bulkUnarchiveSuccessPayload', { successMessage: action.successMessage, count: action.count })
314
- .set('selectedTemplateIds', fromJS([]));
315
- case types.BULK_UNARCHIVE_FAILURE:
316
- return state.set('bulkUnarchiveInProgress', false).set('bulkUnarchiveError', action.error);
317
234
  default:
318
235
  return state;
319
236
  }
@@ -2,7 +2,6 @@ import {
2
2
  call, put, takeLatest, all,
3
3
  } from 'redux-saga/effects';
4
4
  import get from 'lodash/get';
5
- import { CapNotification } from '@capillarytech/cap-ui-library';
6
5
  // import { schema, normalize } from 'normalizr';
7
6
  import * as Api from '../../services/api';
8
7
  import * as types from './constants';
@@ -10,7 +9,6 @@ import { saveCdnConfigs, removeAllCdnLocalStorageItems } from '../../utils/cdnTr
10
9
  import { COPY_OF } from '../../constants/unified';
11
10
  import { ZALO_TEMPLATE_INFO_REQUEST } from '../Zalo/constants';
12
11
  import { getTemplateInfoById } from '../Zalo/saga';
13
-
14
12
  // Individual exports for testing
15
13
  export function* getAllTemplates(channel, queryParams) {
16
14
  try {
@@ -203,64 +201,6 @@ export function* getSenderDetails({
203
201
  }
204
202
  }
205
203
 
206
- export function* archiveTemplateSaga({ channel, id, successMessage, description }) {
207
- try {
208
- yield call(Api.archiveTemplate, { channel, id });
209
- yield put({ type: types.ARCHIVE_TEMPLATE_SUCCESS, id, successMessage, description });
210
- } catch (error) {
211
- yield put({ type: types.ARCHIVE_TEMPLATE_FAILURE, error });
212
- CapNotification.error({ message: error.message || 'Failed to archive template' });
213
- }
214
- }
215
-
216
- export function* unarchiveTemplateSaga({ channel, id, successMessage, description }) {
217
- try {
218
- yield call(Api.unarchiveTemplate, { channel, id });
219
- yield put({ type: types.UNARCHIVE_TEMPLATE_SUCCESS, id, successMessage, description });
220
- } catch (error) {
221
- yield put({ type: types.UNARCHIVE_TEMPLATE_FAILURE, error });
222
- CapNotification.error({ message: error.message || 'Failed to unarchive template' });
223
- }
224
- }
225
-
226
- export function* bulkArchiveTemplatesSaga({ channel, ids, successMessage }) {
227
- try {
228
- const result = yield call(Api.bulkArchiveTemplates, { channel, ids });
229
- const count = get(result, 'response.modifiedCount', ids.length);
230
- yield put({ type: types.BULK_ARCHIVE_SUCCESS, successMessage, count });
231
- } catch (error) {
232
- yield put({ type: types.BULK_ARCHIVE_FAILURE, error });
233
- CapNotification.error({ message: error.message || 'Failed to archive templates' });
234
- }
235
- }
236
-
237
- export function* bulkUnarchiveTemplatesSaga({ channel, ids, successMessage }) {
238
- try {
239
- const result = yield call(Api.bulkUnarchiveTemplates, { channel, ids });
240
- const count = get(result, 'response.modifiedCount', ids.length);
241
- yield put({ type: types.BULK_UNARCHIVE_SUCCESS, successMessage, count });
242
- } catch (error) {
243
- yield put({ type: types.BULK_UNARCHIVE_FAILURE, error });
244
- CapNotification.error({ message: error.message || 'Failed to unarchive templates' });
245
- }
246
- }
247
-
248
- export function* watchArchiveTemplate() {
249
- yield takeLatest(types.ARCHIVE_TEMPLATE_REQUEST, archiveTemplateSaga);
250
- }
251
-
252
- export function* watchUnarchiveTemplate() {
253
- yield takeLatest(types.UNARCHIVE_TEMPLATE_REQUEST, unarchiveTemplateSaga);
254
- }
255
-
256
- export function* watchBulkArchive() {
257
- yield takeLatest(types.BULK_ARCHIVE_REQUEST, bulkArchiveTemplatesSaga);
258
- }
259
-
260
- export function* watchBulkUnarchive() {
261
- yield takeLatest(types.BULK_UNARCHIVE_REQUEST, bulkUnarchiveTemplatesSaga);
262
- }
263
-
264
204
  export function* watchGetAllTemplates() {
265
205
  yield takeLatest(types.GET_ALL_TEMPLATES_REQUEST, getAllTemplates);
266
206
  }
@@ -343,10 +283,6 @@ export function* v2TemplateSaga() {
343
283
  watchFetchWeCrmAccounts(),
344
284
  watchGetSenderDetails(),
345
285
  watchForGetTemplateInfoById(), // Zalo preview functionality from Templates component
346
- watchArchiveTemplate(),
347
- watchUnarchiveTemplate(),
348
- watchBulkArchive(),
349
- watchBulkUnarchive(),
350
286
  ]);
351
287
  }
352
288
 
@@ -72,16 +72,6 @@ const selectBEEEditor = () => createSelector(makeSelectTemplates(), (templates)
72
72
  return BEETemplate || null;
73
73
  });
74
74
 
75
- const selectArchiveFilter = () => createSelector(
76
- makeSelectTemplates(),
77
- (substate) => substate.archiveFilter || 'active',
78
- );
79
-
80
- const selectSelectedTemplateIds = () => createSelector(
81
- makeSelectTemplates(),
82
- (substate) => substate.selectedTemplateIds || [],
83
- );
84
-
85
75
  export {
86
76
  uploadSelector,
87
77
  templateUserList,
@@ -93,6 +83,4 @@ export {
93
83
  selectEdmEditor,
94
84
  selectBEEEditor,
95
85
  selectCmsTemplatesLoader,
96
- selectArchiveFilter,
97
- selectSelectedTemplateIds,
98
86
  };
@@ -320,16 +320,4 @@ describe('ChannelTypeIllustration', () => {
320
320
  }).not.toThrow();
321
321
  });
322
322
  });
323
-
324
- describe('isArchivedMode', () => {
325
- it('should render CapIllustration when isArchivedMode is true', () => {
326
- const wrapper = renderComponent({ isArchivedMode: true });
327
- expect(wrapper.find('CapIllustration').exists()).toBe(true);
328
- });
329
-
330
- it('should render CapIllustration when isArchivedMode is false', () => {
331
- const wrapper = renderComponent({ isArchivedMode: false, currentChannel: SMS });
332
- expect(wrapper.find('CapIllustration').exists()).toBe(true);
333
- });
334
- });
335
323
  });