@capillarytech/creatives-library 6.13.8 → 6.13.9
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/package.json +1 -1
- package/v2Containers/CreativesContainer/index.js +12 -5
- package/v2Containers/Templates/actions.js +117 -110
- package/v2Containers/Templates/constants.js +2 -0
- package/v2Containers/Templates/index.js +27 -0
- package/v2Containers/Templates/messages.js +4 -0
- package/v2Containers/Templates/reducer.js +2 -0
- package/v2Containers/Viber/index.js +2 -2
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from '@capillarytech/cap-ui-library';
|
|
6
6
|
import { injectIntl, FormattedMessage } from 'react-intl';
|
|
7
7
|
import classnames from 'classnames';
|
|
8
|
-
import {isEmpty, get, forEach} from 'lodash';
|
|
8
|
+
import {isEmpty, get, forEach, cloneDeep} from 'lodash';
|
|
9
9
|
import { connect } from 'react-redux';
|
|
10
10
|
import { createStructuredSelector } from 'reselect';
|
|
11
11
|
import { bindActionCreators } from 'redux';
|
|
@@ -18,7 +18,6 @@ import SlideBoxHeader from './SlideBoxHeader';
|
|
|
18
18
|
import SlideBoxFooter from './SlideBoxFooter';
|
|
19
19
|
import * as constants from './constants';
|
|
20
20
|
import * as commonUtil from '../../utils/common';
|
|
21
|
-
|
|
22
21
|
import './index.scss';
|
|
23
22
|
import * as templateActions from '../Templates/actions';
|
|
24
23
|
import * as globalActions from '../Cap/actions';
|
|
@@ -249,7 +248,7 @@ class Creatives extends React.Component {
|
|
|
249
248
|
}
|
|
250
249
|
case constants.VIBER: {
|
|
251
250
|
const { messageBody, isDefault } = templateData;
|
|
252
|
-
const
|
|
251
|
+
const viber = JSON.parse(messageBody || '{}');
|
|
253
252
|
creativesTemplateData = {
|
|
254
253
|
type: constants.VIBER,
|
|
255
254
|
isDefault,
|
|
@@ -258,7 +257,7 @@ class Creatives extends React.Component {
|
|
|
258
257
|
versions: {
|
|
259
258
|
base: {
|
|
260
259
|
content: {
|
|
261
|
-
viber
|
|
260
|
+
...viber,
|
|
262
261
|
},
|
|
263
262
|
},
|
|
264
263
|
},
|
|
@@ -352,10 +351,18 @@ class Creatives extends React.Component {
|
|
|
352
351
|
break;
|
|
353
352
|
case constants.VIBER:
|
|
354
353
|
if (template.value) {
|
|
354
|
+
const { Templates = {} } = this.props || {};
|
|
355
|
+
const selectedViberAccount = Templates && Templates.selectedViberAccount;
|
|
356
|
+
const accountDetails = selectedViberAccount || '';
|
|
357
|
+
const accountId = selectedViberAccount ? selectedViberAccount.id : '';
|
|
355
358
|
const { versions } = template.value;
|
|
359
|
+
const content = cloneDeep(versions.base.content);
|
|
360
|
+
content.scenarioKey = get(accountDetails, 'configs.scenario_key');
|
|
356
361
|
templateData = {
|
|
357
362
|
channel,
|
|
358
|
-
|
|
363
|
+
accountId,
|
|
364
|
+
accountDetails,
|
|
365
|
+
messageBody: JSON.stringify(content),
|
|
359
366
|
};
|
|
360
367
|
}
|
|
361
368
|
break;
|
|
@@ -4,119 +4,126 @@
|
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
7
|
+
import * as types from './constants';
|
|
8
|
+
|
|
9
|
+
export function getAllTemplates(channel, queryParams) {
|
|
10
|
+
console.log('get all templates action trigereed', channel, queryParams);
|
|
11
|
+
return {
|
|
12
|
+
type: types.GET_ALL_TEMPLATES_REQUEST, channel, queryParams,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function resetTemplate() {
|
|
17
|
+
return {
|
|
18
|
+
type: types.RESET_TEMPLATE,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function resetAccount() {
|
|
23
|
+
return {
|
|
24
|
+
type: types.RESET_ACCOUNT,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function deleteTemplate(channel, id) {
|
|
29
|
+
console.log('delete template action trigereed', channel, id);
|
|
30
|
+
return {
|
|
31
|
+
type: types.DELETE_TEMPLATE_REQUEST, channel, id,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function getUserList() {
|
|
36
|
+
return {
|
|
37
|
+
type: types.GET_USER_LIST_REQUEST,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getWeCrmAccounts(source) {
|
|
42
|
+
return {
|
|
43
|
+
type: types.GET_WECRM_ACCOUNTS_REQUEST, source,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function setWeChatAccount(weChatAccount) {
|
|
48
|
+
console.log('setting wechat account', weChatAccount);
|
|
49
|
+
return {
|
|
50
|
+
type: types.SET_WECHAT_ACCOUNT,
|
|
51
|
+
weChatAccount,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function setLineAccount(lineAccount) {
|
|
56
56
|
return {
|
|
57
57
|
type: types.SET_LINE_ACCOUNT,
|
|
58
58
|
lineAccount,
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
62
|
+
export function setViberAccount(viberAccount) {
|
|
63
|
+
return {
|
|
64
|
+
type: types.SET_VIBER_ACCOUNT,
|
|
65
|
+
viberAccount,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function handleHtmlUpload(selectedTemplate) {
|
|
70
|
+
return {
|
|
71
|
+
type: types.SET_SELECTED_LAYOUT,
|
|
72
|
+
selectedTemplate,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function handleZipUpload(selectedFile, successHandler, errorHandler) {
|
|
77
|
+
return {
|
|
78
|
+
type: types.SEND_ZIPPED_FILE_REQUEST,
|
|
79
|
+
selectedFile,
|
|
80
|
+
successHandler,
|
|
81
|
+
errorHandler,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function getDefaultBeeTemplates() {
|
|
86
|
+
return {
|
|
87
|
+
type: types.GET_DEAFULT_BEE_TEMPLATES_REQUEST,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function setEdmTemplate(template) {
|
|
92
|
+
return {
|
|
93
|
+
type: types.SET_EDM_TEMPLATE,
|
|
94
|
+
template,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function setBEETemplate(template) {
|
|
98
|
+
return {
|
|
99
|
+
type: types.SET_BEE_TEMPLATE,
|
|
100
|
+
template,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export function getTemplateDetails(id, channel) {
|
|
104
|
+
console.log('getting template', id, channel);
|
|
105
|
+
return {
|
|
106
|
+
type: types.GET_TEMPLATE_DETAILS_REQUEST,
|
|
107
|
+
id,
|
|
108
|
+
channel,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function resetTemplateData() {
|
|
113
|
+
return {
|
|
114
|
+
type: types.RESET_TEMPLATE_DATA,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function resetUploadData() {
|
|
119
|
+
console.log('clearing upload data');
|
|
120
|
+
return {
|
|
121
|
+
type: types.RESET_UPLOAD_DATA,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function resetTemplateStoreData() {
|
|
126
|
+
return {
|
|
127
|
+
type: types.CLEAR_TEMPLATE_STORE_DATA,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
@@ -43,6 +43,8 @@ export const RESET_UPLOAD_DATA = "app/v2Containers/Templates/RESET_UPLOAD_DATA";
|
|
|
43
43
|
export const CLEAR_TEMPLATE_STORE_DATA = "app/v2Containers/Templates/CLEAR_TEMPLATE_STORE_DATA";
|
|
44
44
|
|
|
45
45
|
export const SET_LINE_ACCOUNT = "app/v2Containers/Templates/SET_LINE_ACCOUNT";
|
|
46
|
+
export const SET_VIBER_ACCOUNT = "app/v2Containers/Templates/SET_VIBER_ACCOUNT";
|
|
47
|
+
|
|
46
48
|
|
|
47
49
|
export const GET_DEAFULT_BEE_TEMPLATES_REQUEST = 'app/v2Containers/Templates/GET_DEAFULT_BEE_TEMPLATES_REQUEST';
|
|
48
50
|
export const GET_DEAFULT_BEE_TEMPLATES_SUCCESS = 'app/v2Containers/Templates/GET_DEAFULT_BEE_TEMPLATES_SUCCESS';
|
|
@@ -171,6 +171,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
171
171
|
break;
|
|
172
172
|
case VIBER:
|
|
173
173
|
channel = 'Viber';
|
|
174
|
+
if (!this.props.isFullMode) {
|
|
175
|
+
activeMode = ACCOUNT_SELECTION_MODE;
|
|
176
|
+
this.props.actions.getWeCrmAccounts(channel);
|
|
177
|
+
}
|
|
174
178
|
break;
|
|
175
179
|
case LINE:
|
|
176
180
|
channel = "Line";
|
|
@@ -258,6 +262,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
258
262
|
}
|
|
259
263
|
} else if (nextProps.route.name.toLowerCase() === VIBER_CHANNEL) {
|
|
260
264
|
channel = 'Viber';
|
|
265
|
+
if (!this.props.isFullMode) {
|
|
266
|
+
this.setState({defaultAccount: true});
|
|
267
|
+
nextProps.actions.getWeCrmAccounts(channel);
|
|
268
|
+
}
|
|
261
269
|
}
|
|
262
270
|
|
|
263
271
|
this.setState({ channel }, () => {
|
|
@@ -282,6 +290,20 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
282
290
|
if ((this.state.channel || '').toLowerCase() === "mobilepush" && nextProps.Templates.selectedWeChatAccount) {
|
|
283
291
|
params.accountId = nextProps.Templates.selectedWeChatAccount.id;
|
|
284
292
|
}
|
|
293
|
+
if (this.state.channel.toLowerCase() === VIBER_CHANNEL && isEmpty(nextProps.Templates.selectedViberAccount)) {
|
|
294
|
+
let selectedAccount = '';
|
|
295
|
+
if (isEmpty(nextProps.Templates.weCrmAccounts)) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
selectedAccount = nextProps.Templates.weCrmAccounts[0];
|
|
299
|
+
this.setState({selectedAccount: selectedAccount.name}, () => {
|
|
300
|
+
params.wecrmId = selectedAccount.configs.wecrm_app_id;
|
|
301
|
+
params.wecrmToken = selectedAccount.configs.wecrm_token;
|
|
302
|
+
params.originalId = selectedAccount.sourceAccountIdentifier;
|
|
303
|
+
this.props.actions.setViberAccount(nextProps.Templates.weCrmAccounts[0]);
|
|
304
|
+
this.getAllTemplates({params});
|
|
305
|
+
});
|
|
306
|
+
}
|
|
285
307
|
if ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && isEmpty(nextProps.Templates.selectedWeChatAccount) && (this.props.location.query.type === 'embedded') && !this.isEnabledInLibraryModule("showAccountSelection")) {
|
|
286
308
|
let selectedAccount = '';
|
|
287
309
|
if (isEmpty(nextProps.Templates.weCrmAccounts)) {
|
|
@@ -448,6 +470,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
448
470
|
} else if (this.state.channel.toLowerCase() === 'line') {
|
|
449
471
|
this.props.actions.setLineAccount(this.props.Templates.weCrmAccounts.find((item) => item.name === this.state.selectedAccount));
|
|
450
472
|
}
|
|
473
|
+
|
|
451
474
|
this.setState({activeMode: TEMPLATES_MODE});
|
|
452
475
|
console.log("getAllTemplates params: ", params);
|
|
453
476
|
this.getAllTemplates({params, resetPage: true});
|
|
@@ -1756,6 +1779,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1756
1779
|
noAccountHeader = messages.noAccountsPresentLine;
|
|
1757
1780
|
break;
|
|
1758
1781
|
}
|
|
1782
|
+
case VIBER: {
|
|
1783
|
+
noAccountHeader = messages.noAccountsPresentViber;
|
|
1784
|
+
break;
|
|
1785
|
+
}
|
|
1759
1786
|
default:
|
|
1760
1787
|
break;
|
|
1761
1788
|
}
|
|
@@ -366,4 +366,8 @@ export default defineMessages({
|
|
|
366
366
|
id: `${scope}.duplicatingTemplate`,
|
|
367
367
|
defaultMessage: 'Duplicating template...'
|
|
368
368
|
},
|
|
369
|
+
noAccountsPresentViber: {
|
|
370
|
+
id: `${scope}.noAccountsPresentViber`,
|
|
371
|
+
defaultMessage: "Viber accounts are not setup for your brand",
|
|
372
|
+
},
|
|
369
373
|
});
|
|
@@ -73,6 +73,8 @@ function templatesReducer(state = initialState, action) {
|
|
|
73
73
|
.set('selectedWeChatAccount', fromJS(action.weChatAccount));
|
|
74
74
|
case types.SET_LINE_ACCOUNT:
|
|
75
75
|
return state.set('selectedLineAccount', fromJS(action.lineAccount));
|
|
76
|
+
case types.SET_VIBER_ACCOUNT:
|
|
77
|
+
return state.set('selectedViberAccount', fromJS(action.viberAccount));
|
|
76
78
|
case types.RESET_ACCOUNT:
|
|
77
79
|
return state
|
|
78
80
|
.remove('selectedWeChatAccount')
|
|
@@ -64,7 +64,7 @@ const Viber = (props) => {
|
|
|
64
64
|
handleClose,
|
|
65
65
|
onCreateComplete,
|
|
66
66
|
params,
|
|
67
|
-
templateData,
|
|
67
|
+
templateData = {},
|
|
68
68
|
actions,
|
|
69
69
|
viber = {},
|
|
70
70
|
getFormSubscriptionData,
|
|
@@ -114,7 +114,7 @@ const Viber = (props) => {
|
|
|
114
114
|
}, [paramObj.id]);
|
|
115
115
|
|
|
116
116
|
useEffect(() => {
|
|
117
|
-
if (params && params.id) {
|
|
117
|
+
if (params && params.id || templateData.edit) {
|
|
118
118
|
const { viber: editViberContent = {} } = get(templateData, `versions.base.content`) || get(viber, `templateDetails.versions.base.content`) || {};
|
|
119
119
|
const editMessageTitle = (templateData || {}).name || get(viber, 'templateDetails.name');
|
|
120
120
|
updateTextMessageTitle(editMessageTitle);
|