@capillarytech/creatives-library 8.0.345 → 8.0.346

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 (30) 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/v2Components/CapCustomSkeleton/index.js +1 -1
  5. package/v2Components/CapCustomSkeleton/tests/__snapshots__/index.test.js.snap +12 -12
  6. package/v2Containers/CreativesContainer/SlideBoxFooter.js +1 -3
  7. package/v2Containers/CreativesContainer/index.js +0 -5
  8. package/v2Containers/CreativesContainer/messages.js +0 -4
  9. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -3
  10. package/v2Containers/Email/reducer.js +12 -3
  11. package/v2Containers/Email/sagas.js +9 -4
  12. package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +4 -0
  13. package/v2Containers/Email/tests/reducer.test.js +47 -0
  14. package/v2Containers/Email/tests/sagas.test.js +146 -6
  15. package/v2Containers/Templates/ChannelTypeIllustration.js +6 -23
  16. package/v2Containers/Templates/_templates.scss +24 -130
  17. package/v2Containers/Templates/actions.js +0 -36
  18. package/v2Containers/Templates/constants.js +0 -23
  19. package/v2Containers/Templates/index.js +30 -286
  20. package/v2Containers/Templates/messages.js +0 -68
  21. package/v2Containers/Templates/reducer.js +0 -68
  22. package/v2Containers/Templates/sagas.js +1 -89
  23. package/v2Containers/Templates/selectors.js +0 -12
  24. package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +0 -12
  25. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1122 -1300
  26. package/v2Containers/Templates/tests/index.test.js +0 -6
  27. package/v2Containers/Templates/tests/reducer.test.js +0 -178
  28. package/v2Containers/Templates/tests/sagas.test.js +8 -314
  29. package/v2Containers/Templates/tests/selector.test.js +0 -32
  30. package/v2Containers/Assets/images/archive_Empty_Illustration.svg +0 -9
@@ -1,9 +1,7 @@
1
- import React from 'react';
2
1
  import {
3
- call, put, select, takeLatest, all,
2
+ call, put, takeLatest, all,
4
3
  } from 'redux-saga/effects';
5
4
  import get from 'lodash/get';
6
- import { CapNotification } from '@capillarytech/cap-ui-library';
7
5
  // import { schema, normalize } from 'normalizr';
8
6
  import * as Api from '../../services/api';
9
7
  import * as types from './constants';
@@ -11,18 +9,6 @@ import { saveCdnConfigs, removeAllCdnLocalStorageItems } from '../../utils/cdnTr
11
9
  import { COPY_OF } from '../../constants/unified';
12
10
  import { ZALO_TEMPLATE_INFO_REQUEST } from '../Zalo/constants';
13
11
  import { getTemplateInfoById } from '../Zalo/saga';
14
-
15
- const templateNameDescription = (templateName) => (
16
- templateName
17
- ? (
18
- <span>
19
- <span className="notification-template-label">Template name </span>
20
- <span className="notification-template-name">{templateName}</span>
21
- </span>
22
- )
23
- : undefined
24
- );
25
-
26
12
  // Individual exports for testing
