@capillarytech/creatives-library 7.17.92 → 7.17.94
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/services/api.js +0 -5
- package/v2Components/CapDeviceContent/index.js +2 -30
- package/v2Components/CapDeviceContent/messages.js +0 -13
- package/v2Components/CapImageUpload/index.js +2 -2
- package/v2Components/CapImageUpload/messages.js +2 -2
- package/v2Components/MobilePushPreviewV2/index.js +3 -6
- package/v2Components/TemplatePreview/_templatePreview.scss +10 -9
- package/v2Components/TemplatePreview/index.js +2 -2
- package/v2Containers/CreativesContainer/index.js +41 -36
- package/v2Containers/InApp/constants.js +32 -1
- package/v2Containers/InApp/index.js +102 -78
- package/v2Containers/InApp/index.scss +2 -1
- package/v2Containers/InApp/messages.js +13 -0
- package/v2Containers/InApp/tests/index.test.js +3 -13
- package/v2Containers/InApp/tests/mockData.js +1 -0
- package/v2Containers/Templates/_templates.scss +4 -0
- package/v2Containers/Templates/index.js +18 -44
- package/v2Containers/TemplatesV2/index.js +1 -6
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -237,11 +237,6 @@ export const createMobilePushTemplate = ({template}) => {
|
|
|
237
237
|
return request(url, getAPICallObject('POST', template));
|
|
238
238
|
};
|
|
239
239
|
|
|
240
|
-
export const createInAppTemplate = ({payload}) => {
|
|
241
|
-
const url = `${API_ENDPOINT}/templates/INAPP`;
|
|
242
|
-
return request(url, getAPICallObject('POST', payload));
|
|
243
|
-
};
|
|
244
|
-
|
|
245
240
|
export const duplicateTemplate = ({id, channel}) => {
|
|
246
241
|
const url = `${API_ENDPOINT}/templates/duplicate/${id}/${channel}`;
|
|
247
242
|
return request(url, getAPICallObject('GET'));
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
INAPP_IMG_SIZE,
|
|
24
24
|
INITIAL_CTA_DATA,
|
|
25
25
|
MEDIA_RADIO_OPTIONS,
|
|
26
|
+
BUTTON_RADIO_OPTIONS,
|
|
26
27
|
} from "../../v2Containers/InApp/constants";
|
|
27
28
|
import { INAPP } from "../../v2Containers/CreativesContainer/constants";
|
|
28
29
|
import CapImageUpload from "../CapImageUpload";
|
|
@@ -115,35 +116,6 @@ const CapDeviceContent = (props) => {
|
|
|
115
116
|
});
|
|
116
117
|
};
|
|
117
118
|
|
|
118
|
-
const buttonRadioOptions = [
|
|
119
|
-
{
|
|
120
|
-
value: INAPP_BUTTON_TYPES.NONE,
|
|
121
|
-
label: (
|
|
122
|
-
<CapHeading
|
|
123
|
-
type="h4"
|
|
124
|
-
className="inapp-button-none"
|
|
125
|
-
>
|
|
126
|
-
{formatMessage(messages.btnTypeNone)}
|
|
127
|
-
</CapHeading>
|
|
128
|
-
),
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
value: INAPP_BUTTON_TYPES.CTA,
|
|
132
|
-
label: (
|
|
133
|
-
<>
|
|
134
|
-
<div
|
|
135
|
-
className="inapp-button-cta"
|
|
136
|
-
>
|
|
137
|
-
<CapHeading type="h4">
|
|
138
|
-
{formatMessage(messages.btnTypeCTA)}
|
|
139
|
-
</CapHeading>
|
|
140
|
-
<CapLabel>{formatMessage(messages.ctaDesc)}</CapLabel>
|
|
141
|
-
</div>
|
|
142
|
-
</>
|
|
143
|
-
),
|
|
144
|
-
},
|
|
145
|
-
];
|
|
146
|
-
|
|
147
119
|
const onTitleChange = ({ target: { value } }) => {
|
|
148
120
|
setTitle(value);
|
|
149
121
|
};
|
|
@@ -308,7 +280,7 @@ const CapDeviceContent = (props) => {
|
|
|
308
280
|
description={<CapLabel type="label3">{formatMessage(messages.btnDesc)}</CapLabel>}
|
|
309
281
|
/>
|
|
310
282
|
<CapRadioGroup
|
|
311
|
-
options={
|
|
283
|
+
options={BUTTON_RADIO_OPTIONS}
|
|
312
284
|
value={buttonType}
|
|
313
285
|
onChange={onChangeButtonType}
|
|
314
286
|
className="inapp-btn-radio-group"
|
|
@@ -55,19 +55,6 @@ export default defineMessages({
|
|
|
55
55
|
id: `${prefix}.mediaImage`,
|
|
56
56
|
defaultMessage: "Image",
|
|
57
57
|
},
|
|
58
|
-
btnTypeNone: {
|
|
59
|
-
id: `${prefix}.btnTypeNone`,
|
|
60
|
-
defaultMessage: "None",
|
|
61
|
-
},
|
|
62
|
-
btnTypeCTA: {
|
|
63
|
-
id: `${prefix}.btnTypeCTA`,
|
|
64
|
-
defaultMessage: "Call to action",
|
|
65
|
-
},
|
|
66
|
-
ctaDesc: {
|
|
67
|
-
id: `${prefix}.ctaDesc`,
|
|
68
|
-
defaultMessage:
|
|
69
|
-
"Create a button that lets customers take an action",
|
|
70
|
-
},
|
|
71
58
|
emptyTemplateMessageErrorMessage: {
|
|
72
59
|
id: `${prefix}.emptyTemplateMessageErrorMessage`,
|
|
73
60
|
defaultMessage: "Template message cannot be empty",
|
|
@@ -245,7 +245,7 @@ function CapImageUpload(props) {
|
|
|
245
245
|
{channel === WHATSAPP && (
|
|
246
246
|
<>
|
|
247
247
|
<CapHeadingSpan type="label2">
|
|
248
|
-
<FormattedMessage {...messages.
|
|
248
|
+
<FormattedMessage {...messages.maxImageSize} />
|
|
249
249
|
</CapHeadingSpan>
|
|
250
250
|
<CapHeadingSpan type="label2">
|
|
251
251
|
<FormattedMessage {...messages.whatsappAspectRatio} />
|
|
@@ -270,7 +270,7 @@ function CapImageUpload(props) {
|
|
|
270
270
|
{
|
|
271
271
|
channel === INAPP && (
|
|
272
272
|
<CapHeadingSpan type="label2" className="image-size">
|
|
273
|
-
<FormattedMessage {...messages.
|
|
273
|
+
<FormattedMessage {...messages.maxImageSize} />
|
|
274
274
|
</CapHeadingSpan>
|
|
275
275
|
)
|
|
276
276
|
}
|
|
@@ -2,8 +2,8 @@ import { defineMessages } from 'react-intl';
|
|
|
2
2
|
const scope = `creatives.componentsV2.CapImageUpload`;
|
|
3
3
|
|
|
4
4
|
export default defineMessages({
|
|
5
|
-
|
|
6
|
-
id: `${scope}.
|
|
5
|
+
maxImageSize: {
|
|
6
|
+
id: `${scope}.maxImageSize`,
|
|
7
7
|
defaultMessage: 'Size upto: 5MB',
|
|
8
8
|
},
|
|
9
9
|
whatsappAspectRatio: {
|
|
@@ -46,7 +46,7 @@ class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react
|
|
|
46
46
|
const androidPreviewContent = {
|
|
47
47
|
templateTitle: androidContent?.title,
|
|
48
48
|
templateMsg: androidContent?.message,
|
|
49
|
-
mediaPreview: { inAppImageSrcAndroid: androidContent?.expandableDetails?.
|
|
49
|
+
mediaPreview: { inAppImageSrcAndroid: androidContent?.expandableDetails?.image },
|
|
50
50
|
ctaData: androidContent?.expandableDetails?.buttons?.map((cta) => {
|
|
51
51
|
const { index, type, text, url = "", label } = cta;
|
|
52
52
|
const ctaObject = {
|
|
@@ -63,7 +63,7 @@ class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react
|
|
|
63
63
|
const iosPreviewContent = {
|
|
64
64
|
templateTitle: iosContent?.title,
|
|
65
65
|
templateMsg: iosContent?.message,
|
|
66
|
-
mediaPreview: { inAppImageSrcIos: iosContent?.expandableDetails?.
|
|
66
|
+
mediaPreview: { inAppImageSrcIos: iosContent?.expandableDetails?.image },
|
|
67
67
|
ctaData: iosContent?.expandableDetails?.buttons?.map((cta) => {
|
|
68
68
|
const { index, type, text, url = "", label } = cta;
|
|
69
69
|
const ctaObject = {
|
|
@@ -131,17 +131,14 @@ class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react
|
|
|
131
131
|
const {templateData} = this.props;
|
|
132
132
|
let hasAndroid;
|
|
133
133
|
let hasIos;
|
|
134
|
-
let hasBothAndroidAndIos;
|
|
135
134
|
if (this.props.channel === MOBILE_PUSH) {
|
|
136
135
|
hasAndroid = get(templateData, 'versions.base.ANDROID') || get(templateData, 'androidContent.title');
|
|
137
136
|
hasIos = get(templateData, 'versions.base.IOS') || get(templateData, 'iosContent.title');
|
|
138
|
-
hasBothAndroidAndIos = hasAndroid && hasIos;
|
|
139
137
|
} else if (this.props.channel === INAPP.toUpperCase()) {
|
|
140
138
|
hasAndroid = get(templateData, 'versions.base.content.ANDROID') || get(templateData, 'androidContent.title');
|
|
141
139
|
hasIos = get(templateData, 'versions.base.content.IOS') || get(templateData, 'iosContent.title');
|
|
142
|
-
hasBothAndroidAndIos = hasAndroid && hasIos;
|
|
143
140
|
}
|
|
144
|
-
|
|
141
|
+
const hasBothAndroidAndIos = hasAndroid && hasIos;
|
|
145
142
|
return (
|
|
146
143
|
<div>
|
|
147
144
|
<div className="devices">
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
margin-right: $CAP_SPACE_08;
|
|
43
43
|
margin-left: $CAP_SPACE_08;
|
|
44
44
|
width: 178px;
|
|
45
|
-
max-height:
|
|
45
|
+
max-height: $CAP_SPACE_44;
|
|
46
46
|
text-overflow: ellipsis;
|
|
47
47
|
overflow: hidden;
|
|
48
48
|
text-align: left;
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
.inapp-message-container-HEADER-ANDROID {
|
|
59
59
|
position: absolute;
|
|
60
60
|
display: flex;
|
|
61
|
-
bottom: 19.4rem;
|
|
61
|
+
// bottom: 19.4rem;
|
|
62
62
|
width: 200px;
|
|
63
63
|
left: 28%;
|
|
64
64
|
top: 20px;
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
left: 26%;
|
|
82
82
|
bottom: -21px;
|
|
83
83
|
text-align: center;
|
|
84
|
+
top: 22%;
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
.inapp-image-HEADER-ANDROID {
|
|
@@ -98,7 +99,7 @@
|
|
|
98
99
|
height: 46px;
|
|
99
100
|
left: 35%;
|
|
100
101
|
bottom: 30px;
|
|
101
|
-
max-height:
|
|
102
|
+
max-height: $CAP_SPACE_40;
|
|
102
103
|
font-size: 8px;
|
|
103
104
|
text-overflow: ellipsis;
|
|
104
105
|
text-align: left;
|
|
@@ -171,7 +172,7 @@
|
|
|
171
172
|
width: 120px;
|
|
172
173
|
height: 46px;
|
|
173
174
|
bottom: 30px;
|
|
174
|
-
max-height:
|
|
175
|
+
max-height: $CAP_SPACE_44;
|
|
175
176
|
overflow: hidden;
|
|
176
177
|
font-size: 8px;
|
|
177
178
|
text-overflow: ellipsis;
|
|
@@ -220,7 +221,7 @@
|
|
|
220
221
|
|
|
221
222
|
.inapp-content-FULLSCREEN-ANDROID {
|
|
222
223
|
width: 186px;
|
|
223
|
-
height:
|
|
224
|
+
height: 144px;
|
|
224
225
|
text-align: left;
|
|
225
226
|
margin-top: $CAP_SPACE_04;
|
|
226
227
|
text-overflow: ellipsis;
|
|
@@ -262,7 +263,7 @@
|
|
|
262
263
|
margin-right: $CAP_SPACE_08;
|
|
263
264
|
margin-left: $CAP_SPACE_08;
|
|
264
265
|
width: 178px;
|
|
265
|
-
max-height:
|
|
266
|
+
max-height: $CAP_SPACE_44;
|
|
266
267
|
text-overflow: ellipsis;
|
|
267
268
|
overflow: hidden;
|
|
268
269
|
text-align: left;
|
|
@@ -317,7 +318,7 @@
|
|
|
317
318
|
height: 46px;
|
|
318
319
|
left: 35%;
|
|
319
320
|
top: -31px;
|
|
320
|
-
max-height:
|
|
321
|
+
max-height: $CAP_SPACE_40;
|
|
321
322
|
overflow: hidden;
|
|
322
323
|
font-size: 8px;
|
|
323
324
|
text-overflow: ellipsis;
|
|
@@ -389,7 +390,7 @@
|
|
|
389
390
|
width: 60%;
|
|
390
391
|
height: 46px;
|
|
391
392
|
bottom: 30px;
|
|
392
|
-
max-height:
|
|
393
|
+
max-height: $CAP_SPACE_44;
|
|
393
394
|
overflow: hidden;
|
|
394
395
|
font-size: 8px;
|
|
395
396
|
text-overflow: ellipsis;
|
|
@@ -439,7 +440,7 @@
|
|
|
439
440
|
|
|
440
441
|
.inapp-content-FULLSCREEN-iOS {
|
|
441
442
|
width: 186px;
|
|
442
|
-
height:
|
|
443
|
+
height: 144px;
|
|
443
444
|
text-align: left;
|
|
444
445
|
margin-top: $CAP_SPACE_04;
|
|
445
446
|
text-overflow: ellipsis;
|
|
@@ -504,7 +504,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
504
504
|
<CapImage
|
|
505
505
|
className="preview-image sms"
|
|
506
506
|
src={smsMobileAndroid}
|
|
507
|
-
alt=
|
|
507
|
+
alt={this.props.intl.formatMessage(messages.previewGenerated)}
|
|
508
508
|
/>
|
|
509
509
|
<div className="msg-container sms">
|
|
510
510
|
<div className={"message-pop sms"}>
|
|
@@ -563,7 +563,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
563
563
|
? wechatBodyNew
|
|
564
564
|
: smsMobileAndroid
|
|
565
565
|
}
|
|
566
|
-
alt=
|
|
566
|
+
alt={this.props.intl.formatMessage(messages.previewGenerated)}
|
|
567
567
|
/>
|
|
568
568
|
<div className="msg-container wechat">
|
|
569
569
|
<div
|
|
@@ -84,7 +84,7 @@ export class Creatives extends React.Component {
|
|
|
84
84
|
|
|
85
85
|
componentDidMount() {
|
|
86
86
|
GA.timeTracker.startTimer(CREATIVES_CONTAINER);
|
|
87
|
-
if
|
|
87
|
+
if(!this.props?.isFullMode){
|
|
88
88
|
this.props?.templateActions.getCdnTransformationConfig();
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -156,7 +156,7 @@ export class Creatives extends React.Component {
|
|
|
156
156
|
this.setState((prevState) => {
|
|
157
157
|
let templateStep = prevState.templateStep + 1;
|
|
158
158
|
const {emailCreateMode, currentChannel} = prevState;
|
|
159
|
-
if ((currentChannel.toUpperCase() === constants.EMAIL && emailCreateMode === "upload") ||
|
|
159
|
+
if ((currentChannel.toUpperCase() === constants.EMAIL && emailCreateMode === "upload") || [constants.MOBILE_PUSH, constants.WECHAT, constants.INAPP].includes(currentChannel.toUpperCase())) {
|
|
160
160
|
templateStep = prevState.templateStep + 2;
|
|
161
161
|
}
|
|
162
162
|
return {
|
|
@@ -195,7 +195,6 @@ export class Creatives extends React.Component {
|
|
|
195
195
|
this.setState({ isGetFormData: false });
|
|
196
196
|
};
|
|
197
197
|
getTemplateData = (templateData) => { //from consumers to creatives
|
|
198
|
-
console.log('in getTemplateData', templateData, this.props);
|
|
199
198
|
const { isFullMode, messageDetails = {}, smsRegister } = this.props;
|
|
200
199
|
const { additionalProperties = {} } = messageDetails;
|
|
201
200
|
if (!isFullMode && templateData) { // for component mode
|
|
@@ -271,23 +270,36 @@ export class Creatives extends React.Component {
|
|
|
271
270
|
};
|
|
272
271
|
break;
|
|
273
272
|
}
|
|
274
|
-
case constants.MOBILE_PUSH:
|
|
275
|
-
|
|
276
|
-
{
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
ANDROID: templateData.androidContent,
|
|
284
|
-
IOS: templateData.iosContent,
|
|
285
|
-
},
|
|
273
|
+
case constants.MOBILE_PUSH: {
|
|
274
|
+
const mode = get(templateData, 'androidContent.type') || get(templateData, 'iosContent.type') || '';
|
|
275
|
+
creativesTemplateData = {
|
|
276
|
+
type: channel,
|
|
277
|
+
name: templateData.messageSubject,
|
|
278
|
+
versions: {
|
|
279
|
+
base: {
|
|
280
|
+
ANDROID: templateData.androidContent,
|
|
281
|
+
IOS: templateData.iosContent,
|
|
286
282
|
},
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
283
|
+
},
|
|
284
|
+
definition: {accountId: templateData.accountId, mode: mode.toLowerCase()},
|
|
285
|
+
};
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
case constants.INAPP: {
|
|
289
|
+
const mode = get(templateData, 'androidContent.type') || get(templateData, 'iosContent.type') || '';
|
|
290
|
+
creativesTemplateData = {
|
|
291
|
+
type: channel,
|
|
292
|
+
name: templateData.messageSubject,
|
|
293
|
+
versions: {
|
|
294
|
+
content: {
|
|
295
|
+
ANDROID: templateData.androidContent,
|
|
296
|
+
IOS: templateData.iosContent,
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
definition: {accountId: templateData.accountId, mode: mode.toLowerCase()},
|
|
300
|
+
};
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
291
303
|
case constants.WECHAT: {
|
|
292
304
|
const messageBody = JSON.parse(templateData.messageBody);
|
|
293
305
|
creativesTemplateData = {
|
|
@@ -533,7 +545,6 @@ export class Creatives extends React.Component {
|
|
|
533
545
|
|
|
534
546
|
getCreativesData = async (channel, template, templateRecords) => { //from creatives to consumers
|
|
535
547
|
let templateData = { channel };
|
|
536
|
-
console.log('in getCreativesData', channel, template);
|
|
537
548
|
switch (channel) {
|
|
538
549
|
case constants.SMS:
|
|
539
550
|
if (template?.value?.base) {
|
|
@@ -622,7 +633,7 @@ export class Creatives extends React.Component {
|
|
|
622
633
|
}
|
|
623
634
|
break;
|
|
624
635
|
case constants.INAPP:
|
|
625
|
-
if (get(template, "value.versions.base")) {
|
|
636
|
+
if (get(template, "value.versions.base.content")) {
|
|
626
637
|
const inAppTemplate = template.value;
|
|
627
638
|
templateData.accountId = get(inAppTemplate, 'definition.accountId');
|
|
628
639
|
const type = (get(this.props, "messageDetails.type") || '').toLowerCase();
|
|
@@ -630,7 +641,7 @@ export class Creatives extends React.Component {
|
|
|
630
641
|
templateData.licenseCode = get(inAppTemplate, 'definition.licenseCode');
|
|
631
642
|
templateData.templateId = get(inAppTemplate, '_id');
|
|
632
643
|
}
|
|
633
|
-
const androidContent = get(inAppTemplate, 'versions.base.ANDROID');
|
|
644
|
+
const androidContent = get(inAppTemplate, 'versions.base.content.ANDROID');
|
|
634
645
|
if (!isEmpty(androidContent)) {
|
|
635
646
|
if (type !== LOYALTY) {
|
|
636
647
|
delete androidContent.cuid;
|
|
@@ -646,7 +657,7 @@ export class Creatives extends React.Component {
|
|
|
646
657
|
templateData.androidContent.type = get(inAppTemplate, 'definition.mode', '').toUpperCase();
|
|
647
658
|
templateData.androidContent.deviceType = 'ANDROID';
|
|
648
659
|
}
|
|
649
|
-
const iosContent = get(inAppTemplate, 'versions.base.IOS');
|
|
660
|
+
const iosContent = get(inAppTemplate, 'versions.base.content.IOS');
|
|
650
661
|
if (!isEmpty(iosContent)) {
|
|
651
662
|
if (type !== LOYALTY) {
|
|
652
663
|
delete iosContent.cuid;
|
|
@@ -761,10 +772,10 @@ export class Creatives extends React.Component {
|
|
|
761
772
|
header,
|
|
762
773
|
footer,
|
|
763
774
|
headerVarMapped,
|
|
764
|
-
headerTemplate
|
|
775
|
+
headerTemplate
|
|
765
776
|
};
|
|
766
777
|
const {
|
|
767
|
-
whatsappDocName = '', whatsappDocSize, whatsappDocPages, whatsappDocImg = ''
|
|
778
|
+
whatsappDocName = '', whatsappDocSize, whatsappDocPages, whatsappDocImg = ''
|
|
768
779
|
} = whatsappDocParams;
|
|
769
780
|
switch (mediaType) {
|
|
770
781
|
case (WHATSAPP_MEDIA_TYPES.IMAGE):
|
|
@@ -894,7 +905,6 @@ export class Creatives extends React.Component {
|
|
|
894
905
|
default:
|
|
895
906
|
break;
|
|
896
907
|
}
|
|
897
|
-
console.log('in getCreativesData templateData', templateData);
|
|
898
908
|
return templateData;
|
|
899
909
|
};
|
|
900
910
|
getSlideBoxContent({mode, templateData, isFullMode}) {
|
|
@@ -997,10 +1007,10 @@ export class Creatives extends React.Component {
|
|
|
997
1007
|
const templateData = this.state.templateData ? this.state.templateData : template; //select existing or create new content
|
|
998
1008
|
const channel = templateData.type;
|
|
999
1009
|
const creativesData = this.getCreativesData(channel, template, templateData );// convers data to consumer understandable format
|
|
1000
|
-
creativesData.then(
|
|
1010
|
+
creativesData.then(data=>{
|
|
1001
1011
|
this.logGTMEvent(channel, data);
|
|
1002
1012
|
this.props.getCreativesData(data);// send data to consumer
|
|
1003
|
-
})
|
|
1013
|
+
})
|
|
1004
1014
|
},
|
|
1005
1015
|
);
|
|
1006
1016
|
}
|
|
@@ -1056,9 +1066,6 @@ export class Creatives extends React.Component {
|
|
|
1056
1066
|
if (isMobilepush) {
|
|
1057
1067
|
showFooter = currentStep === "modeSelection" || (currentStep === 'createTemplateContent' && !isEmpty(mobilePushCreateMode));
|
|
1058
1068
|
}
|
|
1059
|
-
if (isInApp) {
|
|
1060
|
-
showFooter = currentStep === "modeSelection" || (currentStep === 'createTemplateContent' && !isEmpty(inAppCreateMode));
|
|
1061
|
-
}
|
|
1062
1069
|
} else if (channel === constants.EMAIL && isFullMode) {
|
|
1063
1070
|
const isEmailCreate = slidBoxContent === 'createTemplate' && channel === constants.EMAIL && currentStep !== 'createTemplateContent';
|
|
1064
1071
|
showFooter = isEmailCreate && emailCreateMode;
|
|
@@ -1100,7 +1107,6 @@ export class Creatives extends React.Component {
|
|
|
1100
1107
|
if ([constants.LINE, constants.VIBER, constants.FACEBOOK].includes(channel) || isLineViberChannel) {
|
|
1101
1108
|
showFooter = false;
|
|
1102
1109
|
}
|
|
1103
|
-
|
|
1104
1110
|
return showFooter;
|
|
1105
1111
|
}
|
|
1106
1112
|
shouldShowDoneFooter = () => {
|
|
@@ -1113,7 +1119,7 @@ export class Creatives extends React.Component {
|
|
|
1113
1119
|
if (channel === constants.EMAIL || channel === constants.SMS) {
|
|
1114
1120
|
const isEmailCreate = slidBoxContent === 'createTemplate' && channel === constants.EMAIL && currentStep !== 'createTemplateContent';
|
|
1115
1121
|
showDone = (slidBoxContent === 'editTemplate' || slidBoxContent === 'createTemplate') && !isEmailCreate;
|
|
1116
|
-
} else if ([constants.WECHAT, constants.MOBILE_PUSH
|
|
1122
|
+
} else if ([constants.WECHAT, constants.MOBILE_PUSH].includes(channel)) {
|
|
1117
1123
|
showDone = currentStep === "createTemplateContent" || slidBoxContent === "editTemplate";
|
|
1118
1124
|
}
|
|
1119
1125
|
|
|
@@ -1136,7 +1142,7 @@ export class Creatives extends React.Component {
|
|
|
1136
1142
|
onChange={(ev) => {
|
|
1137
1143
|
const value = ev.currentTarget.value;
|
|
1138
1144
|
const isEmptyTemplateName = value.trim() ? false : true;
|
|
1139
|
-
this.setState({isTemplateNameEmpty: isEmptyTemplateName});
|
|
1145
|
+
this.setState({isTemplateNameEmpty : isEmptyTemplateName});
|
|
1140
1146
|
const newFormData = {...formData, 'template-name': value};
|
|
1141
1147
|
onFormDataChange(newFormData);
|
|
1142
1148
|
}}
|
|
@@ -1147,7 +1153,7 @@ export class Creatives extends React.Component {
|
|
|
1147
1153
|
if ([constants.EMAIL, constants.MOBILE_PUSH, constants.INAPP].includes(channel) && (slidBoxContent === 'editTemplate' || slidBoxContent === 'createTemplate')) {
|
|
1148
1154
|
const name = get(formData, 'template-name');
|
|
1149
1155
|
if (channel === constants.EMAIL && !name && slidBoxContent === 'createTemplate') {
|
|
1150
|
-
this.setState({isTemplateNameEmpty:
|
|
1156
|
+
this.setState({isTemplateNameEmpty:true});
|
|
1151
1157
|
}
|
|
1152
1158
|
this.templateContainerDetails = {formData, onFormDataChange};
|
|
1153
1159
|
if (name && !isEditName) {
|
|
@@ -1216,7 +1222,6 @@ export class Creatives extends React.Component {
|
|
|
1216
1222
|
smsRegister,
|
|
1217
1223
|
enableNewChannels,
|
|
1218
1224
|
} = this.props;
|
|
1219
|
-
console.log('this.props', this.props);
|
|
1220
1225
|
const mapTemplateCreate = slidBoxContent === 'createTemplate' && weChatTemplateType === MAP_TEMPLATE && templateStep !== 'modeSelection';
|
|
1221
1226
|
/* TODO: Instead of passing down same props separately to each component down, write common function to these props and pass it accordingly */
|
|
1222
1227
|
return (
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FormattedMessage } from "react-intl";
|
|
3
|
+
import CapHeading from "@capillarytech/cap-ui-library/CapHeading";
|
|
4
|
+
import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
|
|
3
5
|
import { WEBSITE } from "../../v2Components/CapInAppCTA/constants";
|
|
4
6
|
import messages from "./messages";
|
|
5
7
|
|
|
@@ -26,7 +28,8 @@ export const INAPP_MEDIA_TYPES = {
|
|
|
26
28
|
TEXT: "TEXT",
|
|
27
29
|
IMAGE: "IMAGE",
|
|
28
30
|
};
|
|
29
|
-
|
|
31
|
+
export const BIG_TEXT = 'BIG_TEXT';
|
|
32
|
+
export const BIG_PICTURE = 'BIG_PICTURE';
|
|
30
33
|
export const NONE = "NONE";
|
|
31
34
|
export const CTA = "CTA";
|
|
32
35
|
export const MAPP_SDK = "MAPP_SDK";
|
|
@@ -93,3 +96,31 @@ export const MEDIA_RADIO_OPTIONS = [
|
|
|
93
96
|
label: <FormattedMessage {...messages.mediaImage} />,
|
|
94
97
|
},
|
|
95
98
|
];
|
|
99
|
+
export const BUTTON_RADIO_OPTIONS = [
|
|
100
|
+
{
|
|
101
|
+
value: INAPP_BUTTON_TYPES.NONE,
|
|
102
|
+
label: (
|
|
103
|
+
<CapHeading
|
|
104
|
+
type="h4"
|
|
105
|
+
className="inapp-button-none"
|
|
106
|
+
>
|
|
107
|
+
<FormattedMessage {...messages.btnTypeNone} />
|
|
108
|
+
</CapHeading>
|
|
109
|
+
),
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
value: INAPP_BUTTON_TYPES.CTA,
|
|
113
|
+
label: (
|
|
114
|
+
<>
|
|
115
|
+
<div
|
|
116
|
+
className="inapp-button-cta"
|
|
117
|
+
>
|
|
118
|
+
<CapHeading type="h4">
|
|
119
|
+
<FormattedMessage {...messages.btnTypeCTA} />
|
|
120
|
+
</CapHeading>
|
|
121
|
+
<CapLabel><FormattedMessage {...messages.ctaDesc} /></CapLabel>
|
|
122
|
+
</div>
|
|
123
|
+
</>
|
|
124
|
+
),
|
|
125
|
+
},
|
|
126
|
+
];
|
|
@@ -29,6 +29,8 @@ import { validateTags } from "../../utils/tagValidations";
|
|
|
29
29
|
|
|
30
30
|
import {
|
|
31
31
|
ANDROID,
|
|
32
|
+
BIG_PICTURE,
|
|
33
|
+
BIG_TEXT,
|
|
32
34
|
DEEP_LINK,
|
|
33
35
|
INAPP_BUTTON_TYPES,
|
|
34
36
|
INAPP_MEDIA_TYPES,
|
|
@@ -155,16 +157,28 @@ export const InApp = (props) => {
|
|
|
155
157
|
setTemplateDate(createdAt);
|
|
156
158
|
setTemplateLayoutType(editContent?.ANDROID?.bodyType);
|
|
157
159
|
const androidContent = editContent?.ANDROID;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
160
|
+
const {
|
|
161
|
+
title: androidTitle,
|
|
162
|
+
message: androidMessage,
|
|
163
|
+
cta: androidCta,
|
|
164
|
+
expandableDetails: androidExpandableDetails,
|
|
165
|
+
} = androidContent;
|
|
166
|
+
setTitleAndroid(androidTitle);
|
|
167
|
+
setTemplateMessageAndroid(androidMessage);
|
|
168
|
+
setTemplateMediaTypeAndroid(
|
|
169
|
+
androidExpandableDetails?.style === BIG_TEXT
|
|
170
|
+
? INAPP_MEDIA_TYPES.TEXT
|
|
171
|
+
: INAPP_MEDIA_TYPES.IMAGE
|
|
172
|
+
);
|
|
173
|
+
setInAppImageSrcAndroid(androidExpandableDetails?.image);
|
|
174
|
+
setDeepLinkValueAndroid(androidCta.actionLink);
|
|
175
|
+
setAddActionLinkAndroid(!isEmpty(androidCta) && true);
|
|
176
|
+
setButtonTypeAndroid(
|
|
177
|
+
androidExpandableDetails?.buttonType || INAPP_BUTTON_TYPES.NONE
|
|
178
|
+
);
|
|
179
|
+
if (androidExpandableDetails?.buttonType === INAPP_BUTTON_TYPES.CTA && androidExpandableDetails?.buttons.length > 0) {
|
|
166
180
|
setCtaDataAndroid(
|
|
167
|
-
|
|
181
|
+
androidExpandableDetails?.buttons?.map((cta) => {
|
|
168
182
|
const { index, type, text, url = "", label } = cta;
|
|
169
183
|
const obj = {
|
|
170
184
|
index,
|
|
@@ -179,16 +193,22 @@ export const InApp = (props) => {
|
|
|
179
193
|
);
|
|
180
194
|
}
|
|
181
195
|
const iosContent = editContent?.IOS;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
196
|
+
const {
|
|
197
|
+
title: iosTitle,
|
|
198
|
+
message: iosMessage,
|
|
199
|
+
cta: iosCta,
|
|
200
|
+
expandableDetails: iosExpandableDetails,
|
|
201
|
+
} = iosContent;
|
|
202
|
+
setTitleIos(iosTitle);
|
|
203
|
+
setTemplateMessageIos(iosMessage);
|
|
204
|
+
setTemplateMediaTypeIos(iosExpandableDetails?.style === BIG_TEXT ? INAPP_MEDIA_TYPES.TEXT : INAPP_MEDIA_TYPES.IMAGE);
|
|
205
|
+
setInAppImageSrcIos(iosExpandableDetails?.image);
|
|
206
|
+
setButtonTypeIos(iosExpandableDetails?.buttonType || INAPP_BUTTON_TYPES.NONE);
|
|
207
|
+
setAddActionLinkIos(!isEmpty(iosCta) && true);
|
|
208
|
+
setDeepLinkValueIos(iosCta?.actionLink);
|
|
209
|
+
if (iosExpandableDetails?.buttonType === INAPP_BUTTON_TYPES.CTA && iosExpandableDetails?.buttons.length > 0) {
|
|
190
210
|
setCtaDataIos(
|
|
191
|
-
|
|
211
|
+
iosExpandableDetails?.buttons?.map((cta) => {
|
|
192
212
|
const { index, type, text, url = "", label } = cta;
|
|
193
213
|
const obj = {
|
|
194
214
|
index,
|
|
@@ -405,50 +425,38 @@ export const InApp = (props) => {
|
|
|
405
425
|
];
|
|
406
426
|
|
|
407
427
|
const createModeContent = (
|
|
408
|
-
|
|
428
|
+
<CapRow>
|
|
429
|
+
{/* template name */}
|
|
409
430
|
<CapRow>
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
value={templateName}
|
|
421
|
-
size="default"
|
|
431
|
+
<CapHeading type="h4">
|
|
432
|
+
<FormattedMessage {...messages.creativeName} />
|
|
433
|
+
</CapHeading>
|
|
434
|
+
<CapInput
|
|
435
|
+
id="inapp-template-name-input"
|
|
436
|
+
className="inapp-template-name-input"
|
|
437
|
+
onChange={onTemplateNameChange}
|
|
438
|
+
placeholder={formatMessage(globalMessages.templateNamePlaceholder)}
|
|
439
|
+
value={templateName}
|
|
440
|
+
size="default"
|
|
422
441
|
/>
|
|
423
|
-
</CapRow>
|
|
424
|
-
{/* Creative layout type*/}
|
|
425
|
-
<CapRow className="inapp-creative-layout">
|
|
426
|
-
<CapHeading type="h4">
|
|
427
|
-
<FormattedMessage {...messages.creativeLayout} />
|
|
428
|
-
</CapHeading>
|
|
429
|
-
<CapHeading type="h6" className="inapp-creative-layout-desc">
|
|
430
|
-
<FormattedMessage {...messages.creativeLayoutDesc} />
|
|
431
|
-
</CapHeading>
|
|
432
|
-
</CapRow>
|
|
433
|
-
<CapRadioGroup
|
|
434
|
-
id="inapp-layout-radio"
|
|
435
|
-
options={LAYOUT_RADIO_OPTIONS}
|
|
436
|
-
value={templateLayoutType}
|
|
437
|
-
onChange={onTemplateLayoutTypeChange}
|
|
438
|
-
className="inapp-layout-radio"
|
|
439
|
-
/>
|
|
440
442
|
</CapRow>
|
|
441
|
-
{/*
|
|
442
|
-
<
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
443
|
+
{/* Creative layout type*/}
|
|
444
|
+
<CapRow className="inapp-creative-layout">
|
|
445
|
+
<CapHeading type="h4">
|
|
446
|
+
<FormattedMessage {...messages.creativeLayout} />
|
|
447
|
+
</CapHeading>
|
|
448
|
+
<CapHeading type="h6" className="inapp-creative-layout-desc">
|
|
449
|
+
<FormattedMessage {...messages.creativeLayoutDesc} />
|
|
450
|
+
</CapHeading>
|
|
451
|
+
</CapRow>
|
|
452
|
+
<CapRadioGroup
|
|
453
|
+
id="inapp-layout-radio"
|
|
454
|
+
options={LAYOUT_RADIO_OPTIONS}
|
|
455
|
+
value={templateLayoutType}
|
|
456
|
+
onChange={onTemplateLayoutTypeChange}
|
|
457
|
+
className="inapp-layout-radio"
|
|
458
|
+
/>
|
|
459
|
+
</CapRow>
|
|
452
460
|
);
|
|
453
461
|
//create methods end
|
|
454
462
|
|
|
@@ -548,13 +556,17 @@ export const InApp = (props) => {
|
|
|
548
556
|
const createPayload = () => {
|
|
549
557
|
let androidMediaParams = {};
|
|
550
558
|
let iosMediaParams = {};
|
|
551
|
-
const templateMediaType = panes === ANDROID ? templateMediaTypeAndroid : templateMediaTypeIos;
|
|
552
559
|
const buttonType = panes === ANDROID ? buttonTypeAndroid : buttonTypeIos;
|
|
560
|
+
const commonDevicePayload = {
|
|
561
|
+
luid: "{{luid}}",
|
|
562
|
+
cuid: "{{cuid}}",
|
|
563
|
+
communicationId: "{{communicationId}}",
|
|
564
|
+
};
|
|
553
565
|
switch (templateMediaTypeAndroid) {
|
|
554
566
|
case INAPP_MEDIA_TYPES.IMAGE:
|
|
555
567
|
androidMediaParams = {
|
|
556
|
-
|
|
557
|
-
style:
|
|
568
|
+
image: getCdnUrl({url: inAppImageSrcAndroid, channelName: INAPP }),
|
|
569
|
+
style: BIG_PICTURE,
|
|
558
570
|
};
|
|
559
571
|
break;
|
|
560
572
|
default:
|
|
@@ -563,8 +575,8 @@ export const InApp = (props) => {
|
|
|
563
575
|
switch (templateMediaTypeIos) {
|
|
564
576
|
case INAPP_MEDIA_TYPES.IMAGE:
|
|
565
577
|
iosMediaParams = {
|
|
566
|
-
|
|
567
|
-
style:
|
|
578
|
+
image: getCdnUrl({url: inAppImageSrcIos, channelName: INAPP }),
|
|
579
|
+
style: BIG_PICTURE,
|
|
568
580
|
};
|
|
569
581
|
break;
|
|
570
582
|
default:
|
|
@@ -581,16 +593,13 @@ export const InApp = (props) => {
|
|
|
581
593
|
base: {
|
|
582
594
|
content: {
|
|
583
595
|
ANDROID: {
|
|
584
|
-
|
|
585
|
-
cuid: "{{cuid}}",
|
|
586
|
-
communicationId: "{{communicationId}}",
|
|
596
|
+
...commonDevicePayload,
|
|
587
597
|
title: titleAndroid,
|
|
588
598
|
message: templateMessageAndroid,
|
|
589
599
|
bodyType: templateLayoutType,
|
|
590
600
|
expandableDetails: {
|
|
591
|
-
style:
|
|
601
|
+
style: BIG_TEXT,
|
|
592
602
|
message: templateMessageAndroid,
|
|
593
|
-
mediaType: templateMediaType,
|
|
594
603
|
...androidMediaParams,
|
|
595
604
|
...(isBtnTypeCta && {
|
|
596
605
|
buttonType,
|
|
@@ -601,16 +610,13 @@ export const InApp = (props) => {
|
|
|
601
610
|
cta: deepLinkValueAndroid ? {type: DEEP_LINK, actionLink: deepLinkValueAndroid} : {},
|
|
602
611
|
},
|
|
603
612
|
IOS: {
|
|
604
|
-
|
|
605
|
-
cuid: "{{cuid}}",
|
|
606
|
-
communicationId: "{{communicationId}}",
|
|
613
|
+
...commonDevicePayload,
|
|
607
614
|
title: titleIos,
|
|
608
615
|
message: templateMessageIos,
|
|
609
616
|
bodyType: templateLayoutType,
|
|
610
617
|
expandableDetails: {
|
|
611
|
-
style:
|
|
618
|
+
style: BIG_TEXT,
|
|
612
619
|
message: templateMessageIos,
|
|
613
|
-
mediaType: templateMediaType,
|
|
614
620
|
...iosMediaParams,
|
|
615
621
|
...(isBtnTypeCta && {
|
|
616
622
|
buttonType,
|
|
@@ -701,7 +707,17 @@ export const InApp = (props) => {
|
|
|
701
707
|
<CapSpin spinning={spin}>
|
|
702
708
|
<CapRow className="cap-inapp-creatives">
|
|
703
709
|
<CapColumn span={14}>
|
|
704
|
-
{createModeContent}
|
|
710
|
+
{isFullMode && createModeContent}
|
|
711
|
+
{/* device tab */}
|
|
712
|
+
<CapTab
|
|
713
|
+
panes={PANES}
|
|
714
|
+
onChange={(value) => {
|
|
715
|
+
setPanes(value);
|
|
716
|
+
}}
|
|
717
|
+
activeKey={panes}
|
|
718
|
+
defaultActiveKey={panes}
|
|
719
|
+
className="inapp-template-device-tab"
|
|
720
|
+
/>
|
|
705
721
|
<div className="inapp-scroll-div" />
|
|
706
722
|
</CapColumn>
|
|
707
723
|
<CapColumn span={10} className="inapp-preview-container">
|
|
@@ -709,17 +725,25 @@ export const InApp = (props) => {
|
|
|
709
725
|
</CapColumn>
|
|
710
726
|
</CapRow>
|
|
711
727
|
<div className="inapp-footer">
|
|
712
|
-
{
|
|
728
|
+
{
|
|
713
729
|
<>
|
|
714
730
|
<CapButton
|
|
715
731
|
onClick={onDoneCallback()}
|
|
716
732
|
disabled={isDisableDone()}
|
|
717
733
|
className="inapp-create-btn"
|
|
718
734
|
>
|
|
719
|
-
{isEditFlow ?
|
|
735
|
+
{isEditFlow ? (
|
|
736
|
+
isFullMode ? (
|
|
737
|
+
<FormattedMessage {...messages.update} />
|
|
738
|
+
) : (
|
|
739
|
+
<FormattedMessage {...globalMessages.done} />
|
|
740
|
+
)
|
|
741
|
+
) : (
|
|
742
|
+
<FormattedMessage {...messages.create} />
|
|
743
|
+
)}
|
|
720
744
|
</CapButton>
|
|
721
745
|
</>
|
|
722
|
-
|
|
746
|
+
}
|
|
723
747
|
</div>
|
|
724
748
|
</CapSpin>
|
|
725
749
|
);
|
|
@@ -83,4 +83,17 @@ export default defineMessages({
|
|
|
83
83
|
id: `${prefix}.templateNameRegexErrorMessage`,
|
|
84
84
|
defaultMessage: 'Template name can only contain lowercase alphanumeric characters and underscores',
|
|
85
85
|
},
|
|
86
|
+
btnTypeNone: {
|
|
87
|
+
id: `${prefix}.btnTypeNone`,
|
|
88
|
+
defaultMessage: "None",
|
|
89
|
+
},
|
|
90
|
+
btnTypeCTA: {
|
|
91
|
+
id: `${prefix}.btnTypeCTA`,
|
|
92
|
+
defaultMessage: "Call to action",
|
|
93
|
+
},
|
|
94
|
+
ctaDesc: {
|
|
95
|
+
id: `${prefix}.ctaDesc`,
|
|
96
|
+
defaultMessage:
|
|
97
|
+
"Create a button that lets customers take an action",
|
|
98
|
+
},
|
|
86
99
|
});
|
|
@@ -87,11 +87,6 @@ describe('Test activity inApp container', () => {
|
|
|
87
87
|
params: { id: 'test'},
|
|
88
88
|
getFormData: jest.fn(),
|
|
89
89
|
});
|
|
90
|
-
const inputBox = await screen.findAllByPlaceholderText(
|
|
91
|
-
'Enter template name',
|
|
92
|
-
);
|
|
93
|
-
fireEvent.change(inputBox[0], { target: { value: 'Hello, welcome' } });
|
|
94
|
-
inputBox[0].focus();
|
|
95
90
|
const iosTab = screen.getByRole('tab', {
|
|
96
91
|
name: /ios/i,
|
|
97
92
|
});
|
|
@@ -100,18 +95,13 @@ describe('Test activity inApp container', () => {
|
|
|
100
95
|
name: /android/i,
|
|
101
96
|
});
|
|
102
97
|
fireEvent.click(within(androidTab).getByText(/android/i));
|
|
103
|
-
const inputNameBox = await screen.findAllByPlaceholderText(
|
|
104
|
-
'Enter template name',
|
|
105
|
-
);
|
|
106
|
-
inputNameBox[0].focus();
|
|
107
|
-
fireEvent.change(inputNameBox[0], { target: { value: 'Hello, welcome' } });
|
|
108
98
|
const msgBox = screen.getAllByPlaceholderText(/Please input in-app notification message content/i);
|
|
109
99
|
msgBox[0].focus();
|
|
110
100
|
fireEvent.change(msgBox[0], { target: { value: 'val' }});
|
|
111
|
-
const
|
|
112
|
-
name: /
|
|
101
|
+
const doneBtn = screen.getByRole('button', {
|
|
102
|
+
name: /done/i,
|
|
113
103
|
});
|
|
114
|
-
expect(
|
|
104
|
+
expect(doneBtn).toBeEnabled();
|
|
115
105
|
});
|
|
116
106
|
it('test case for inApp template copy content flow', async () => {
|
|
117
107
|
renderComponent({
|
|
@@ -374,13 +374,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
374
374
|
nextProps.actions.getWeCrmAccounts();
|
|
375
375
|
} else if (nextProps.route.name.toLowerCase() === 'email') {
|
|
376
376
|
channel = 'Email';
|
|
377
|
-
} else if (nextProps.route.name.toLowerCase() === "mobilepush") {
|
|
377
|
+
} else if (nextProps.route.name.toLowerCase() === "mobilepush" || nextProps.route.name === INAPP) {
|
|
378
378
|
this.setState({defaultAccount: true});
|
|
379
|
-
channel =
|
|
380
|
-
nextProps.actions.getWeCrmAccounts(channel);
|
|
381
|
-
} else if (nextProps.route.name === INAPP ) {
|
|
382
|
-
this.setState({defaultAccount: true});
|
|
383
|
-
channel = INAPP_LOWERCASE;
|
|
379
|
+
channel = nextProps.route.name.toLowerCase();
|
|
384
380
|
nextProps.actions.getWeCrmAccounts(channel);
|
|
385
381
|
} else if (nextProps.route.name.toLowerCase() === 'ebill') {
|
|
386
382
|
channel = 'Ebill';
|
|
@@ -407,7 +403,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
407
403
|
params.wecrmToken = (nextProps.Templates.selectedWeChatAccount.configs || {}).wecrm_token;
|
|
408
404
|
params.originalId = nextProps.Templates.selectedWeChatAccount.sourceAccountIdentifier;
|
|
409
405
|
}
|
|
410
|
-
if (
|
|
406
|
+
if (['mobilepush', INAPP_LOWERCASE].includes((this.state.channel).toLowerCase()) && !isEmpty(nextProps.Templates.selectedWeChatAccount)) {
|
|
411
407
|
params.accountId = nextProps.Templates.selectedWeChatAccount.id;
|
|
412
408
|
}
|
|
413
409
|
this.getAllTemplates({params}, true);
|
|
@@ -419,7 +415,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
419
415
|
params.wecrmToken = (nextProps.Templates.selectedWeChatAccount.configs || {}).wecrm_token;
|
|
420
416
|
params.originalId = nextProps.Templates.selectedWeChatAccount.sourceAccountIdentifier;
|
|
421
417
|
}
|
|
422
|
-
if ((
|
|
418
|
+
if ((['mobilepush', INAPP_LOWERCASE].includes((this.state.channel || '').toLowerCase())) && nextProps.Templates.selectedWeChatAccount) {
|
|
423
419
|
params.accountId = nextProps.Templates.selectedWeChatAccount.id;
|
|
424
420
|
}
|
|
425
421
|
const selectedChannel = this.state.channel.toLowerCase();
|
|
@@ -485,24 +481,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
485
481
|
nextProps.actions.setWeChatAccount(selectedAccount);
|
|
486
482
|
this.getAllTemplates({params});
|
|
487
483
|
});
|
|
488
|
-
} else if (
|
|
489
|
-
|
|
490
|
-
if ((nextProps.location.query.account_id && account.id === Number(nextProps.location.query.account_id)) || (nextProps.location.query.source_account_id && account.sourceAccountIdentifier && account.sourceAccountIdentifier === nextProps.location.query.source_account_id)) {
|
|
491
|
-
selectedAccount = account;
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
|
-
this.props.actions.setWeChatAccount(selectedAccount);
|
|
495
|
-
params.accountId = Number(nextProps.location.query.account_id);
|
|
496
|
-
this.getAllTemplates({params});
|
|
497
|
-
}
|
|
498
|
-
else if (selectedChannel === INAPP_LOWERCASE && (nextProps.location.query.account_id || nextProps.location.query.source_account_id)) {
|
|
484
|
+
} else if ([INAPP_LOWERCASE, 'mobilepush'].includes(selectedChannel) && (nextProps.location.query.account_id || nextProps.location.query.source_account_id)) {
|
|
485
|
+
const { location: { query } } = nextProps || {};
|
|
499
486
|
forEach(nextProps.Templates.weCrmAccounts, (account) => {
|
|
500
|
-
if ((
|
|
487
|
+
if ((query.account_id && account.id === Number(query.account_id)) || (query.source_account_id && account.sourceAccountIdentifier && account.sourceAccountIdentifier === query.source_account_id)) {
|
|
501
488
|
selectedAccount = account;
|
|
502
489
|
}
|
|
503
490
|
});
|
|
504
491
|
this.props.actions.setWeChatAccount(selectedAccount);
|
|
505
|
-
params.accountId = Number(
|
|
492
|
+
params.accountId = Number(query.account_id);
|
|
506
493
|
this.getAllTemplates({params});
|
|
507
494
|
}
|
|
508
495
|
}
|
|
@@ -678,9 +665,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
678
665
|
params.wecrmToken = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})].configs.wecrm_token;
|
|
679
666
|
this.props.actions.setWeChatAccount(this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})]);
|
|
680
667
|
params.originalId = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})].sourceAccountIdentifier;
|
|
681
|
-
} else if (
|
|
682
|
-
this.props.
|
|
683
|
-
|
|
668
|
+
} else if (['mobilepush', INAPP_LOWERCASE].includes(selectedChannel)) {
|
|
669
|
+
const selectedAccount = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})];
|
|
670
|
+
this.props.actions.setWeChatAccount(selectedAccount);
|
|
671
|
+
const account = selectedAccount;
|
|
684
672
|
params.accountId = account.id;
|
|
685
673
|
const isAndroidSupported = get(account, "configs.android") === '1';
|
|
686
674
|
const isIosSupported = get(account, "configs.ios") === '1';
|
|
@@ -835,13 +823,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
835
823
|
queryParams.wecrmToken = this.props.Templates.selectedWeChatAccount.configs.wecrm_token;
|
|
836
824
|
queryParams.originalId = this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier;
|
|
837
825
|
}
|
|
838
|
-
if (this.state.channel.toLowerCase()
|
|
839
|
-
queryParams.accountId = this.props.Templates.selectedWeChatAccount.id;
|
|
840
|
-
if (this.state.mode) {
|
|
841
|
-
queryParams.mode = this.state.mode.toLowerCase();
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
if (this.state.channel.toLowerCase() === INAPP_LOWERCASE && !isEmpty(this.props.Templates.selectedWeChatAccount)) {
|
|
826
|
+
if (([MOBILE_PUSH_LOWERCASE, INAPP_LOWERCASE.includes](this.state.channel.toLowerCase())) && !isEmpty(this.props.Templates.selectedWeChatAccount)) {
|
|
845
827
|
queryParams.accountId = this.props.Templates.selectedWeChatAccount.id;
|
|
846
828
|
if (this.state.mode) {
|
|
847
829
|
queryParams.mode = this.state.mode.toLowerCase();
|
|
@@ -1095,8 +1077,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1095
1077
|
break;
|
|
1096
1078
|
}
|
|
1097
1079
|
case MOBILE_PUSH:
|
|
1098
|
-
templateData.content = template;
|
|
1099
|
-
break;
|
|
1100
1080
|
case INAPP:
|
|
1101
1081
|
templateData.content = template;
|
|
1102
1082
|
break;
|
|
@@ -1326,7 +1306,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1326
1306
|
: ['sms', "email"].includes(this.state.channel.toLowerCase()) && !isLoading && this.getSmsEmailIllustration()
|
|
1327
1307
|
}
|
|
1328
1308
|
|
|
1329
|
-
{(this.state.selectedAccount === '' && isEmpty(this.props.Templates.selectedWeChatAccount)) && (
|
|
1309
|
+
{(this.state.selectedAccount === '' && isEmpty(this.props.Templates.selectedWeChatAccount)) && (['wechat', 'mobilepush', INAPP_LOWERCASE].includes(this.state.channel.toLowerCase())) &&
|
|
1330
1310
|
<div style={{ height: '65vh', textAlign: 'center', lineHeight: '65vh' }}>
|
|
1331
1311
|
<CapHeading type="h6">{accounts ? this.props.intl.formatMessage(messages.noAccountMessage) : this.props.intl.formatMessage(messages.noAccountsPresent)}</CapHeading>
|
|
1332
1312
|
</div>
|
|
@@ -1369,7 +1349,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1369
1349
|
{showInAppIllustration &&
|
|
1370
1350
|
(
|
|
1371
1351
|
noLoaderAndSearchText &&
|
|
1372
|
-
<div
|
|
1352
|
+
<div className={`${this.isFullMode() ? 'inapp-illustration-parent' : ''}`}>
|
|
1373
1353
|
<CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />
|
|
1374
1354
|
</div>
|
|
1375
1355
|
)
|
|
@@ -1401,18 +1381,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1401
1381
|
pathname: `/sms/view`,
|
|
1402
1382
|
query: type === 'embedded' ? {type: 'embedded', module} : {},
|
|
1403
1383
|
};
|
|
1404
|
-
} else if (this.state.channel.toLowerCase()
|
|
1384
|
+
} else if (['mobilepush', INAPP_LOWERCASE].includes(this.state.channel.toLowerCase())) {
|
|
1405
1385
|
routeParams = {
|
|
1406
|
-
pathname:
|
|
1386
|
+
pathname: `/${this.state.channel.toLowerCase()}/edit/${e.template_id}`,
|
|
1407
1387
|
query: type === 'embedded' ? {type: 'embedded', module, account_id: e.account_id } : {},
|
|
1408
1388
|
};
|
|
1409
|
-
} else if (this.state.channel.toLowerCase() ===
|
|
1410
|
-
routeParams = {
|
|
1411
|
-
pathname: `/inapp/edit/${e.template_id}`,
|
|
1412
|
-
query: type === 'embedded' ? {type: 'embedded', module, account_id: e.account_id } : {},
|
|
1413
|
-
};
|
|
1414
|
-
}
|
|
1415
|
-
else if (this.state.channel.toLowerCase() === 'wechat') {
|
|
1389
|
+
} else if (this.state.channel.toLowerCase() === 'wechat') {
|
|
1416
1390
|
if (e.template_type && e.template_type === 'RICHMEDIA_WECHAT_TEMPLATE') {
|
|
1417
1391
|
this.props.router.push({
|
|
1418
1392
|
pathname: `/wechat/richmedia/edit/${e.template_id}`,
|
|
@@ -282,12 +282,7 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
282
282
|
argsPanes.map((pane) => {
|
|
283
283
|
let content = null;
|
|
284
284
|
if (pane.key === selectedChannel) {
|
|
285
|
-
|
|
286
|
-
if ( selectedChannel === "mpush") {
|
|
287
|
-
channel = "mobilepush";
|
|
288
|
-
} else {
|
|
289
|
-
channel = selectedChannel;
|
|
290
|
-
}
|
|
285
|
+
const channel = selectedChannel === "mpush" ? "mobilepush" : selectedChannel;
|
|
291
286
|
content = this.getTemplatesComponent(channel);
|
|
292
287
|
}
|
|
293
288
|
return {
|