@capillarytech/creatives-library 8.0.345-alpha.13 → 8.0.345-alpha.14

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 (29) 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 +11 -3
  11. package/v2Containers/Email/sagas.js +9 -5
  12. package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +4 -0
  13. package/v2Containers/Email/tests/sagas.test.js +21 -3
  14. package/v2Containers/Templates/ChannelTypeIllustration.js +6 -23
  15. package/v2Containers/Templates/_templates.scss +24 -130
  16. package/v2Containers/Templates/actions.js +0 -36
  17. package/v2Containers/Templates/constants.js +0 -23
  18. package/v2Containers/Templates/index.js +30 -286
  19. package/v2Containers/Templates/messages.js +0 -68
  20. package/v2Containers/Templates/reducer.js +0 -68
  21. package/v2Containers/Templates/sagas.js +1 -89
  22. package/v2Containers/Templates/selectors.js +0 -12
  23. package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +0 -12
  24. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1122 -1300
  25. package/v2Containers/Templates/tests/index.test.js +0 -6
  26. package/v2Containers/Templates/tests/reducer.test.js +0 -178
  27. package/v2Containers/Templates/tests/sagas.test.js +8 -314
  28. package/v2Containers/Templates/tests/selector.test.js +0 -32
  29. package/v2Containers/Assets/images/archive_Empty_Illustration.svg +0 -9
@@ -26,13 +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
29
  });
37
30
 
38
31
  function templatesReducer(state = initialState, action) {
@@ -238,67 +231,6 @@ function templatesReducer(state = initialState, action) {
238
231
  hostName: '',
239
232
  errors: action.payload,
240
233
  });
241
- case types.SET_ARCHIVE_FILTER:
242
- return state
243
- .set('archiveFilter', action.filter)
244
- .set('templates', [])
245
- .set('selectedTemplateIds', fromJS([]));
246
- case types.SET_ARCHIVED_MODE:
247
- return state
248
- .set('isArchivedMode', action.isArchived)
249
- .set('archiveFilter', action.isArchived ? 'archived' : 'active')
250
- .set('templates', [])
251
- .set('selectedTemplateIds', fromJS([]));
252
- case types.TOGGLE_TEMPLATE_SELECTION: {
253
- const rawSelected = state.get('selectedTemplateIds');
254
- // Defensive: handle undefined (stale persisted state) or plain array (pre-fromJS migration)
255
- const currentSelected = rawSelected && typeof rawSelected.toJS === 'function'
256
- ? rawSelected.toJS()
257
- : (Array.isArray(rawSelected) ? rawSelected : []);
258
- const idx = currentSelected.indexOf(action.id);
259
- const newSelected = idx === -1
260
- ? [...currentSelected, action.id]
261
- : currentSelected.filter((id) => id !== action.id);
262
- return state.set('selectedTemplateIds', fromJS(newSelected));
263
- }
264
- case types.SELECT_ALL_TEMPLATES:
265
- return state.set('selectedTemplateIds', fromJS(action.ids));
266
- case types.CLEAR_TEMPLATE_SELECTION:
267
- return state.set('selectedTemplateIds', fromJS([]));
268
- case types.ARCHIVE_TEMPLATE_REQUEST:
269
- return state.set('archiveInProgress', true);
270
- case types.ARCHIVE_TEMPLATE_SUCCESS: {
271
- const afterArchive = state.get('selectedTemplateIds');
272
- const archiveSelected = afterArchive && typeof afterArchive.toJS === 'function' ? afterArchive.toJS() : [];
273
- return state
274
- .set('archiveInProgress', false)
275
- .set('selectedTemplateIds', fromJS(archiveSelected.filter((sid) => sid !== action.id)));
276
- }
277
- case types.ARCHIVE_TEMPLATE_FAILURE:
278
- return state.set('archiveInProgress', false);
279
- case types.UNARCHIVE_TEMPLATE_REQUEST:
280
- return state.set('unarchiveInProgress', true);
281
- case types.UNARCHIVE_TEMPLATE_SUCCESS: {
282
- const afterUnarchive = state.get('selectedTemplateIds');
283
- const unarchiveSelected = afterUnarchive && typeof afterUnarchive.toJS === 'function' ? afterUnarchive.toJS() : [];
284
- return state
285
- .set('unarchiveInProgress', false)
286
- .set('selectedTemplateIds', fromJS(unarchiveSelected.filter((sid) => sid !== action.id)));
287
- }
288
- case types.UNARCHIVE_TEMPLATE_FAILURE:
289
- return state.set('unarchiveInProgress', false);
290
- case types.BULK_ARCHIVE_REQUEST:
291
- return state.set('bulkArchiveInProgress', true);
292
- case types.BULK_ARCHIVE_SUCCESS:
293
- return state.set('bulkArchiveInProgress', false).set('selectedTemplateIds', fromJS([]));
294
- case types.BULK_ARCHIVE_FAILURE:
295
- return state.set('bulkArchiveInProgress', false);
296
- case types.BULK_UNARCHIVE_REQUEST:
297
- return state.set('bulkUnarchiveInProgress', true);
298
- case types.BULK_UNARCHIVE_SUCCESS:
299
- return state.set('bulkUnarchiveInProgress', false).set('selectedTemplateIds', fromJS([]));
300
- case types.BULK_UNARCHIVE_FAILURE:
301
- return state.set('bulkUnarchiveInProgress', false);
302
234
  default:
303
235
  return state;
304
236
  }
@@ -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
  });