@capillarytech/creatives-library 8.0.42 → 8.0.43-alpha.1

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 (54) hide show
  1. package/containers/Assets/Gallery/sagas.js +0 -1
  2. package/containers/Cap/sagas.js +5 -5
  3. package/containers/Cap/tests/saga.test.js +2 -4
  4. package/containers/Ebill/sagas.js +3 -1
  5. package/containers/Email/sagas.js +3 -1
  6. package/containers/Line/Create/sagas.js +3 -2
  7. package/containers/Line/Edit/sagas.js +1 -1
  8. package/containers/MobilePush/Create/sagas.js +3 -1
  9. package/containers/MobilePush/Edit/sagas.js +3 -1
  10. package/containers/Sms/Create/sagas.js +3 -1
  11. package/containers/Sms/Edit/sagas.js +3 -1
  12. package/containers/Templates/sagas.js +3 -1
  13. package/containers/WeChat/MapTemplates/sagas.js +3 -1
  14. package/package.json +1 -1
  15. package/services/api.js +18 -22
  16. package/services/tests/api.test.js +3 -1
  17. package/styles/containers/login/_loginPage.scss +2 -1
  18. package/utils/commonUtils.js +6 -3
  19. package/utils/tests/commonUtil.test.js +3 -1
  20. package/v2Components/Ckeditor/index.js +2 -4
  21. package/v2Components/FormBuilder/index.js +1 -1
  22. package/v2Containers/Assets/Gallery/sagas.js +1 -1
  23. package/v2Containers/BeeEditor/sagas.js +2 -2
  24. package/v2Containers/CallTask/sagas.js +1 -1
  25. package/v2Containers/Cap/sagas.js +8 -6
  26. package/v2Containers/CapFacebookPreview/sagas.js +4 -2
  27. package/v2Containers/CreativesContainer/index.js +1 -1
  28. package/v2Containers/Email/sagas.js +4 -2
  29. package/v2Containers/FTP/sagas.js +4 -2
  30. package/v2Containers/Facebook/index.js +1 -1
  31. package/v2Containers/Facebook/sagas.js +7 -3
  32. package/v2Containers/InApp/sagas.js +3 -1
  33. package/v2Containers/InApp/tests/sagas.test.js +2 -2
  34. package/v2Containers/LanguageProvider/sagas.js +3 -1
  35. package/v2Containers/Line/Container/sagas.js +3 -1
  36. package/v2Containers/MobilePush/Create/sagas.js +3 -1
  37. package/v2Containers/MobilePush/Edit/sagas.js +3 -2
  38. package/v2Containers/Rcs/sagas.js +3 -1
  39. package/v2Containers/Sms/Create/actions.js +1 -0
  40. package/v2Containers/Sms/Create/sagas.js +3 -1
  41. package/v2Containers/Sms/Edit/actions.js +1 -0
  42. package/v2Containers/Sms/Edit/index.js +3 -1
  43. package/v2Containers/Sms/Edit/sagas.js +8 -9
  44. package/v2Containers/SmsTrai/Create/sagas.js +3 -1
  45. package/v2Containers/Templates/actions.js +5 -1
  46. package/v2Containers/Templates/index.js +8 -0
  47. package/v2Containers/Templates/reducer.js +7 -0
  48. package/v2Containers/Templates/sagas.js +7 -25
  49. package/v2Containers/TemplatesV2/index.js +4 -8
  50. package/v2Containers/Viber/sagas.js +3 -2
  51. package/v2Containers/WeChat/MapTemplates/sagas.js +3 -1
  52. package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +3 -1
  53. package/v2Containers/Whatsapp/sagas.js +3 -1
  54. package/v2Containers/Zalo/saga.js +1 -1