27
13
  export function* getAllTemplates(channel, queryParams) {
28
14
  try {
@@ -215,76 +201,6 @@ export function* getSenderDetails({
215
201
  }
216
202
  }
217
203
 
218
- export function* archiveTemplateSaga({ channel, id, templateName }) {
219
- try {
220
- yield call(Api.archiveTemplate, { channel, id });
221
- yield put({ type: types.ARCHIVE_TEMPLATE_SUCCESS, id });
222
- const archiveFilter = yield select((state) => state.get('templates') ? state.get('templates').get('archiveFilter', 'active') : 'active');
223
- yield call(getAllTemplates, { channel, queryParams: { page: 1, archiveStatus: archiveFilter } });
224
- CapNotification.success({ message: 'Template archived successfully', description: templateNameDescription(templateName) });
225
- } catch (error) {
226
- yield put({ type: types.ARCHIVE_TEMPLATE_FAILURE, error });
227
- CapNotification.error({ message: 'Failed to archive template' });
228
- }
229
- }
230
-
231
- export function* unarchiveTemplateSaga({ channel, id, templateName }) {
232
- try {
233
- yield call(Api.unarchiveTemplate, { channel, id });
234
- yield put({ type: types.UNARCHIVE_TEMPLATE_SUCCESS, id });
235
- const archiveFilter = yield select((state) => state.get('templates') ? state.get('templates').get('archiveFilter', 'active') : 'active');
236
- yield call(getAllTemplates, { channel, queryParams: { page: 1, archiveStatus: archiveFilter } });
237
- CapNotification.success({ message: 'Template unarchived successfully', description: templateNameDescription(templateName) });
238
- } catch (error) {
239
- yield put({ type: types.UNARCHIVE_TEMPLATE_FAILURE, error });
240
- CapNotification.error({ message: 'Failed to unarchive template' });
241
- }
242
- }
243
-
244
- export function* bulkArchiveTemplatesSaga({ channel, ids }) {
245
- try {
246
- const result = yield call(Api.bulkArchiveTemplates, { channel, ids });
247
- yield put({ type: types.BULK_ARCHIVE_SUCCESS });
248
- const count = get(result, 'response.modifiedCount', ids.length);
249
- const archiveFilter = yield select((state) => state.get('templates') ? state.get('templates').get('archiveFilter', 'active') : 'active');
250
- yield call(getAllTemplates, { channel, queryParams: { page: 1, archiveStatus: archiveFilter } });
251
- CapNotification.success({ message: `${count} templates archived successfully` });
252
- } catch (error) {
253
- yield put({ type: types.BULK_ARCHIVE_FAILURE, error });
254
- CapNotification.error({ message: 'Failed to archive templates' });
255
- }
256
- }
257
-
258
- export function* bulkUnarchiveTemplatesSaga({ channel, ids }) {
259
- try {
260
- const result = yield call(Api.bulkUnarchiveTemplates, { channel, ids });
261
- yield put({ type: types.BULK_UNARCHIVE_SUCCESS });
262
- const count = get(result, 'response.modifiedCount', ids.length);
263
- const archiveFilter = yield select((state) => state.get('templates') ? state.get('templates').get('archiveFilter', 'active') : 'active');
264
- yield call(getAllTemplates, { channel, queryParams: { page: 1, archiveStatus: archiveFilter } });
265
- CapNotification.success({ message: `${count} templates unarchived successfully` });
266
- } catch (error) {
267
- yield put({ type: types.BULK_UNARCHIVE_FAILURE, error });
268
- CapNotification.error({ message: 'Failed to unarchive templates' });
269
- }
270
- }
271
-
272
- export function* watchArchiveTemplate() {
273
- yield takeLatest(types.ARCHIVE_TEMPLATE_REQUEST, archiveTemplateSaga);
274
- }
275
-
276
- export function* watchUnarchiveTemplate() {
277
- yield takeLatest(types.UNARCHIVE_TEMPLATE_REQUEST, unarchiveTemplateSaga);
278
- }
279
-
280
- export function* watchBulkArchive() {
281
- yield takeLatest(types.BULK_ARCHIVE_REQUEST, bulkArchiveTemplatesSaga);
282
- }
283
-
284
- export function* watchBulkUnarchive() {
285
- yield takeLatest(types.BULK_UNARCHIVE_REQUEST, bulkUnarchiveTemplatesSaga);
286
- }
287
-
288
204
  export function* watchGetAllTemplates() {
289
205
  yield takeLatest(types.GET_ALL_TEMPLATES_REQUEST, getAllTemplates);
290
206
  }
@@ -367,10 +283,6 @@ export function* v2TemplateSaga() {
367
283
  watchFetchWeCrmAccounts(),
368
284
  watchGetSenderDetails(),
369
285
  watchForGetTemplateInfoById(), // Zalo preview functionality from Templates component
370
- watchArchiveTemplate(),
371
- watchUnarchiveTemplate(),
372
- watchBulkArchive(),
373
- watchBulkUnarchive(),
374
286
  ]);
375
287
  }
376
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
  });