@capillarytech/creatives-library 8.0.44 → 8.0.45
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/Cap/sagas.js +15 -10
- package/containers/Cap/tests/saga.test.js +10 -9
- 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/hoc/withCreatives.js +2 -3
- package/package.json +1 -1
- package/services/api.js +18 -22
- package/styles/containers/login/_loginPage.scss +2 -1
- package/v2Components/Ckeditor/index.js +2 -4
- package/v2Components/NavigationBar/index.js +5 -7
- package/v2Containers/Assets/Gallery/sagas.js +1 -1
- package/v2Containers/BeeEditor/sagas.js +2 -2
- package/v2Containers/CallTask/sagas.js +1 -1
- package/v2Containers/Cap/index.js +7 -0
- package/v2Containers/Cap/sagas.js +9 -5
- package/v2Containers/CapFacebookPreview/sagas.js +4 -2
- package/v2Containers/CreativesContainer/index.js +155 -111
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +5 -5
- package/v2Containers/Email/sagas.js +4 -2
- package/v2Containers/FTP/sagas.js +4 -2
- package/v2Containers/Facebook/sagas.js +7 -3
- 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/index.js +3 -10
- package/v2Containers/Line/Container/sagas.js +3 -1
- package/v2Containers/MobilePush/Create/index.js +1 -1
- package/v2Containers/MobilePush/Create/sagas.js +3 -1
- package/v2Containers/MobilePush/Edit/sagas.js +15 -27
- package/v2Containers/Rcs/sagas.js +3 -1
- package/v2Containers/Sms/Create/sagas.js +3 -1
- package/v2Containers/Sms/Edit/index.js +0 -1
- package/v2Containers/Sms/Edit/sagas.js +8 -9
- package/v2Containers/SmsTrai/Create/sagas.js +3 -1
- package/v2Containers/Templates/actions.js +3 -1
- package/v2Containers/Templates/index.js +5 -0
- package/v2Containers/Templates/reducer.js +6 -6
- package/v2Containers/Templates/sagas.js +9 -27
- package/v2Containers/TemplatesV2/index.js +0 -8
- package/v2Containers/Viber/sagas.js +3 -2
- package/v2Containers/WeChat/MapTemplates/sagas.js +14 -23
- package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +3 -1
- package/v2Containers/Whatsapp/sagas.js +3 -1
- package/v2Containers/Zalo/index.js +0 -4
- package/v2Containers/Zalo/saga.js +1 -1
|
@@ -9,7 +9,9 @@ import {
|
|
|
9
9
|
} from "@capillarytech/cap-ui-library";
|
|
10
10
|
import { injectIntl, FormattedMessage } from 'react-intl';
|
|
11
11
|
import classnames from 'classnames';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
isEmpty, get, forEach, cloneDeep,
|
|
14
|
+
} from 'lodash';
|
|
13
15
|
import { connect } from 'react-redux';
|
|
14
16
|
import { createStructuredSelector } from 'reselect';
|
|
15
17
|
import { bindActionCreators } from 'redux';
|
|
@@ -17,7 +19,9 @@ import styled from 'styled-components';
|
|
|
17
19
|
import { GA } from '@capillarytech/cap-ui-utils';
|
|
18
20
|
|
|
19
21
|
import * as actions from './actions';
|
|
20
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
selectEmailLayout, uploadSelector, templateUserList, makeSelectTemplates,
|
|
24
|
+
} from '../Templates/selectors';
|
|
21
25
|
import SlideBoxContent from './SlideBoxContent';
|
|
22
26
|
import SlideBoxHeader from './SlideBoxHeader';
|
|
23
27
|
import SlideBoxFooter from './SlideBoxFooter';
|
|
@@ -28,26 +32,30 @@ import './index.scss';
|
|
|
28
32
|
import * as templateActions from '../Templates/actions';
|
|
29
33
|
import * as globalActions from '../Cap/actions';
|
|
30
34
|
import * as zaloActions from '../Zalo/actions';
|
|
31
|
-
import {isLoading as isLoadingSelector} from './selectors';
|
|
35
|
+
import { isLoading as isLoadingSelector } from './selectors';
|
|
32
36
|
import messages from './messages';
|
|
33
37
|
import zaloMessages from '../Zalo/messages';
|
|
34
38
|
import { MAP_TEMPLATE } from '../WeChat/Wrapper/constants';
|
|
35
39
|
import { makeSelectFetchingCmsData } from '../Email/selectors';
|
|
36
|
-
import {
|
|
37
|
-
|
|
40
|
+
import {
|
|
41
|
+
IMAGE as LINE_IMAGE, IMAGE_MAP, IMAGE_CAROUSEL, VIDEO as LINE_VIDEO, TEMPLATE, STICKER,
|
|
42
|
+
} from '../Line/Container/constants';
|
|
43
|
+
import { IMAGE, VIDEO } from '../Facebook/Advertisement/constant';
|
|
38
44
|
import { CREATIVE } from '../Facebook/constants';
|
|
39
45
|
import { LOYALTY } from '../App/constants';
|
|
40
46
|
import { WHATSAPP_STATUSES, WHATSAPP_MEDIA_TYPES } from '../Whatsapp/constants';
|
|
41
47
|
|
|
42
48
|
import { updateImagesInHtml } from '../../utils/cdnTransformation';
|
|
43
49
|
import { IOS } from '../InApp/constants';
|
|
44
|
-
import injectReducer from '../../utils/injectReducer'
|
|
50
|
+
import injectReducer from '../../utils/injectReducer';
|
|
45
51
|
import injectSaga from '../../utils/injectSaga';
|
|
46
52
|
import creativesContainerReducer from './reducer';
|
|
47
53
|
import { compose } from 'redux';
|
|
48
54
|
import { capSagaForFetchSchemaForEntity } from '../Cap/sagas';
|
|
49
55
|
import { v2TemplateSagaWatchGetDefaultBeeTemplates } from '../Templates/sagas';
|
|
50
|
-
import {
|
|
56
|
+
import {
|
|
57
|
+
CAP_SPACE_32, CAP_SPACE_56, CAP_SPACE_64,
|
|
58
|
+
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
51
59
|
|
|
52
60
|
const classPrefix = 'add-creatives-section';
|
|
53
61
|
const CREATIVES_CONTAINER = 'creativesContainer';
|
|
@@ -70,7 +78,7 @@ export class Creatives extends React.Component {
|
|
|
70
78
|
isLoadingContent: true,
|
|
71
79
|
templateStep: 1, //modeSelection: for template name and (for email selecting upload or editor), and createTemplate to create template create based on modeSelection
|
|
72
80
|
showSlideBox: true,
|
|
73
|
-
slidBoxContent: this.getSlideBoxContent({mode: props.creativesMode, templateData: props.templateData, isFullMode: props.isFullMode}),
|
|
81
|
+
slidBoxContent: this.getSlideBoxContent({ mode: props.creativesMode, templateData: props.templateData, isFullMode: props.isFullMode }),
|
|
74
82
|
templateData: this.getTemplateData(props.templateData),
|
|
75
83
|
templateNameExists: props.creativesMode === 'edit', // if edit mode templateNameExists will be true, and false in create flow.
|
|
76
84
|
currentChannel: this.props.channel || 'sms',
|
|
@@ -85,6 +93,7 @@ export class Creatives extends React.Component {
|
|
|
85
93
|
3: 'createTemplateContent',
|
|
86
94
|
};
|
|
87
95
|
}
|
|
96
|
+
|
|
88
97
|
componentWillUnmount() {
|
|
89
98
|
if (get(this.props, 'location.query.type', '') === "embedded") {
|
|
90
99
|
this.props.templateActions.resetTemplateStoreData();
|
|
@@ -100,15 +109,15 @@ export class Creatives extends React.Component {
|
|
|
100
109
|
}
|
|
101
110
|
|
|
102
111
|
onEnterTemplateName = () => {
|
|
103
|
-
this.setState({templateNameExists: true});
|
|
112
|
+
this.setState({ templateNameExists: true });
|
|
104
113
|
};
|
|
105
114
|
|
|
106
115
|
onRemoveTemplateName = () => {
|
|
107
|
-
this.setState({templateNameExists: false});
|
|
116
|
+
this.setState({ templateNameExists: false });
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
onSelectTemplate = (template, fbAdManager) => {
|
|
111
|
-
const data = {slidBoxContent: constants.EDIT_TEMPLATE, templateData: template};
|
|
120
|
+
const data = { slidBoxContent: constants.EDIT_TEMPLATE, templateData: template };
|
|
112
121
|
if (fbAdManager) {
|
|
113
122
|
data.fbAdManager = fbAdManager;
|
|
114
123
|
}
|
|
@@ -117,7 +126,7 @@ export class Creatives extends React.Component {
|
|
|
117
126
|
|
|
118
127
|
actionCallback = () => {
|
|
119
128
|
CapNotification.error({
|
|
120
|
-
message: <FormattedMessage {...zaloMessages.zaloFailureNotificationPreview}/>,
|
|
129
|
+
message: <FormattedMessage {...zaloMessages.zaloFailureNotificationPreview} />,
|
|
121
130
|
});
|
|
122
131
|
};
|
|
123
132
|
|
|
@@ -126,7 +135,7 @@ export class Creatives extends React.Component {
|
|
|
126
135
|
const templateData = template;
|
|
127
136
|
const usersList = commonUtil.getMergedUserList(this.props.templateUserList);
|
|
128
137
|
const userId = parseInt(template.updatedBy, 10);
|
|
129
|
-
templateData.updatedByName = commonUtil.getUserNameById(userId, usersList
|
|
138
|
+
templateData.updatedByName = commonUtil.getUserNameById(userId, usersList);
|
|
130
139
|
this.setState({ slidBoxContent: constants.PREVIEW, templateData });
|
|
131
140
|
} else {
|
|
132
141
|
const {
|
|
@@ -134,7 +143,7 @@ export class Creatives extends React.Component {
|
|
|
134
143
|
sourceAccountIdentifier = "",
|
|
135
144
|
configs: { token = "" } = {},
|
|
136
145
|
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
137
|
-
const { hostName = ''} = get(this.props, "Templates.senderDetails", {});
|
|
146
|
+
const { hostName = '' } = get(this.props, "Templates.senderDetails", {});
|
|
138
147
|
this.props.zaloActions.getTemplateInfoById({
|
|
139
148
|
username: name,
|
|
140
149
|
oa_id: sourceAccountIdentifier,
|
|
@@ -146,9 +155,11 @@ export class Creatives extends React.Component {
|
|
|
146
155
|
});
|
|
147
156
|
}
|
|
148
157
|
};
|
|
158
|
+
|
|
149
159
|
onEditTemplate = () => {
|
|
150
160
|
this.setState({ slidBoxContent: 'editTemplate', showSlideBox: true, templateNameExists: true });
|
|
151
161
|
};
|
|
162
|
+
|
|
152
163
|
onCreateNew = (fbAdManager) => {
|
|
153
164
|
const data = { slidBoxContent: 'createTemplate', showSlideBox: true };
|
|
154
165
|
if (fbAdManager) {
|
|
@@ -161,13 +172,15 @@ export class Creatives extends React.Component {
|
|
|
161
172
|
this.setState({ slidBoxContent: 'templates', showSlideBox: true, isGetFormData: false });
|
|
162
173
|
this.resetStep();
|
|
163
174
|
};
|
|
175
|
+
|
|
164
176
|
onChannelChange = (channel) => {
|
|
165
|
-
this.setState({currentChannel: channel, templateData: null});
|
|
177
|
+
this.setState({ currentChannel: channel, templateData: null });
|
|
166
178
|
}
|
|
179
|
+
|
|
167
180
|
onCreateNextStep = () => {
|
|
168
181
|
this.setState((prevState) => {
|
|
169
182
|
let templateStep = prevState.templateStep + 1;
|
|
170
|
-
const {emailCreateMode, currentChannel} = prevState;
|
|
183
|
+
const { emailCreateMode, currentChannel } = prevState;
|
|
171
184
|
if ((currentChannel.toUpperCase() === constants.EMAIL && emailCreateMode === "upload") || [constants.MOBILE_PUSH, constants.WECHAT, constants.INAPP].includes(currentChannel.toUpperCase())) {
|
|
172
185
|
templateStep = prevState.templateStep + 2;
|
|
173
186
|
}
|
|
@@ -178,22 +191,23 @@ export class Creatives extends React.Component {
|
|
|
178
191
|
}
|
|
179
192
|
|
|
180
193
|
onEmailModeChange = (mode) => {
|
|
181
|
-
this.setState({ emailCreateMode: mode});
|
|
194
|
+
this.setState({ emailCreateMode: mode });
|
|
182
195
|
}
|
|
183
196
|
|
|
184
197
|
onInAppModeChange = (mode) => {
|
|
185
|
-
this.setState({ inAppCreateMode: mode});
|
|
198
|
+
this.setState({ inAppCreateMode: mode });
|
|
186
199
|
}
|
|
187
200
|
|
|
188
201
|
onMobilepushModeChange = (mode) => {
|
|
189
|
-
this.setState({ mobilePushCreateMode: mode});
|
|
202
|
+
this.setState({ mobilePushCreateMode: mode });
|
|
190
203
|
}
|
|
204
|
+
|
|
191
205
|
onWechatTemplateChange = (templateType) => {
|
|
192
|
-
this.setState(
|
|
206
|
+
this.setState({ weChatTemplateType: templateType });
|
|
193
207
|
}
|
|
194
208
|
|
|
195
209
|
onWeChatMaptemplateStepChange = (step) => {
|
|
196
|
-
this.setState({weChatMaptemplateStep: step});
|
|
210
|
+
this.setState({ weChatMaptemplateStep: step });
|
|
197
211
|
}
|
|
198
212
|
|
|
199
213
|
onCallTaskSubmit = (data) => {
|
|
@@ -206,12 +220,13 @@ export class Creatives extends React.Component {
|
|
|
206
220
|
onValidationFail = () => {
|
|
207
221
|
this.setState({ isGetFormData: false });
|
|
208
222
|
};
|
|
223
|
+
|
|
209
224
|
getTemplateData = (templateData) => { //from consumers to creatives
|
|
210
225
|
const { isFullMode, messageDetails = {}, smsRegister } = this.props;
|
|
211
226
|
const { additionalProperties = {} } = messageDetails;
|
|
212
227
|
if (!isFullMode && templateData) { // for component mode
|
|
213
|
-
const {channel} = templateData;
|
|
214
|
-
let creativesTemplateData = {type: channel };
|
|
228
|
+
const { channel } = templateData;
|
|
229
|
+
let creativesTemplateData = { type: channel };
|
|
215
230
|
switch (channel) {
|
|
216
231
|
case constants.NO_COMMUNICATION: {
|
|
217
232
|
creativesTemplateData = {
|
|
@@ -293,7 +308,7 @@ export class Creatives extends React.Component {
|
|
|
293
308
|
IOS: templateData.iosContent,
|
|
294
309
|
},
|
|
295
310
|
},
|
|
296
|
-
definition: {accountId: templateData.accountId, mode: mode.toLowerCase()},
|
|
311
|
+
definition: { accountId: templateData.accountId, mode: mode.toLowerCase() },
|
|
297
312
|
};
|
|
298
313
|
break;
|
|
299
314
|
}
|
|
@@ -310,7 +325,7 @@ export class Creatives extends React.Component {
|
|
|
310
325
|
},
|
|
311
326
|
},
|
|
312
327
|
},
|
|
313
|
-
definition: {accountId: templateData?.accountId, mode: mode?.toLowerCase()},
|
|
328
|
+
definition: { accountId: templateData?.accountId, mode: mode?.toLowerCase() },
|
|
314
329
|
};
|
|
315
330
|
break;
|
|
316
331
|
}
|
|
@@ -336,7 +351,9 @@ export class Creatives extends React.Component {
|
|
|
336
351
|
const facebookCreativeList = [];
|
|
337
352
|
fBContent.forEach((obj) => {
|
|
338
353
|
const data = cloneDeep(obj);
|
|
339
|
-
const {
|
|
354
|
+
const {
|
|
355
|
+
subType, linkDescription, imageLink, websiteLink, videoId, videoName, videoUrl,
|
|
356
|
+
} = obj || {};
|
|
340
357
|
delete data.linkDescription;
|
|
341
358
|
delete data.websiteLink;
|
|
342
359
|
data.linkDesc = linkDescription;
|
|
@@ -365,7 +382,7 @@ export class Creatives extends React.Component {
|
|
|
365
382
|
versions: {
|
|
366
383
|
base: {
|
|
367
384
|
content: {
|
|
368
|
-
FacebookAd: {...facebookCreativeList},
|
|
385
|
+
FacebookAd: { ...facebookCreativeList },
|
|
369
386
|
pageOrgUnitId: this.props.orgUnitId,
|
|
370
387
|
},
|
|
371
388
|
},
|
|
@@ -448,7 +465,7 @@ export class Creatives extends React.Component {
|
|
|
448
465
|
} = {},
|
|
449
466
|
} = templateData;
|
|
450
467
|
const mediaParams = {};
|
|
451
|
-
const { url = '', previewUrl = '', docParams = {}, footer = '', headerVarMapped = {}, headerTemplate = ''} = whatsappMedia || {};
|
|
468
|
+
const { url = '', previewUrl = '', docParams = {}, footer = '', headerVarMapped = {}, headerTemplate = '' } = whatsappMedia || {};
|
|
452
469
|
switch (mediaType) {
|
|
453
470
|
case (WHATSAPP_MEDIA_TYPES.IMAGE):
|
|
454
471
|
mediaParams.imageUrl = url;
|
|
@@ -597,7 +614,9 @@ export class Creatives extends React.Component {
|
|
|
597
614
|
emailBase = templateRecords.base;
|
|
598
615
|
}
|
|
599
616
|
const newHtmlContent = await updateImagesInHtml(html_content);
|
|
600
|
-
templateData = {
|
|
617
|
+
templateData = {
|
|
618
|
+
...templateData, ...emailBase, emailBody: newHtmlContent, emailSubject: (emailBase && emailBase.subject) ? emailBase.subject : '',
|
|
619
|
+
};
|
|
601
620
|
delete templateData.html_content;
|
|
602
621
|
delete templateData.subject;
|
|
603
622
|
}
|
|
@@ -660,7 +679,9 @@ export class Creatives extends React.Component {
|
|
|
660
679
|
case constants.WECHAT:
|
|
661
680
|
if (template.value) {
|
|
662
681
|
const { accountId, previewContent, ...messageBody } = template.value;
|
|
663
|
-
templateData = {
|
|
682
|
+
templateData = {
|
|
683
|
+
channel, accountId, messageBody: JSON.stringify(messageBody), previewContent,
|
|
684
|
+
};
|
|
664
685
|
}
|
|
665
686
|
break;
|
|
666
687
|
case constants.LINE:
|
|
@@ -802,13 +823,15 @@ export class Creatives extends React.Component {
|
|
|
802
823
|
case constants.FACEBOOK: {
|
|
803
824
|
if (template.value) {
|
|
804
825
|
const FacebookAd = template?.value?.versions?.base?.content?.FacebookAd;
|
|
805
|
-
const type = FacebookAd[0]
|
|
806
|
-
const {accountId} = this.props.Templates.selectedFacebookAccount || template.value || {};
|
|
826
|
+
const { type } = FacebookAd[0];
|
|
827
|
+
const { accountId } = this.props.Templates.selectedFacebookAccount || template.value || {};
|
|
807
828
|
const facebookCreativeList = [];
|
|
808
829
|
const fBContent = Object.values(FacebookAd);
|
|
809
830
|
fBContent.forEach((obj) => {
|
|
810
831
|
const data = cloneDeep(obj);
|
|
811
|
-
const {
|
|
832
|
+
const {
|
|
833
|
+
subType, linkDesc, imgSrc, webSiteLink, video
|
|
834
|
+
} = obj;
|
|
812
835
|
delete data.type;
|
|
813
836
|
delete data.linkDesc;
|
|
814
837
|
delete data.webSiteLink;
|
|
@@ -845,7 +868,7 @@ export class Creatives extends React.Component {
|
|
|
845
868
|
break;
|
|
846
869
|
case constants.RCS: {
|
|
847
870
|
if (template.value) {
|
|
848
|
-
const {name = "", versions = {}, type = ""} = {
|
|
871
|
+
const { name = "", versions = {}, type = "" } = {
|
|
849
872
|
} = template.value || {};
|
|
850
873
|
const {
|
|
851
874
|
cardContent = [],
|
|
@@ -865,7 +888,6 @@ export class Creatives extends React.Component {
|
|
|
865
888
|
creativeName: name,
|
|
866
889
|
rcsContent,
|
|
867
890
|
};
|
|
868
|
-
|
|
869
891
|
if (smsFallBackContent.message) {
|
|
870
892
|
templateData.smsFallBackContent = smsFallBackContent;
|
|
871
893
|
}
|
|
@@ -888,7 +910,8 @@ export class Creatives extends React.Component {
|
|
|
888
910
|
}
|
|
889
911
|
return templateData;
|
|
890
912
|
};
|
|
891
|
-
|
|
913
|
+
|
|
914
|
+
getSlideBoxContent({ mode, templateData, isFullMode }) {
|
|
892
915
|
let creativesMode = isFullMode ? 'createTemplate' : 'templates';// for library mode templates page is initial mode and for full mode createTemplates
|
|
893
916
|
if (mode === 'create' && isFullMode) {
|
|
894
917
|
creativesMode = 'createTemplate';
|
|
@@ -981,7 +1004,7 @@ export class Creatives extends React.Component {
|
|
|
981
1004
|
() => {
|
|
982
1005
|
const templateData = this.state.templateData ? this.state.templateData : template; //select existing or create new content
|
|
983
1006
|
const channel = templateData.type;
|
|
984
|
-
const creativesData = this.getCreativesData(channel, template, templateData
|
|
1007
|
+
const creativesData = this.getCreativesData(channel, template, templateData);// convers data to consumer understandable format
|
|
985
1008
|
creativesData.then((data) => {
|
|
986
1009
|
this.logGTMEvent(channel, data);
|
|
987
1010
|
this.props.getCreativesData(data);// send data to consumer
|
|
@@ -990,11 +1013,13 @@ export class Creatives extends React.Component {
|
|
|
990
1013
|
);
|
|
991
1014
|
}
|
|
992
1015
|
};
|
|
1016
|
+
|
|
993
1017
|
setIsLoadingContent = (isLoadingContent) => {
|
|
994
1018
|
if (this.state.isLoadingContent !== isLoadingContent) {
|
|
995
|
-
this.setState({isLoadingContent });
|
|
1019
|
+
this.setState({ isLoadingContent });
|
|
996
1020
|
}
|
|
997
1021
|
}
|
|
1022
|
+
|
|
998
1023
|
resetStep = () => {
|
|
999
1024
|
this.setState((prevState) => {
|
|
1000
1025
|
let newState = {
|
|
@@ -1006,6 +1031,7 @@ export class Creatives extends React.Component {
|
|
|
1006
1031
|
return newState;
|
|
1007
1032
|
});
|
|
1008
1033
|
}
|
|
1034
|
+
|
|
1009
1035
|
handleCloseSlideBox = () => {
|
|
1010
1036
|
const { currentChannel = '', slidBoxContent = '' } = this.state;
|
|
1011
1037
|
const reloadTemplates = currentChannel === constants.WHATSAPP && slidBoxContent === 'editTemplate';
|
|
@@ -1018,22 +1044,25 @@ export class Creatives extends React.Component {
|
|
|
1018
1044
|
showSlideBox: false,
|
|
1019
1045
|
}), () => this.props.handleCloseCreatives(reloadTemplates));
|
|
1020
1046
|
};
|
|
1047
|
+
|
|
1021
1048
|
saveMessage = () => {
|
|
1022
1049
|
this.setState({ isGetFormData: true });
|
|
1023
1050
|
};
|
|
1051
|
+
|
|
1024
1052
|
discardMessage = () => {
|
|
1025
1053
|
this.setState({ isDiscardMessage: true });
|
|
1026
1054
|
}
|
|
1055
|
+
|
|
1027
1056
|
shouldShowFooter = () => {
|
|
1028
|
-
const {isFullMode } = this.props;
|
|
1029
|
-
const {slidBoxContent, currentChannel, emailCreateMode, templateNameExists, templateStep, mobilePushCreateMode, inAppCreateMode, weChatTemplateType, templateData} = this.state;
|
|
1057
|
+
const { isFullMode } = this.props;
|
|
1058
|
+
const { slidBoxContent, currentChannel, emailCreateMode, templateNameExists, templateStep, mobilePushCreateMode, inAppCreateMode, weChatTemplateType, templateData } = this.state;
|
|
1030
1059
|
const channel = currentChannel.toUpperCase();
|
|
1031
1060
|
const currentStep = this.creativesTemplateSteps[templateStep];
|
|
1032
1061
|
let showFooter = false;
|
|
1033
1062
|
showFooter = isFullMode && slidBoxContent === "preview";
|
|
1034
1063
|
const isMobilepush = channel === constants.MOBILE_PUSH;
|
|
1035
1064
|
const isInApp = channel === constants.INAPP;
|
|
1036
|
-
if (!isFullMode
|
|
1065
|
+
if (!isFullMode) {
|
|
1037
1066
|
const isEmailCreate = slidBoxContent === 'createTemplate' && channel === constants.EMAIL && currentStep !== 'createTemplateContent';
|
|
1038
1067
|
const isCreate = (slidBoxContent === 'editTemplate' || slidBoxContent === 'createTemplate') && !isEmailCreate;
|
|
1039
1068
|
const isCallTask = channel === constants.CALL_TASK;
|
|
@@ -1056,24 +1085,24 @@ export class Creatives extends React.Component {
|
|
|
1056
1085
|
}
|
|
1057
1086
|
if (channel === constants.MOBILE_PUSH &&
|
|
1058
1087
|
((slidBoxContent === 'createTemplate' && !isEmpty(mobilePushCreateMode))
|
|
1059
|
-
|
|
1088
|
+
|| (slidBoxContent === 'editTemplate' && currentStep === 'modeSelection')) &&
|
|
1060
1089
|
templateNameExists) {
|
|
1061
1090
|
showFooter = true;
|
|
1062
1091
|
}
|
|
1063
1092
|
|
|
1064
1093
|
if (channel === constants.WECHAT &&
|
|
1065
1094
|
((slidBoxContent === 'createTemplate' && !isEmpty(weChatTemplateType))
|
|
1066
|
-
|
|
1095
|
+
|| (slidBoxContent === 'editTemplate' && currentStep === 'modeSelection'))) {
|
|
1067
1096
|
showFooter = true;
|
|
1068
1097
|
}
|
|
1069
1098
|
|
|
1070
1099
|
if (showFooter) {
|
|
1071
1100
|
if (slidBoxContent === "createTemplate" && ((channel === constants.EMAIL && currentStep === 'createTemplateContent') ||
|
|
1072
|
-
|
|
1101
|
+
([constants.SMS, constants.WECHAT].includes(channel) && currentStep === 'modeSelection'))) {
|
|
1073
1102
|
showFooter = showFooter && !this.state.isLoadingContent;
|
|
1074
1103
|
} else if (slidBoxContent === "editTemplate" &&
|
|
1075
|
-
|
|
1076
|
-
|
|
1104
|
+
([constants.SMS, constants.WECHAT, constants.EMAIL].includes(channel) &&
|
|
1105
|
+
currentStep === 'modeSelection')) {
|
|
1077
1106
|
showFooter = showFooter && !this.state.isLoadingContent;
|
|
1078
1107
|
}
|
|
1079
1108
|
}
|
|
@@ -1084,8 +1113,11 @@ export class Creatives extends React.Component {
|
|
|
1084
1113
|
}
|
|
1085
1114
|
return showFooter;
|
|
1086
1115
|
}
|
|
1116
|
+
|
|
1087
1117
|
shouldShowDoneFooter = () => {
|
|
1088
|
-
const {
|
|
1118
|
+
const {
|
|
1119
|
+
slidBoxContent, templateStep, currentChannel, templateData,
|
|
1120
|
+
} = this.state;
|
|
1089
1121
|
const { isFullMode } = this.props;
|
|
1090
1122
|
const currentStep = this.creativesTemplateSteps[templateStep];
|
|
1091
1123
|
let showDone = false;
|
|
@@ -1100,60 +1132,67 @@ export class Creatives extends React.Component {
|
|
|
1100
1132
|
|
|
1101
1133
|
return showDone;
|
|
1102
1134
|
}
|
|
1103
|
-
|
|
1135
|
+
|
|
1136
|
+
templateNameComponentHeader = ({ formData, onFormDataChange, name }) => (
|
|
1104
1137
|
<CapHeader
|
|
1105
1138
|
inline
|
|
1106
1139
|
title={name}
|
|
1107
1140
|
className="support-video-elements"
|
|
1108
|
-
description={
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1141
|
+
description={(
|
|
1142
|
+
<CapLink
|
|
1143
|
+
title={<FormattedMessage {...messages.creativesTemplatesEditName} />}
|
|
1144
|
+
onClick={() => { this.setState({ isEditName: true }, () => { this.showTemplateName({ formData, onFormDataChange }); }); }} />
|
|
1145
|
+
)
|
|
1146
|
+
} />
|
|
1147
|
+
)
|
|
1148
|
+
|
|
1149
|
+
templateNameComponentInput = ({ formData, onFormDataChange, name }) => (
|
|
1150
|
+
<CapInput
|
|
1151
|
+
value={name}
|
|
1152
|
+
suffix={<span />}
|
|
1153
|
+
onBlur={() => { this.setState({ isEditName: false }, () => { this.showTemplateName({ formData, onFormDataChange }); }); }}
|
|
1154
|
+
onChange={(ev) => {
|
|
1155
|
+
const { value } = ev.currentTarget;
|
|
1156
|
+
const isEmptyTemplateName = value.trim() ? false : true;
|
|
1113
1157
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1158
|
+
const newFormData = { ...formData, 'template-name': value, 'isTemplateNameEdited': true };
|
|
1159
|
+
this.setState({ isTemplateNameEmpty: isEmptyTemplateName });
|
|
1160
|
+
onFormDataChange(newFormData);
|
|
1161
|
+
}}
|
|
1162
|
+
/>
|
|
1163
|
+
)
|
|
1120
1164
|
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
onFormDataChange(newFormData);
|
|
1124
|
-
}}
|
|
1125
|
-
/>)
|
|
1126
|
-
showTemplateName = ({formData, onFormDataChange}) => { //gets called from email/index after template data is fetched
|
|
1127
|
-
const {slidBoxContent, currentChannel, isEditName} = this.state;
|
|
1165
|
+
showTemplateName = ({ formData, onFormDataChange }) => { //gets called from email/index after template data is fetched
|
|
1166
|
+
const { slidBoxContent, currentChannel, isEditName } = this.state;
|
|
1128
1167
|
const channel = currentChannel.toUpperCase();
|
|
1129
1168
|
if ([constants.EMAIL, constants.MOBILE_PUSH, constants.INAPP].includes(channel) && (slidBoxContent === 'editTemplate' || slidBoxContent === 'createTemplate')) {
|
|
1130
1169
|
const name = get(formData, 'template-name');
|
|
1131
1170
|
if (channel === constants.EMAIL && !name && slidBoxContent === 'createTemplate') {
|
|
1132
|
-
this.setState({isTemplateNameEmpty: true});
|
|
1171
|
+
this.setState({ isTemplateNameEmpty: true });
|
|
1133
1172
|
}
|
|
1134
|
-
this.templateContainerDetails = {formData, onFormDataChange};
|
|
1173
|
+
this.templateContainerDetails = { formData, onFormDataChange };
|
|
1135
1174
|
if (name && !isEditName) {
|
|
1136
|
-
this.setState({showTemplateNameComponentEdit: false});
|
|
1175
|
+
this.setState({ showTemplateNameComponentEdit: false });
|
|
1137
1176
|
} else if (isEditName) {
|
|
1138
|
-
this.setState({showTemplateNameComponentEdit: true});
|
|
1177
|
+
this.setState({ showTemplateNameComponentEdit: true });
|
|
1139
1178
|
}
|
|
1140
1179
|
}
|
|
1141
1180
|
}
|
|
1142
1181
|
|
|
1143
1182
|
showLiquidErrorInFooter = (errorMessages) => {
|
|
1144
|
-
const isError = (
|
|
1145
|
-
this.setState({isLiquidValidationError: isError, errorMessages});
|
|
1183
|
+
const isError = (errorMessages?.STANDARD_ERROR_MSG?.length > 0 || errorMessages?.LIQUID_ERROR_MSG?.length > 0);
|
|
1184
|
+
this.setState({ isLiquidValidationError: isError, errorMessages });
|
|
1146
1185
|
};
|
|
1147
1186
|
|
|
1148
1187
|
shouldShowContinueFooter = () => { // only for email for now, has to be modified according to channel
|
|
1149
|
-
const {slidBoxContent, templateStep, currentChannel, emailCreateMode, mobilePushCreateMode, inAppCreateMode, weChatTemplateType} = this.state;
|
|
1188
|
+
const { slidBoxContent, templateStep, currentChannel, emailCreateMode, mobilePushCreateMode, inAppCreateMode, weChatTemplateType } = this.state;
|
|
1150
1189
|
let isShowContinueFooter = false;
|
|
1151
1190
|
const currentStep = this.creativesTemplateSteps[templateStep];
|
|
1152
1191
|
const channel = currentChannel.toUpperCase();
|
|
1153
1192
|
if (channel === constants.EMAIL || channel === constants.SMS) {
|
|
1154
1193
|
if ((emailCreateMode === "upload" && !isEmpty(this.props.EmailLayout)) || emailCreateMode === "editor") {
|
|
1155
1194
|
let isEmailCreate = slidBoxContent === 'createTemplate';
|
|
1156
|
-
isEmailCreate = currentChannel.toUpperCase() === constants.EMAIL && ((emailCreateMode === "upload" && currentStep !== 'createTemplateContent') || (
|
|
1195
|
+
isEmailCreate = currentChannel.toUpperCase() === constants.EMAIL && ((emailCreateMode === "upload" && currentStep !== 'createTemplateContent') || (emailCreateMode === "editor" && currentStep !== 'createTemplateContent' && currentStep !== "templateSelection"));
|
|
1157
1196
|
isShowContinueFooter = isEmailCreate && emailCreateMode;
|
|
1158
1197
|
}
|
|
1159
1198
|
} else if (currentChannel.toUpperCase() === constants.MOBILE_PUSH) {
|
|
@@ -1166,24 +1205,27 @@ export class Creatives extends React.Component {
|
|
|
1166
1205
|
|
|
1167
1206
|
return isShowContinueFooter;
|
|
1168
1207
|
}
|
|
1208
|
+
|
|
1169
1209
|
templateNameRenderProp = () => {
|
|
1170
|
-
const {showTemplateNameComponentEdit, currentChannel, slidBoxContent} = this.state;
|
|
1171
|
-
const {templateContainerDetails} = this;
|
|
1172
|
-
const {formData, onFormDataChange} = templateContainerDetails;
|
|
1210
|
+
const { showTemplateNameComponentEdit, currentChannel, slidBoxContent } = this.state;
|
|
1211
|
+
const { templateContainerDetails } = this;
|
|
1212
|
+
const { formData, onFormDataChange } = templateContainerDetails;
|
|
1173
1213
|
const channel = currentChannel.toUpperCase();
|
|
1174
1214
|
if ([constants.EMAIL, constants.MOBILE_PUSH, constants.INAPP].includes(channel) && (slidBoxContent === 'editTemplate' || slidBoxContent === 'createTemplate')) {
|
|
1175
1215
|
const name = get(formData, 'template-name');
|
|
1176
|
-
return showTemplateNameComponentEdit ? this.templateNameComponentInput({formData, onFormDataChange, name}) : this.templateNameComponentHeader({formData, onFormDataChange, name});
|
|
1216
|
+
return showTemplateNameComponentEdit ? this.templateNameComponentInput({ formData, onFormDataChange, name }) : this.templateNameComponentHeader({ formData, onFormDataChange, name });
|
|
1177
1217
|
}
|
|
1178
1218
|
return false;
|
|
1179
1219
|
}
|
|
1220
|
+
|
|
1180
1221
|
shouldShowHeader = () => {
|
|
1181
|
-
const {currentChannel, slidBoxContent} = this.state;
|
|
1222
|
+
const { currentChannel, slidBoxContent } = this.state;
|
|
1182
1223
|
if (currentChannel.toUpperCase() === constants.FACEBOOK && slidBoxContent === 'createTemplate') {
|
|
1183
1224
|
return false;
|
|
1184
1225
|
}
|
|
1185
1226
|
return true;
|
|
1186
1227
|
}
|
|
1228
|
+
|
|
1187
1229
|
render() {
|
|
1188
1230
|
const {
|
|
1189
1231
|
slidBoxContent,
|
|
@@ -1229,37 +1271,39 @@ export class Creatives extends React.Component {
|
|
|
1229
1271
|
errorMessages?.STANDARD_ERROR_MSG?.length > 0 && errorMessages?.LIQUID_ERROR_MSG?.length > 0
|
|
1230
1272
|
? CAP_SPACE_64
|
|
1231
1273
|
: errorMessages?.LIQUID_ERROR_MSG?.length > 0
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1274
|
+
? CAP_SPACE_56
|
|
1275
|
+
: errorMessages?.STANDARD_ERROR_MSG?.length > 0
|
|
1276
|
+
? CAP_SPACE_32
|
|
1277
|
+
: 0;
|
|
1236
1278
|
/* TODO: Instead of passing down same props separately to each component down, write common function to these props and pass it accordingly */
|
|
1237
1279
|
return (
|
|
1238
1280
|
<SlideBoxWrapper slideBoxWrapperMargin={slideBoxWrapperMargin} className={classnames(`${classPrefix} ${isFullMode ? 'creatives-full-mode' : 'creatives-library-mode'} ${mapTemplateCreate ? 'map-template-create' : ''}`)}>
|
|
1239
1281
|
<CapSlideBox
|
|
1240
1282
|
header={
|
|
1241
|
-
this.shouldShowHeader() &&
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1283
|
+
this.shouldShowHeader() && (
|
|
1284
|
+
<SlideBoxHeader
|
|
1285
|
+
key="creatives-container-slidebox-header"
|
|
1286
|
+
channel={currentChannel}
|
|
1287
|
+
messages={this.props.messages}
|
|
1288
|
+
slidBoxContent={this.state.slidBoxContent}
|
|
1289
|
+
templateData={templateData}
|
|
1290
|
+
onShowTemplates={this.onShowTemplates}
|
|
1291
|
+
creativesMode={creativesMode}
|
|
1292
|
+
isFullMode={isFullMode}
|
|
1293
|
+
isLoadingContent={isLoadingContent}
|
|
1294
|
+
shouldShowTemplateName={this.templateContainerDetails}
|
|
1295
|
+
templateNameRenderProp={this.templateNameRenderProp}
|
|
1296
|
+
weChatMaptemplateStep={weChatMaptemplateStep}
|
|
1297
|
+
onWeChatMaptemplateStepChange={this.onWeChatMaptemplateStepChange}
|
|
1298
|
+
weChatTemplateType={weChatTemplateType}
|
|
1299
|
+
showPrefix={!isUploading} // not show back button when email template is being uploaded
|
|
1300
|
+
templateStep={this.creativesTemplateSteps[templateStep]}
|
|
1301
|
+
smsRegister={smsRegister}
|
|
1302
|
+
handleClose={this.handleCloseSlideBox}
|
|
1303
|
+
moduleType={this.props.messageDetails?.type}
|
|
1304
|
+
/>
|
|
1305
|
+
)}
|
|
1306
|
+
content={(
|
|
1263
1307
|
<SlideBoxContent
|
|
1264
1308
|
key="creatives-container-slidebox-content"
|
|
1265
1309
|
onSelectTemplate={this.onSelectTemplate}
|
|
@@ -1322,9 +1366,9 @@ export class Creatives extends React.Component {
|
|
|
1322
1366
|
creativesMode={creativesMode} // An existing prop that we're using here. Required to ensure correct account details in Edit or Preview in case of Embedded mode.
|
|
1323
1367
|
hostName={this.props?.hostName || ''}
|
|
1324
1368
|
eventContextTags={eventContextTags}
|
|
1325
|
-
|
|
1326
|
-
}
|
|
1327
|
-
footer={this.shouldShowFooter() &&
|
|
1369
|
+
/>
|
|
1370
|
+
)}
|
|
1371
|
+
footer={this.shouldShowFooter() && (
|
|
1328
1372
|
<SlideBoxFooter
|
|
1329
1373
|
isFullMode={isFullMode}
|
|
1330
1374
|
messages={this.props.messages}
|
|
@@ -1340,10 +1384,10 @@ export class Creatives extends React.Component {
|
|
|
1340
1384
|
shouldShowDoneFooter={this.shouldShowDoneFooter}
|
|
1341
1385
|
fetchingCmsData={fetchingCmsData}
|
|
1342
1386
|
isTemplateNameEmpty={isTemplateNameEmpty}
|
|
1343
|
-
isLiquidValidationError
|
|
1387
|
+
isLiquidValidationError={isLiquidValidationError}
|
|
1344
1388
|
errorMessages={errorMessages}
|
|
1345
1389
|
/>
|
|
1346
|
-
}
|
|
1390
|
+
)}
|
|
1347
1391
|
handleClose={this.handleCloseSlideBox}
|
|
1348
1392
|
show={showSlideBox}
|
|
1349
1393
|
size="size-xl"
|
|
@@ -1403,6 +1447,6 @@ function mapDispatchToProps(dispatch) {
|
|
|
1403
1447
|
const withConnect = connect(mapStatesToProps, mapDispatchToProps);
|
|
1404
1448
|
const withReducer = injectReducer({ key: 'creativesContainer', reducer: creativesContainerReducer });
|
|
1405
1449
|
const withSaga = injectSaga({ key: 'cap', saga: capSagaForFetchSchemaForEntity });
|
|
1406
|
-
const withDefaultTempSaga = injectSaga({ key: '
|
|
1450
|
+
const withDefaultTempSaga = injectSaga({ key: 'creativesContainer', saga: v2TemplateSagaWatchGetDefaultBeeTemplates });
|
|
1407
1451
|
|
|
1408
1452
|
export default compose(withSaga, withDefaultTempSaga, withReducer, withConnect)(injectIntl(Creatives));
|