@@ -5,7 +5,6 @@ import * as types from './constants';
5
5
  export function* getAllAssets(assetType, queryParams) {
6
6
  try {
7
7
  const result = yield call(Api.getAllAssets, assetType, queryParams);
8
- //why are we using assetType.queryParams.page ??
9
8
  yield put({ type: types.GET_ALL_ASSETS_SUCCESS, data: result?.response, isReset: queryParams.page === 1 });
10
9
  } catch (error) {
11
10
  yield put({ type: types.GET_ALL_ASSETS_FAILURE, error });
@@ -1,10 +1,11 @@
1
- import { fork, take, call, put, cancelled, cancel, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ fork, take, call, put, cancelled, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import { getRedirectionUrl } from '@capillarytech/cap-ui-utils/utils/logoutUtil';
3
5
  // import { normalize } from 'normalizr';
4
6
  import * as Api from '../../services/api';
5
7
  import * as LocalStorage from '../../services/localStorageApi';
6
8
  import * as types from './constants';
7
- import config from '../../config/app';
8
9
  // import {makeSelectOrgId} from './selectors';
9
10
 
10
11
  export function* authorize(user) {
@@ -38,12 +39,11 @@ function* switchOrg({orgID}) {
38
39
  export function* loginFlow() {
39
40
  let condition = true;
40
41
  while (condition) {
41
- const { user } = yield take(types.LOGIN_REQUEST);
42
- const task = yield fork(authorize, user);
42
+ const {user} = yield take(types.LOGIN_REQUEST);
43
+ yield fork(authorize, user);
43
44
  const action = yield take([types.LOGOUT_REQUEST, types.LOGIN_FAILURE]);
44
45
  if (action.type === types.LOGOUT_REQUEST) {
45
46
  condition = false;
46
- yield cancel(task);
47
47
  }
48
48
  // yield call(LocalStorage.clearItem, 'token');
49
49
  // yield call(LocalStorage.clearItem, 'orgID');
@@ -24,17 +24,15 @@ describe('loginFlow', () => {
24
24
  it('should handle the login flow', () => {
25
25
  const generator = loginFlow();
26
26
  const user = { username: 'testuser', password: 'password123' };
27
- let task;
28
27
 
29
28
  // First iteration
30
29
  expect(generator.next().value).toEqual(take(LOGIN_REQUEST));
31
30
  expect(generator.next({ user }).value).toEqual(fork(authorize, user));
32
- task = generator.next().value; // Assign the task value
31
+ // task = generator.next().value; // Assign the task value
33
32
  try{
34
- const logoutAction = { type: LOGOUT_REQUEST };
35
33
  const failureAction = { type: LOGIN_FAILURE };
36
34
 
37
- expect(generator.next(logoutAction).value).toEqual(cancel(task));
35
+ // expect(generator.next(logoutAction).value).toEqual(cancel(task));
38
36
 
39
37
  // When LOGIN_FAILURE action is dispatched
40
38
  expect(generator.next(failureAction).value).toEqual(take(LOGIN_REQUEST));
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import * as Api from '../../services/api';
3
5
  import * as types from './constants';
4
6
 
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, takeEvery, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, takeEvery, all,
3
+ } from 'redux-saga/effects';
2
4
  import * as Api from '../../services/api';
3
5
  import * as types from './constants';
4
6
 
@@ -1,6 +1,7 @@
1
1
  // Line Sagas
2
-
3
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
2
+ import {
3
+ call, put, takeLatest, all,
4
+ } from 'redux-saga/effects';
4
5
  import * as Api from '../../../services/api';
5
6
  import * as types from './constants';
6
7
 
@@ -1,4 +1,4 @@
1
- import { call, put, takeLatest, take, cancel } from 'redux-saga/effects';
1
+ import { call, put, takeLatest } from 'redux-saga/effects';
2
2
  // import { schema, normalize } from 'normalizr';
3
3
  import * as Api from '../../../services/api';
4
4
  import * as types from './constants';
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  // import { schema, normalize } from 'normalizr';
3
5
  import * as Api from '../../../services/api';
4
6
  import * as types from './constants';
@@ -1,4 +1,6 @@
1
- import { call, put, takeLatest, take, cancel, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  // import { schema, normalize } from 'normalizr';
3
5
  import * as Api from '../../../services/api';
4
6
  import * as types from './constants';
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  // import { schema, normalize } from 'normalizr';
3
5
  import * as Api from '../../../services/api';
4
6
  import * as types from './constants';
@@ -1,4 +1,6 @@
1
- import { call, put, takeLatest, take, cancel, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  // import { schema, normalize } from 'normalizr';
3
5
  import * as Api from '../../../services/api';
4
6
  import * as types from './constants';
@@ -1,4 +1,6 @@
1
- import { call, put, takeLatest, take, cancel, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  // import { schema, normalize } from 'normalizr';
3
5
  import * as Api from '../../services/api';
4
6
  import * as types from './constants';
@@ -1,4 +1,6 @@
1
- import { take, call, put, takeLatest, cancel, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import * as Api from '../../../services/api';
3
5
  import * as types from './constants';
4
6
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.42",
4
+ "version": "8.0.43-alpha.1",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/services/api.js CHANGED
@@ -266,29 +266,25 @@ export const createChannelWiseTemplate = ({ channel, template }) => {
266
266
  };
267
267
 
268
268
 
269
- export const getTemplateDetails = ({id, channel}) => {
269
+ export const getTemplateDetails = async ({id, channel}) => {
270
270
  const url = `${API_ENDPOINT}/templates/v1/${id}/${channel ? channel.toUpperCase() : SMS}`;
271
- const compressedTemplatesData = request(url, getAPICallObject('GET'));
272
- return compressedTemplatesData.then((data) => {
273
- const { response = '' } = data || {};
274
- const decompressData = decompressJsonObject(response);
275
- if (channel?.toUpperCase() === EMAIL) {
276
- return { ...data, response: addBaseToTemplate(decompressData) };
277
- }
278
- return { ...data, response: decompressData };
279
- });
271
+ const compressedTemplatesData = await request(url, getAPICallObject('GET'));
272
+ const {response = ''} = compressedTemplatesData || {};
273
+ const decompressData = decompressJsonObject(response);
274
+ if (channel?.toUpperCase() === EMAIL) {
275
+ return { ...compressedTemplatesData, response: addBaseToTemplate(decompressData) };
276
+ }
277
+ return { ...compressedTemplatesData, response: decompressData};
280
278
  };
281
279
 
282
- export const getAllTemplates = ({channel, queryParams = {}}) => {
280
+ export const getAllTemplates = async ({channel, queryParams = {}}) => {
283
281
  const url = getUrlWithQueryParams({
284
282
  url: `${API_ENDPOINT}/templates/v1/${channel}?`,
285
283
  queryParams,
286
284
  });
287
- const compressedTemplatesData = request(url, getAPICallObject('GET'));
288
- return compressedTemplatesData.then((data) => {
289
- const { response = '' } = data || {};
290
- return { ...data, response: decompressJsonObject(response)};
291
- });
285
+ const compressedTemplatesData = await request(url, getAPICallObject('GET'));
286
+ const {response = ''} = compressedTemplatesData || {};
287
+ return { ...compressedTemplatesData, response: decompressJsonObject(response)};
292
288
  };
293
289
 
294
290
  export const deleteTemplate = ({channel, id}) => {
@@ -535,13 +531,13 @@ export const getS3UrlFileSizes = (data) => {
535
531
  return request(url, getAPICallObject('POST', data));
536
532
  };
537
533
 
538
- export const getTemplateInfoById = ({id, username, oa_id, token, host}) => {
534
+ export const getTemplateInfoById = async ({
535
+ id, username, oa_id, token, host,
536
+ }) => {
539
537
  const url = `${API_ENDPOINT}/templates/v1/${id}/Zalo?username=${username}&oa_id=${oa_id}&token=${token}&host=${host}`;
540
- const compressedTemplatesData = request(url, getAPICallObject('GET'));
541
- return compressedTemplatesData.then((data) => {
542
- const { response = '' } = data || {};
543
- return { ...data, response: decompressJsonObject(response)};
544
- });
538
+ const compressedTemplatesData = await request(url, getAPICallObject('GET'));
539
+ const {response = ''} = compressedTemplatesData || {};
540
+ return { ...compressedTemplatesData, response: decompressJsonObject(response)};
545
541
  };
546
542
 
547
543
  export const getMetaTags = ({previewUrl}) => {
@@ -189,7 +189,9 @@ describe('getTemplateDetails -- Test with valid responses', () => {
189
189
  _id: '123',
190
190
  versions: {
191
191
  history: ['v1', 'v2'],
192
- base: 'v1',
192
+ base: {
193
+ "0":"v","1":"1","subject":undefined,
194
+ },
193
195
  },
194
196
  },
195
197
  status: 200,
@@ -19,7 +19,8 @@ div#app:first-child {
19
19
  overflow: hidden;
20
20
 
21
21
  .ant-input-affix-wrapper, .login-form-button {
22
- width: 100% !important
22
+ width: 100% !important;
23
+ margin-bottom: 5%;
23
24
  }
24
25
 
25
26
  .login-form-item {
@@ -17,11 +17,14 @@ export const addBaseToTemplate = (template) => {
17
17
  ...template,
18
18
  versions: {
19
19
  ...template.versions,
20
- base: history[0],
21
- },
20
+ base:{
21
+ ...history[0],
22
+ ...( !history?.[0]?.subject && { subject: get(template, 'versions.base.subject') })
23
+ }
24
+ }
22
25
  });
23
26
  }
24
- return template;
27
+ return template;
25
28
  };
26
29
 
27
30
  export const isEmbeddedEditOrPreview = (queryType, creativesMode) => queryType === EMBEDDED &&
@@ -37,7 +37,9 @@ describe('addBaseToTemplate', () => {
37
37
  const expected = {
38
38
  versions: {
39
39
  history: ['v1', 'v2', 'v3'],
40
- base: 'v1',
40
+ base: {
41
+ "0":"v","1":"1","subject":undefined,
42
+ },
41
43
  },
42
44
  };
43
45
  expect(addBaseToTemplate(template)).toEqual(expected);
@@ -17,11 +17,9 @@ import { request,getAPICallObject } from '../../services/api';
17
17
  import './style.scss';
18
18
  // import messages from './messages';
19
19
  const loadScript = require('load-script');
20
+ const hostName = window.location.origin.includes('localhost') ? 'https://nightly.intouch.capillarytech.com' : window.location.origin;
21
+ const defaultScriptUrl = `${hostName}/arya/ui/library/ckeditor/ckeditor.js`;
20
22
 
21
- const defaultScriptUrl = `${window.location.origin}/arya/ui/library/ckeditor/ckeditor.js`;
22
- //const defaultScriptUrl = 'https://nightly.intouch.capillarytech.com/arya/ui/library/ckeditor/ckeditor.js';
23
- /*Uncomment the above line to use CKEDITOR in local
24
- */
25
23
  const user = localStorage.getItem('user');
26
24
  let locale = 'en';
27
25
  if (user && JSON.parse(user).lang) {
@@ -3789,7 +3789,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3789
3789
 
3790
3790
 
3791
3791
  return (
3792
- <CapSpin spinning={this.liquidFlow && this.props.liquidExtractionInProgress} tip={this.props.intl.formatMessage(messages.liquidSpinText)} >
3792
+ <CapSpin spinning={Boolean(this.liquidFlow && this.props.liquidExtractionInProgress)} tip={this.props.intl.formatMessage(messages.liquidSpinText)} >
3793
3793
  <CapRow>
3794
3794
  {this.props.schema && this.renderForm()}
3795
3795
  <SlideBox
@@ -78,4 +78,4 @@ export function* v2GallerySagas() {
78
78
  watchDeleteAssetById(),
79
79
  watchGetUserList(),
80
80
  ]);
81
- }
81
+ }
@@ -27,11 +27,11 @@ function* watchCreateCustomRow() {
27
27
  // All sagas to be loaded
28
28
  export default [
29
29
  watchCreateCustomRow,
30
- watchForMediaGeneration
30
+ watchForMediaGeneration,
31
31
  ];
32
32
 
33
33
  export function* v2BeeEditionSagas() {
34
34
  yield all([
35
35
  watchCreateCustomRow(),
36
36
  ]);
37
- }
37
+ }
@@ -14,4 +14,4 @@ export function* v2CallTaskSagas() {
14
14
  yield all([
15
15
  defaultSaga(),
16
16
  ]);
17
- }
17
+ }
@@ -1,4 +1,7 @@
1
- import { fork, take, call, put, cancelled, cancel, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ take, call, put, cancelled, takeLatest, all,
3
+ fork,
4
+ } from 'redux-saga/effects';
2
5
  // import { normalize } from 'normalizr';
3
6
  import * as Api from '../../services/api';
4
7
  import * as LocalStorage from '../../services/localStorageApi';
@@ -9,7 +12,7 @@ import {
9
12
  getTopbarMenuDataValue,
10
13
  getLoyaltyTopbarMenuDataValue,
11
14
  LOYALTY,
12
- } from '../../v2Containers/App/constants';
15
+ } from "../App/constants";
13
16
  // import {makeSelectOrgId} from './selectors';
14
17
 
15
18
  export function* authorize(user) {
@@ -43,12 +46,11 @@ export function* switchOrg({orgID}) {
43
46
  export function* loginFlow() {
44
47
  let condition = true;
45
48
  while (condition) {
46
- const { user } = yield take(types.LOGIN_REQUEST);
47
- const task = yield fork(authorize, user);
49
+ const {user} = yield take(types.LOGIN_REQUEST);
50
+ yield fork(authorize, user);
48
51
  const action = yield take([types.LOGOUT_REQUEST_V2, types.LOGIN_FAILURE]);
49
52
  if (action.type === types.LOGOUT_REQUEST_V2) {
50
53
  condition = false;
51
- yield cancel(task);
52
54
  }
53
55
  // yield call(LocalStorage.clearItem, 'token');
54
56
  // yield call(LocalStorage.clearItem, 'orgID');
@@ -260,7 +262,7 @@ export function* capSagaForFetchSchemaForEntity() {
260
262
  yield all([
261
263
  watchFetchSchemaForEntity(),
262
264
  watchLiquidEntity(),
263
- ])
265
+ ]);
264
266
  }
265
267
 
266
268
  export function* v2CapSagas() {
@@ -1,4 +1,6 @@
1
- import { take, call, put, takeLatest, cancel, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import * as Api from '../../services/api';
3
5
  import * as type from './constants';
4
6
 
@@ -39,4 +41,4 @@ export function* v2CapFacebookPreviewSagas() {
39
41
  yield all([
40
42
  watchImageFacebookPreview(),
41
43
  ]);
42
- }
44
+ }
@@ -1403,6 +1403,6 @@ function mapDispatchToProps(dispatch) {
1403
1403
  const withConnect = connect(mapStatesToProps, mapDispatchToProps);
1404
1404
  const withReducer = injectReducer({ key: 'creativesContainer', reducer: creativesContainerReducer });
1405
1405
  const withSaga = injectSaga({ key: 'cap', saga: capSagaForFetchSchemaForEntity });
1406
- const withDefaultTempSaga = injectSaga({ key: 'templates', saga: v2TemplateSagaWatchGetDefaultBeeTemplates });
1406
+ const withDefaultTempSaga = injectSaga({ key: 'creativesContainer', saga: v2TemplateSagaWatchGetDefaultBeeTemplates });
1407
1407
 
1408
1408
  export default compose(withSaga, withDefaultTempSaga, withReducer, withConnect)(injectIntl(Creatives));
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, takeEvery, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, takeEvery, all,
3
+ } from 'redux-saga/effects';
2
4
  import * as Api from '../../services/api';
3
5
  import * as types from './constants';
4
6
  import { transformEmailTemplates, storeS3FileSizeDetails } from '../../utils/cdnTransformation';
@@ -157,4 +159,4 @@ export function* v2EmailDuplicateTemplateSaga() {
157
159
  yield all([
158
160
  watchDuplicateTemplate(),
159
161
  ]);
160
- }
162
+ }
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import * as Api from '../../services/api';
3
5
  import * as types from './constants';
4
6
 
@@ -28,4 +30,4 @@ export function* v2FTPSagas() {
28
30
  yield all([
29
31
  watchGetFTPServers(),
30
32
  ]);
31
- }
33
+ }
@@ -477,6 +477,6 @@ const mapDispatchToProps = (dispatch) => ({
477
477
 
478
478
  const withConnect = connect(mapStateToProps, mapDispatchToProps);
479
479
  const withReducer = injectReducer({ key: 'facebook', reducer: v2FacebookReducer });
480
- const withSaga = injectSaga({ key: 'gallery', saga: v2GallerySagas });
480
+ const withSaga = injectSaga({ key: 'facebook', saga: v2GallerySagas });
481
481
 
482
482
  export default compose(withSaga, withReducer, withConnect)(injectIntl(withStyles(Facebook, styles)));
@@ -1,4 +1,6 @@
1
- import { take, call, put, takeLatest, cancel, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import * as Api from '../../services/api';
3
5
  import {
4
6
  GET_MARKETING_OBJECTIVES,
@@ -121,7 +123,9 @@ export function* editTemplate({ template, callback }) {
121
123
  if (callback) {
122
124
  callback(result.response);
123
125
  }
124
- yield put({ type: EDIT_FACEBOOK_AD_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg });
126
+ yield put({
127
+ type: EDIT_FACEBOOK_AD_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg,
128
+ });
125
129
  } catch (error) {
126
130
  yield put({ type: EDIT_FACEBOOK_AD_TEMPLATE_FAILURE, error, errorMsg });
127
131
  if (callback) {
@@ -194,4 +198,4 @@ export function* v2FacebookSagas() {
194
198
  watchCreateTemplate(),
195
199
  watchGetOrgOUs(),
196
200
  ]);
197
- }
201
+ }
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import * as Api from '../../services/api';
3
5
  import {
4
6
  INAPP_TEMPLATE_CREATE_REQUEST,
@@ -1,7 +1,8 @@
1
1
  import {
2
- call, cancel, put, takeLatest,
2
+ call, put, takeLatest,
3
3
  } from 'redux-saga/effects';
4
4
  import { createMockTask } from 'redux-saga/utils';
5
+ import { expectSaga } from 'redux-saga-test-plan';
5
6
  import * as sagas from '../sagas';
6
7
  import * as Api from '../../../services/api';
7
8
  import * as types from '../constants';
@@ -9,7 +10,6 @@ import { INAPP } from '../../CreativesContainer/constants';
9
10
  import {
10
11
  v2InAppSagas,
11
12
  } from "../sagas";
12
- import { expectSaga } from 'redux-saga-test-plan';
13
13
 
14
14
  describe('test for uploadInAppAsset function', () => {
15
15
  it('should dispatch UPLOAD_INAPP_ASSET_SUCCESS action with asset data, status code, and template type', () => {
@@ -1,4 +1,6 @@
1
- import { takeLatest, take, all, cancel, call, put } from 'redux-saga/effects';
1
+ import {
2
+ takeLatest, all, call, put,
3
+ } from 'redux-saga/effects';
2
4
  import * as Api from '../../services/api';
3
5
  import * as types from './constants';
4
6
 
@@ -1,6 +1,8 @@
1
1
  // Line Sagas
2
2
 
3
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
3
+ import {
4
+ call, put, takeLatest, all,
5
+ } from 'redux-saga/effects';
4
6
  import * as Api from '../../../services/api';
5
7
  import * as types from './constants';
6
8
 
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  // import { schema, normalize } from 'normalizr';
3
5
  import * as Api from '../../../services/api';
4
6
  import * as types from './constants';
@@ -1,4 +1,6 @@
1
- import { call, put, takeLatest, take, cancel, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  // import { schema, normalize } from 'normalizr';
3
5
  import * as Api from '../../../services/api';
4
6
  import * as types from './constants';
@@ -49,7 +51,6 @@ export function* getIosCtas(licenseCode) {
49
51
 
50
52
  export function* getMobilepushTemplatesList(params) {
51
53
  try {
52
-
53
54
  const result = yield call(Api.getAllTemplates, {channel: params.channel, queryParams: params.queryParams});
54
55
  yield put({ type: types.GET_MOBILEPUSH_TEMPLATES_LIST_SUCCESS, data: result.response.templates, templateData: result.response.mapped});
55
56
  } catch (error) {
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import * as Api from '../../services/api';
3
5
  import {
4
6
  RCS,
@@ -7,6 +7,7 @@
7
7
  import * as types from './constants';
8
8
 
9
9
  export function createTemplate(template, onCreateTemplateComplete) {
10
+ console.log('***Action***', template);
10
11
  return {
11
12
  type: types.CREATE_TEMPLATE_REQUEST,
12
13
  template,
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  // import { schema, normalize } from 'normalizr';
3
5
  import * as Api from '../../../services/api';
4
6
  import * as types from './constants';
@@ -12,6 +12,7 @@ export function defaultAction() {
12
12
  }
13
13
 
14
14
  export function editTemplate(template, onUpdateTemplateComplete) {
15
+ console.log('***Action***', template);
15
16
  return {
16
17
  type: types.EDIT_TEMPLATE_REQUEST,
17
18
  template,
@@ -201,6 +201,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
201
201
  const content = _.get(this.state, `formData[0]['sms-editor']`);
202
202
  const unicodeEnabled = _.get(this.state, `formData[0]['unicode-validity']`);
203
203
  const smsDetails = updateCharCount(content || "", unicodeEnabled || false);
204
+ console.log('***onTemplateContentChange***', content, unicodeEnabled, smsDetails);
204
205
  if (this.smsCount.current) {
205
206
  this.smsCount.current.innerText = `${smsDetails.parts}${this.props.intl.formatMessage(messages.sms)} (${smsDetails.chars_used} ${this.props.intl.formatMessage(messages.characters)})`;
206
207
  }
@@ -924,7 +925,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
924
925
  const formData = _.cloneDeep(this.state.formData);
925
926
  editData.name = formData['template-name'];
926
927
  editData.versions.base = formData.base;
927
-
928
+ console.log('***saveFormData***', editData);
929
+ console.log('***saveFormData***', formData);
928
930
  this.props.actions.editTemplate(editData, this.onUpdateTemplateComplete);
929
931
  }
930
932
  isSmsLoading = () => {
@@ -1,5 +1,6 @@
1
- import { call, put, takeLatest, take, cancel, all } from 'redux-saga/effects';
2
- // import { schema, normalize } from 'normalizr';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
3
4
  import * as Api from '../../../services/api';
4
5
  import * as types from './constants';
5
6
 
@@ -13,8 +14,10 @@ export function* editTemplate(template) {
13
14
  errorMsg = result.message;
14
15
  }
15
16
 
16
- yield put({ type: types.EDIT_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg });
17
- yield template.onUpdateTemplateComplete(result.response,errorMsg);
17
+ yield put({
18
+ type: types.EDIT_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg
19
+ });
20
+ yield template.onUpdateTemplateComplete(result.response, errorMsg);
18
21
  } catch (error) {
19
22
  yield put({ type: types.EDIT_TEMPLATE_FAILURE, error, errorMsg });
20
23
  }
@@ -33,14 +36,10 @@ export function* getTemplateDetails(id) {
33
36
 
34
37
  function* watchEditTemplate() {
35
38
  yield takeLatest(types.EDIT_TEMPLATE_REQUEST, editTemplate);
36
-
37
-
38
39
  }
39
40
 
40
41
  function* watchGetTemplateDetails() {
41
42
  yield takeLatest(types.GET_TEMPLATE_DETAILS_REQUEST, getTemplateDetails);
42
-
43
-
44
43
  }
45
44
 
46
45
  // All sagas to be loaded
@@ -53,4 +52,4 @@ export function* v2SmsEditSagas() {
53
52
  watchEditTemplate(),
54
53
  watchGetTemplateDetails(),
55
54
  ]);
56
- }
55
+ }
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import * as Api from '../../../services/api';
3
5
  import * as types from './constants';
4
6
 
@@ -5,9 +5,12 @@
5
5
  */
6
6
 
7
7
  import * as types from './constants';
8
- import { LINE, WHATSAPP, RCS, ZALO } from '../CreativesContainer/constants';
8
+ import {
9
+ LINE, WHATSAPP, RCS, ZALO,
10
+ } from '../CreativesContainer/constants';
9
11
 
10
12
  export function getAllTemplates(channel, queryParams, intlCopyOf = '') {
13
+ console.log('*********getAllTemplates*********Action', channel, queryParams, intlCopyOf);
11
14
  return {
12
15
  type: types.GET_ALL_TEMPLATES_REQUEST, channel, queryParams, intlCopyOf,
13
16
  };
@@ -26,6 +29,7 @@ export function resetAccount() {
26
29
  }
27
30
 
28
31
  export function deleteTemplate(channel, id) {
32
+ console.log('*********deleteTemplate*********Action', channel, id);
29
33
  return {
30
34
  type: types.DELETE_TEMPLATE_REQUEST, channel, id,
31
35
  };
@@ -136,6 +136,8 @@ import { MAPP_SDK } from '../InApp/constants';
136
136
  import injectReducer from '../../utils/injectReducer';
137
137
  import v2TemplateReducer from './reducer';
138
138
  import { compose } from 'redux';
139
+ import { v2TemplateSaga } from './sagas';
140
+ import { injectSaga } from '@capillarytech/vulcan-react-sdk/utils';
139
141
 
140
142
  const { timeTracker } = GA;
141
143
  const {CapCustomCardList} = CapCustomCard;
@@ -358,6 +360,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
358
360
  if ((this.state.channel || '').toLowerCase() === "sms" && isTraiDltFeature) {
359
361
  queryParams.traiEnable = true;
360
362
  }
363
+ console.log('***queryParams***361', queryParams, channel);
361
364
  this.props.actions.getAllTemplates(channel, queryParams,`${formatMessage(globalMessages.copyOf)}`);
362
365
  }
363
366
 
@@ -423,6 +426,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
423
426
  if (['mobilepush', INAPP_LOWERCASE].includes((this.state.channel).toLowerCase()) && !isEmpty(nextProps.Templates.selectedWeChatAccount)) {
424
427
  params.accountId = nextProps.Templates.selectedWeChatAccount.id;
425
428
  }
429
+ console.log('***params***427', params);
426
430
  this.getAllTemplates({params}, true);
427
431
  }
428
432
  });
@@ -579,6 +583,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
579
583
  if (!nextProps.Templates.deleteTemplateInProgress && !isEqual(nextProps.Templates.deleteTemplateInProgress, this.props.Templates.deleteTemplateInProgress) &&
580
584
  nextProps.Templates.deleteResponse) {
581
585
  const message = `${this.state.channel} ${this.props.intl.formatMessage(messages['Template deleted successfully'])}`;
586
+ console.log('***message***582', message);
582
587
  CapNotification.success({key: 'deleteSucess', message});
583
588
  this.getAllTemplates({params, resetPage: true});
584
589
  }
@@ -1894,6 +1899,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1894
1899
  };
1895
1900
 
1896
1901
  deleteTemplate(template) {
1902
+ console.log('***deleteTemplate-->1898', template);
1897
1903
  this.props.actions.deleteTemplate(this.state.channel.toUpperCase(), template._id);
1898
1904
  this.setState({actionTemplate: {}});
1899
1905
  }
@@ -3234,9 +3240,11 @@ function mapDispatchToProps(dispatch) {
3234
3240
 
3235
3241
  const withReducer = injectReducer({ key: 'templates', reducer: v2TemplateReducer });
3236
3242
  const withConnect = connect(mapStateToProps, mapDispatchToProps);
3243
+ const withSaga = injectSaga({ key: 'templates', saga: v2TemplateSaga });
3237
3244
 
3238
3245
  export default compose(
3239
3246
  UserIsAuthenticated,
3247
+ withSaga,
3240
3248
  withReducer,
3241
3249
  withConnect,
3242
3250
  )(injectIntl(Templates));
@@ -29,26 +29,33 @@ function templatesReducer(state = initialState, action) {
29
29
  case types.DEFAULT_ACTION:
30
30
  return state;
31
31
  case types.GET_ALL_TEMPLATES_REQUEST:
32
+ console.log('***Reducer***Request', action);
32
33
  return state.set('getAllTemplatesInProgress', true).set('templateError', {});
33
34
  case types.GET_ALL_TEMPLATES_SUCCESS:
34
35
  if (action.isReset) {
36
+ console.log('***Reducer***Success36', action);
35
37
  return state.set('getAllTemplatesInProgress', false)
36
38
  .set('templates', action.data ? action.data.templates : [])
37
39
  .set('isSearch', action.data ? action.data.search : false)
38
40
  .set('weCRMtemplates', action.weCRMTemplate ? action.weCRMTemplate : []).set('templateError', {});
39
41
  }
42
+ console.log('***Reducer***Success42', action);
40
43
  return state.set('getAllTemplatesInProgress', false)
41
44
  .set('templates', action.data ? state.get('templates').concat(action.data.templates) : [])
42
45
  .set('isSearch', action.data ? action.data.search : false)
43
46
  .set('weCRMtemplates', action.weCRMTemplate ? state.get('weCRMtemplates').concat(action.weCRMTemplate) : []);
44
47
  case types.GET_ALL_TEMPLATES_FAILURE:
48
+ console.log('***Reducer***Failure', action);
45
49
  return state.set('getAllTemplatesInProgress', false).set('templateError', action.error);
46
50
  case types.DELETE_TEMPLATE_REQUEST:
51
+ console.log('***Reducer***Request', action);
47
52
  return state.set('deleteTemplateInProgress', true);
48
53
  case types.DELETE_TEMPLATE_SUCCESS:
54
+ console.log('***Reducer***Success', action);
49
55
  return state.set('deleteTemplateInProgress', false)
50
56
  .set('deleteResponse', action.data);
51
57
  case types.DELETE_TEMPLATE_FAILURE:
58
+ console.log('***Reducer***Failure', action);
52
59
  return state.set('deleteTemplateInProgress', false);
53
60
  case types.GET_USER_LIST_REQUEST:
54
61
  return state
@@ -1,4 +1,6 @@
1
- import { call, put, takeLatest, select, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import get from 'lodash/get';
3
5
  // import { schema, normalize } from 'normalizr';
4
6
  import * as Api from '../../services/api';
@@ -9,7 +11,7 @@ import { COPY_OF } from '../../containers/App/constants';
9
11
  export function* getAllTemplates(channel, queryParams) {
10
12
  try {
11
13
  const result = yield call(Api.getAllTemplates, channel, queryParams);
12
- const channelTemplates = (channel.channel === 'wechat') ? {templates: [...result.response.mapped, ...result.response.richmedia]} : result.response;
14
+ const channelTemplates = (channel.channel === 'wechat') ? { templates: [...result.response.mapped, ...result.response.richmedia] } : result.response;
13
15
  // const sidebar = result.response.sidebar;
14
16
  if (channel.channel === 'wechat' && channel.queryParams && channel.queryParams.sortBy && channel.queryParams.sortBy.toLocaleLowerCase() === ("Most Recent").toLocaleLowerCase()) {
15
17
  channelTemplates.templates.sort((a, b) => {
@@ -105,13 +107,9 @@ export function* watchGetOrgLevelCampaignSettings() {
105
107
  types.GET_ORG_LEVEL_CAMPAIGN_SETTINGS_REQUEST,
106
108
  getOrgLevelCampaignSettings,
107
109
  );
108
- const store = yield select();
109
- if (!store.getIn(['router', 'location', 'pathname']).includes('/settings/')) {
110
-
111
- }
112
110
  }
113
111
 
114
- export function* sendZippedFile({selectedFile, errorHandler, successHandler}) {
112
+ export function* sendZippedFile({ selectedFile, errorHandler, successHandler }) {
115
113
  let errorMessage = "";
116
114
  try {
117
115
  const result = yield call(Api.sendZippedFile, selectedFile);
@@ -119,7 +117,7 @@ export function* sendZippedFile({selectedFile, errorHandler, successHandler}) {
119
117
  errorMessage = result.message;
120
118
  yield errorHandler(errorMessage);
121
119
  }
122
-
120
+
123
121
  yield put({
124
122
  type: types.SEND_ZIPPED_FILE_SUCCESS,
125
123
  selectedTemplate: decodeURIComponent(result.response.metaEntity.htmlContent),
@@ -181,50 +179,34 @@ export function* getSenderDetails({
181
179
 
182
180
  export function* watchGetAllTemplates() {
183
181
  yield takeLatest(types.GET_ALL_TEMPLATES_REQUEST, getAllTemplates);
184
-
185
-
186
182
  }
187
183
 
188
184
  export function* watchDeleteTemplate() {
189
185
  yield takeLatest(types.DELETE_TEMPLATE_REQUEST, deleteTemplate);
190
-
191
-
192
186
  }
193
187
 
194
188
  export function* watchGetUserList() {
195
189
  yield takeLatest(types.GET_USER_LIST_REQUEST, fetchUserList);
196
-
197
-
198
190
  }
199
191
 
200
192
  export function* watchFetchWeCrmAccounts() {
201
193
  yield takeLatest(types.GET_WECRM_ACCOUNTS_REQUEST, fetchWeCrmAccounts);
202
-
203
-
204
194
  }
205
195
 
206
196
  export function* watchSendingFile() {
207
197
  yield takeLatest(types.SEND_ZIPPED_FILE_REQUEST, sendZippedFile);
208
-
209
-
210
198
  }
211
199
 
212
200
  export function* watchGetDefaultBeeTemplates() {
213
201
  yield takeLatest(types.GET_DEAFULT_BEE_TEMPLATES_REQUEST, getDefaultBeeTemplates);
214
-
215
-
216
202
  }
217
203
 
218
204
  export function* watchGetTemplateDetails() {
219
205
  yield takeLatest(types.GET_TEMPLATE_DETAILS_REQUEST, getTemplateDetails);
220
-
221
-
222
206
  }
223
207
 
224
208
  export function* watchGetSenderDetails() {
225
209
  yield takeLatest(types.GET_SENDER_DETAILS_REQUEST, getSenderDetails);
226
-
227
-
228
210
  }
229
211
 
230
212
  export function* watchGetCdnTransformationConfig() {
@@ -266,4 +248,4 @@ export function* v2TemplateSagaWatchGetDefaultBeeTemplates() {
266
248
  watchSendingFile(),
267
249
  watchGetDefaultBeeTemplates(),
268
250
  ]);
269
- }
251
+ }
@@ -34,11 +34,7 @@ import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS, JP_LOCA
34
34
  import AccessForbidden from '../../v2Components/AccessForbidden';
35
35
  import { getObjFromQueryParams } from '../../utils/v2common';
36
36
  import { makeSelectAuthenticated, selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
37
- import injectSaga from '../../utils/injectSaga';
38
- import injectReducer from '../../utils/injectReducer';
39
37
 
40
- import reducer from '../Templates/reducer';
41
- import { v2TemplateSaga } from '../Templates/sagas';
42
38
 
43
39
  const {CapCustomCardList} = CapCustomCard;
44
40
 
@@ -392,12 +388,12 @@ function mapDispatchToProps(dispatch) {
392
388
 
393
389
  const withConnect = connect(mapStateToProps, mapDispatchToProps);
394
390
 
395
- const withReducer = injectReducer({ key: 'templates', reducer });
396
- const withSaga = injectSaga({ key: 'templates', saga: v2TemplateSaga });
391
+ // const withReducer = injectReducer({ key: 'templates', reducer });
392
+ // const withSaga = injectSaga({ key: 'templates', saga: v2TemplateSaga });
397
393
 
398
394
  export default compose(
399
395
  UserIsAuthenticated,
400
- withSaga,
401
- withReducer,
396
+ // withSaga,
397
+ // withReducer,
402
398
  withConnect,
403
399
  )(injectIntl(withStyles(TemplatesV2, styles)));
@@ -1,5 +1,6 @@
1
-
2
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
3
4
  import * as Api from '../../services/api';
4
5
  import * as types from './constants';
5
6
 
@@ -1,4 +1,6 @@
1
- import { take, call, put, takeLatest, cancel, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import * as Api from '../../../services/api';
3
5
  import * as types from './constants';
4
6
 
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import orderBy from 'lodash/orderBy';
3
5
  import moment from 'moment';
4
6
  import * as Api from '../../../../services/api';
@@ -1,4 +1,6 @@
1
- import { take, cancel, call, put, takeLatest, all } from 'redux-saga/effects';
1
+ import {
2
+ call, put, takeLatest, all,
3
+ } from 'redux-saga/effects';
2
4
  import isEmpty from 'lodash/isEmpty';
3
5
  import get from 'lodash/get';
4
6
  import * as Api from '../../services/api';
@@ -42,4 +42,4 @@ export default [watchForGetTemplateInfoById];
42
42
 
43
43
  export function* v2ZaloSagas() {
44
44
  yield all([watchForGetTemplateInfoById()]);
45
- }
45
+ }