@capillarytech/creatives-library 8.0.42 → 8.0.43-alpha.0
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.
- package/containers/Assets/Gallery/sagas.js +0 -1
- package/containers/Cap/sagas.js +5 -5
- package/containers/Cap/tests/saga.test.js +2 -4
- package/containers/Ebill/sagas.js +3 -1
- package/containers/Email/sagas.js +3 -1
- package/containers/Line/Create/sagas.js +3 -2
- package/containers/Line/Edit/sagas.js +1 -1
- package/containers/MobilePush/Create/sagas.js +3 -1
- package/containers/MobilePush/Edit/sagas.js +3 -1
- package/containers/Sms/Create/sagas.js +3 -1
- package/containers/Sms/Edit/sagas.js +3 -1
- package/containers/Templates/sagas.js +3 -1
- package/containers/WeChat/MapTemplates/sagas.js +3 -1
- package/package.json +1 -1
- package/services/api.js +18 -22
- package/services/tests/api.test.js +3 -1
- package/styles/containers/login/_loginPage.scss +2 -1
- package/utils/commonUtils.js +6 -3
- package/utils/tests/commonUtil.test.js +3 -1
- package/v2Components/Ckeditor/index.js +2 -4
- package/v2Components/FormBuilder/index.js +1 -1
- package/v2Containers/Cap/sagas.js +7 -5
- package/v2Containers/CapFacebookPreview/sagas.js +3 -1
- package/v2Containers/Email/sagas.js +3 -1
- package/v2Containers/FTP/sagas.js +3 -1
- package/v2Containers/Facebook/sagas.js +6 -2
- package/v2Containers/InApp/sagas.js +3 -1
- package/v2Containers/InApp/tests/sagas.test.js +2 -2
- package/v2Containers/LanguageProvider/sagas.js +3 -1
- package/v2Containers/Line/Container/sagas.js +3 -1
- package/v2Containers/MobilePush/Create/sagas.js +3 -1
- package/v2Containers/MobilePush/Edit/sagas.js +3 -2
- package/v2Containers/Rcs/sagas.js +3 -1
- package/v2Containers/Sms/Create/actions.js +1 -0
- package/v2Containers/Sms/Create/sagas.js +3 -1
- package/v2Containers/Sms/Edit/actions.js +1 -0
- package/v2Containers/Sms/Edit/index.js +3 -1
- package/v2Containers/Sms/Edit/sagas.js +8 -9
- package/v2Containers/SmsTrai/Create/sagas.js +3 -1
- package/v2Containers/Templates/actions.js +5 -1
- package/v2Containers/Templates/index.js +8 -0
- package/v2Containers/Templates/reducer.js +7 -0
- package/v2Containers/Templates/sagas.js +7 -25
- package/v2Containers/TemplatesV2/index.js +4 -4
- package/v2Containers/Viber/sagas.js +3 -2
- package/v2Containers/WeChat/MapTemplates/sagas.js +3 -1
- package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +3 -1
- package/v2Containers/Whatsapp/sagas.js +3 -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 });
|
package/containers/Cap/sagas.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
42
|
-
|
|
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,4 @@
|
|
|
1
|
-
import { call, put, takeLatest
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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';
|
package/package.json
CHANGED
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
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
-
|
|
289
|
-
|
|
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 = ({
|
|
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
|
-
|
|
542
|
-
|
|
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}) => {
|
package/utils/commonUtils.js
CHANGED
|
@@ -17,11 +17,14 @@ export const addBaseToTemplate = (template) => {
|
|
|
17
17
|
...template,
|
|
18
18
|
versions: {
|
|
19
19
|
...template.versions,
|
|
20
|
-
base:
|
|
21
|
-
|
|
20
|
+
base:{
|
|
21
|
+
...history[0],
|
|
22
|
+
...( !history?.[0]?.subject && { subject: get(template, 'versions.base.subject') })
|
|
23
|
+
}
|
|
24
|
+
}
|
|
22
25
|
});
|
|
23
26
|
}
|
|
24
|
-
|
|
27
|
+
return template;
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
export const isEmbeddedEditOrPreview = (queryType, creativesMode) => queryType === EMBEDDED &&
|
|
@@ -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
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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 {
|
|
47
|
-
|
|
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');
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
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';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
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({
|
|
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) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
call,
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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';
|
|
@@ -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 {
|
|
2
|
-
|
|
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({
|
|
17
|
-
|
|
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
|
+
}
|
|
@@ -5,9 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as types from './constants';
|
|
8
|
-
import {
|
|
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 {
|
|
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
|
+
}
|
|
@@ -392,12 +392,12 @@ function mapDispatchToProps(dispatch) {
|
|
|
392
392
|
|
|
393
393
|
const withConnect = connect(mapStateToProps, mapDispatchToProps);
|
|
394
394
|
|
|
395
|
-
const withReducer = injectReducer({ key: 'templates', reducer });
|
|
396
|
-
const withSaga = injectSaga({ key: 'templates', saga: v2TemplateSaga });
|
|
395
|
+
// const withReducer = injectReducer({ key: 'templates', reducer });
|
|
396
|
+
// const withSaga = injectSaga({ key: 'templates', saga: v2TemplateSaga });
|
|
397
397
|
|
|
398
398
|
export default compose(
|
|
399
399
|
UserIsAuthenticated,
|
|
400
|
-
withSaga,
|
|
401
|
-
withReducer,
|
|
400
|
+
// withSaga,
|
|
401
|
+
// withReducer,
|
|
402
402
|
withConnect,
|
|
403
403
|
)(injectIntl(withStyles(TemplatesV2, styles)));
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
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';
|