@capillarytech/creatives-library 6.7.0 → 6.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/line-image-placeholder.svg +14 -0
- package/assets/line.png +0 -0
- package/assets/smiley-placeholder.svg +11 -0
- package/components/TemplatePreview/index.js +185 -8
- package/index.js +3 -3
- package/package.json +1 -1
- package/routes.js +2 -2
- package/services/api.js +4 -1
- package/styles/vendor/semantic/src/definitions/modules/accordion.less +219 -219
- package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +1 -1
- package/v2Components/TemplatePreview/assets/images/WECHAT_5x.png +0 -0
- package/v2Components/TemplatePreview/index.js +164 -12
- package/v2Components/TemplatePreview/messages.js +8 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +51 -17
- package/v2Containers/CreativesContainer/index.js +23 -17
- package/v2Containers/Line/Container/Drawer/index.js +93 -0
- package/v2Containers/Line/Container/Image/constants.js +3 -0
- package/v2Containers/Line/Container/Image/index.js +460 -0
- package/v2Containers/Line/Container/Image/messages.js +86 -0
- package/v2Containers/Line/Container/Image/style.js +32 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/custom.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateEight.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateFive.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateFour.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateOne.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateSeven.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateSix.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateThree.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateTwo.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/custom.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateEight.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateFive.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateFour.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateOne.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateSeven.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateSix.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateThree.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateTwo.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/custom.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateEight.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateFive.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateFour.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateOne.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateSeven.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateSix.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateThree.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateTwo.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/custom.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateEight.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateFive.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateFour.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateOne.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateSeven.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateSix.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateThree.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateTwo.png +0 -0
- package/v2Containers/Line/Container/ImageMap/constants.js +19 -0
- package/v2Containers/Line/Container/ImageMap/index.js +603 -0
- package/v2Containers/Line/Container/ImageMap/messages.js +126 -0
- package/v2Containers/Line/Container/ImageMap/style.js +94 -0
- package/v2Containers/Line/Container/ImageMap/templates.json +195 -0
- package/v2Containers/Line/Container/Sticker/index.js +224 -0
- package/v2Containers/Line/Container/Sticker/messages.js +34 -0
- package/v2Containers/Line/Container/Sticker/style.js +36 -0
- package/v2Containers/Line/Container/Sticker/utils.js +68 -0
- package/v2Containers/Line/Container/Text/index.js +338 -0
- package/v2Containers/Line/Container/Text/messages.js +74 -0
- package/v2Containers/Line/Container/Text/style.js +37 -0
- package/v2Containers/Line/Container/Wrapper/index.js +152 -0
- package/v2Containers/Line/Container/Wrapper/messages.js +46 -0
- package/v2Containers/Line/Container/Wrapper/style.js +44 -0
- package/v2Containers/Line/Container/Wrapper/utils.js +67 -0
- package/v2Containers/Line/Container/_lineCreate.scss +108 -0
- package/v2Containers/Line/Container/actions.js +99 -0
- package/v2Containers/Line/Container/constants.js +48 -0
- package/v2Containers/Line/Container/index.js +581 -0
- package/v2Containers/Line/Container/messages.js +66 -0
- package/v2Containers/Line/Container/reducer.js +103 -0
- package/v2Containers/Line/Container/sagas.js +137 -0
- package/v2Containers/Line/Container/selectors.js +30 -0
- package/v2Containers/Line/Container/style.js +57 -0
- package/v2Containers/Line/Create/index.js +1 -1
- package/v2Containers/Templates/index.js +40 -22
- package/v2Containers/Templates/messages.js +8 -0
- package/v2Containers/TemplatesV2/index.js +13 -0
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { bindActionCreators } from 'redux';
|
|
3
|
+
import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
|
|
4
|
+
import { createStructuredSelector } from 'reselect';
|
|
5
|
+
import get from 'lodash/get';
|
|
6
|
+
import isEmpty from 'lodash/isEmpty';
|
|
7
|
+
import style from './style';
|
|
8
|
+
import withStyles from '../../../hoc/withStyles';
|
|
9
|
+
import './_lineCreate.scss';
|
|
10
|
+
|
|
11
|
+
import CapButton from '@capillarytech/cap-ui-library/CapButton';
|
|
12
|
+
import CapNotification from '@capillarytech/cap-ui-library/CapNotification';
|
|
13
|
+
import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
|
|
14
|
+
import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
15
|
+
import CapColumn from '@capillarytech/cap-ui-library/CapColumn';
|
|
16
|
+
import CapRadioCard from '@capillarytech/cap-ui-library/CapRadioCard';
|
|
17
|
+
import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
|
|
18
|
+
import CapHeader from '@capillarytech/cap-ui-library/CapHeader';
|
|
19
|
+
import LineWrapper from './Wrapper';
|
|
20
|
+
import messages from './messages';
|
|
21
|
+
import { TEXT, IMAGE, IMAGE_MAP, STICKER, MAX_LINE_WRAPPER_LIMIT, MAX_LINE_WRAPPER_LIMIT_FULL_MODE } from './constants';
|
|
22
|
+
import { FONT_COLOR_05 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
23
|
+
|
|
24
|
+
import { makeSelectMetaEntities, setInjectedTags } from '../../Cap/selectors';
|
|
25
|
+
import { makeSelectTemplates } from '../../Templates/selectors';
|
|
26
|
+
import TemplatePreview from '../../../v2Components/TemplatePreview';
|
|
27
|
+
import {makeSelectCreateLine, makeSelectLine } from './selectors';
|
|
28
|
+
import * as compActions from './actions';
|
|
29
|
+
import * as templateActionsConfig from '../../Templates/actions';
|
|
30
|
+
import withCreatives from '../../../hoc/withCreatives';
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export const LineContainer = ({
|
|
35
|
+
isFullMode,
|
|
36
|
+
globalActions,
|
|
37
|
+
metaEntities,
|
|
38
|
+
injectedTags = {},
|
|
39
|
+
getDefaultTags,
|
|
40
|
+
location,
|
|
41
|
+
supportedTags,
|
|
42
|
+
actions,
|
|
43
|
+
Line,
|
|
44
|
+
className,
|
|
45
|
+
params,
|
|
46
|
+
onCreateComplete,
|
|
47
|
+
intl: { formatMessage },
|
|
48
|
+
getFormSubscriptionData,
|
|
49
|
+
templateData,
|
|
50
|
+
lineData,
|
|
51
|
+
isCreateFlow,
|
|
52
|
+
templateActions,
|
|
53
|
+
Templates,
|
|
54
|
+
createNew,
|
|
55
|
+
onShowTemplates,
|
|
56
|
+
handleClose,
|
|
57
|
+
additionalProperties
|
|
58
|
+
}) => {
|
|
59
|
+
const paramObj = params || {};
|
|
60
|
+
const initialWrapperContent = [{ type: TEXT, isError: true, isInit: true }];
|
|
61
|
+
const [lineWrapperContents, updateLineWrapperContent] = useState(initialWrapperContent);
|
|
62
|
+
const [isEditFlow, checkEditFlow] = useState(false);
|
|
63
|
+
const [isEditLoading, updateEditLoading] = useState(false);
|
|
64
|
+
const [accountSelectFlow, updateAccountSelectFlow] = useState(false);
|
|
65
|
+
const [selectedAccount, updateSelectedAccount] = useState('');
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (!isFullMode) {
|
|
69
|
+
templateActions.getWeCrmAccounts('Line');
|
|
70
|
+
updateAccountSelectFlow(true);
|
|
71
|
+
const queryParams = {"sortBy":"Most Recent","page":1,"perPage":25};
|
|
72
|
+
templateActions.getAllTemplates('Line', queryParams);
|
|
73
|
+
}
|
|
74
|
+
}, []);
|
|
75
|
+
|
|
76
|
+
const onAccountSelect = (account) => {
|
|
77
|
+
const { value } = account.target;
|
|
78
|
+
templateActions.setLineAccount(Templates.weCrmAccounts.find((item) => item.name === value));
|
|
79
|
+
updateSelectedAccount(value);
|
|
80
|
+
updateAccountSelectFlow(false);
|
|
81
|
+
createNew();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const { id } = paramObj;
|
|
86
|
+
if (id) {
|
|
87
|
+
updateEditLoading(true);
|
|
88
|
+
actions.getTemplateDetails(id, updateEditLoading);
|
|
89
|
+
checkEditFlow(true);
|
|
90
|
+
}
|
|
91
|
+
}, [paramObj.id]);
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (params && params.id) {
|
|
95
|
+
const type = get(Line, 'templateDetails.mode');
|
|
96
|
+
const messageContent = get(Line, `templateDetails.versions.base.content.messages.0.text`);
|
|
97
|
+
const originalContentUrl = get(Line, `templateDetails.versions.base.content.messages.0.originalContentUrl`);
|
|
98
|
+
const previewImageUrl = get(Line, `templateDetails.versions.base.content.messages.0.previewImageUrl`);
|
|
99
|
+
const stickerUrl = get(Line, `templateDetails.versions.base.content.messages.0.stickerUrl`);
|
|
100
|
+
const animatedStickerUrl = get(Line, `templateDetails.versions.base.content.messages.0.animatedStickerUrl`);
|
|
101
|
+
const stickerId = get(Line, `templateDetails.versions.base.content.messages.0.stickerId`);
|
|
102
|
+
const packageId = get(Line, `templateDetails.versions.base.content.messages.0.packageId`);
|
|
103
|
+
const messageTitle = get(Line, 'templateDetails.name');
|
|
104
|
+
const baseUrl = get(Line, `templateDetails.versions.base.content.messages.0.baseUrl`);
|
|
105
|
+
const baseSize = get(Line, `templateDetails.versions.base.content.messages.0.baseSize`);
|
|
106
|
+
const selectedTemplate = get(Line, 'templateDetails.selectedTemplate');
|
|
107
|
+
const assetType = get(Line, 'templateDetails.assetType');
|
|
108
|
+
const actionLinks = get(Line, 'templateDetails.actionLinks');
|
|
109
|
+
const lineContent = {
|
|
110
|
+
type,
|
|
111
|
+
messageContent,
|
|
112
|
+
originalContentUrl,
|
|
113
|
+
previewImageUrl,
|
|
114
|
+
messageTitle,
|
|
115
|
+
selectedSticker: {
|
|
116
|
+
stickerUrl,
|
|
117
|
+
animatedStickerUrl,
|
|
118
|
+
stickerId: `${stickerId}`,
|
|
119
|
+
packageId: `${packageId}`,
|
|
120
|
+
},
|
|
121
|
+
selectedTemplate,
|
|
122
|
+
assetType,
|
|
123
|
+
baseUrl,
|
|
124
|
+
actionLinks,
|
|
125
|
+
baseSize,
|
|
126
|
+
};
|
|
127
|
+
updateLineWrapperContent([lineContent]);
|
|
128
|
+
}
|
|
129
|
+
}, [Line.templateDetails]);
|
|
130
|
+
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (templateData && templateData.versions) {
|
|
133
|
+
const lineMessages = get(templateData, 'versions.base.content.messages', [{}]);
|
|
134
|
+
const lineContent = [];
|
|
135
|
+
lineMessages.forEach(({
|
|
136
|
+
type = 'text',
|
|
137
|
+
text,
|
|
138
|
+
originalContentUrl,
|
|
139
|
+
previewImageUrl,
|
|
140
|
+
stickerUrl,
|
|
141
|
+
animatedStickerUrl,
|
|
142
|
+
selectedSticker,
|
|
143
|
+
stickerId,
|
|
144
|
+
packageId,
|
|
145
|
+
baseUrl,
|
|
146
|
+
baseSize,
|
|
147
|
+
actionLinks,
|
|
148
|
+
assetType,
|
|
149
|
+
selectedTemplate
|
|
150
|
+
}) => {
|
|
151
|
+
const obj = {
|
|
152
|
+
type,
|
|
153
|
+
messageContent: text,
|
|
154
|
+
originalContentUrl,
|
|
155
|
+
previewImageUrl,
|
|
156
|
+
selectedSticker,
|
|
157
|
+
baseUrl,
|
|
158
|
+
baseSize,
|
|
159
|
+
actionLinks,
|
|
160
|
+
assetType,
|
|
161
|
+
selectedTemplate
|
|
162
|
+
};
|
|
163
|
+
if (stickerUrl) {
|
|
164
|
+
obj.selectedSticker = {
|
|
165
|
+
stickerUrl,
|
|
166
|
+
animatedStickerUrl,
|
|
167
|
+
stickerId: `${stickerId}`,
|
|
168
|
+
packageId: `${packageId}`,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
lineContent.push(obj);
|
|
172
|
+
});
|
|
173
|
+
updateLineWrapperContent(lineContent);
|
|
174
|
+
}
|
|
175
|
+
}, [templateData]);
|
|
176
|
+
|
|
177
|
+
const addLineWrappers = () => {
|
|
178
|
+
updateLineWrapperContent([...lineWrapperContents, ...initialWrapperContent])
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const deleteWrapper = index => {
|
|
182
|
+
const selectedIndex = lineWrapperContents.findIndex((el, i) => i === index);
|
|
183
|
+
if (selectedIndex > -1) {
|
|
184
|
+
const newLineWrapperContents = [...lineWrapperContents];
|
|
185
|
+
newLineWrapperContents.splice(selectedIndex, 1);
|
|
186
|
+
updateLineWrapperContent(newLineWrapperContents);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const shiftUp = index => {
|
|
191
|
+
const selectedIndex = lineWrapperContents.findIndex((el, i) => i === index);
|
|
192
|
+
const selectedElement = lineWrapperContents.find((el, i) => i === index);
|
|
193
|
+
if (selectedIndex > -1) {
|
|
194
|
+
const newLineWrapperContents = [...lineWrapperContents];
|
|
195
|
+
newLineWrapperContents.splice(selectedIndex, 1);
|
|
196
|
+
newLineWrapperContents.splice(selectedIndex - 1, 0, selectedElement);
|
|
197
|
+
updateLineWrapperContent(newLineWrapperContents);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const shiftDown = index => {
|
|
202
|
+
const selectedIndex = lineWrapperContents.findIndex((el, i) => i === index);
|
|
203
|
+
const selectedElement = lineWrapperContents.find((el, i) => i === index);
|
|
204
|
+
if (selectedIndex > -1) {
|
|
205
|
+
const newLineWrapperContents = [...lineWrapperContents];
|
|
206
|
+
newLineWrapperContents.splice(selectedIndex, 1);
|
|
207
|
+
newLineWrapperContents.splice(selectedIndex + 1, 0, selectedElement);
|
|
208
|
+
updateLineWrapperContent(newLineWrapperContents);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const updateMessageState = (obj) => {
|
|
213
|
+
const { index: selectedIndex, ...rest } = obj;
|
|
214
|
+
const newLineWrapperContents = [...lineWrapperContents];
|
|
215
|
+
newLineWrapperContents.splice(selectedIndex, 1, rest);
|
|
216
|
+
updateLineWrapperContent(newLineWrapperContents);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const isDoneDisabled = () => {
|
|
220
|
+
if (!lineWrapperContents.length) {
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
let isDisabled = false;
|
|
224
|
+
lineWrapperContents.forEach(({isError}) => {
|
|
225
|
+
isDisabled = isDisabled || isError;
|
|
226
|
+
});
|
|
227
|
+
return isDisabled;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const getLineWrappers = () => {
|
|
231
|
+
return lineWrapperContents.map((lineWrapperContent, index) => {
|
|
232
|
+
let tags =
|
|
233
|
+
metaEntities && metaEntities.tags
|
|
234
|
+
? metaEntities.tags.standard
|
|
235
|
+
: [];
|
|
236
|
+
if (supportedTags) {
|
|
237
|
+
tags = supportedTags;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<LineWrapper
|
|
242
|
+
id={`${lineWrapperContent.type}__${index}`}
|
|
243
|
+
globalActions={globalActions}
|
|
244
|
+
tags={tags}
|
|
245
|
+
injectedTags={injectedTags}
|
|
246
|
+
getDefaultTags={getDefaultTags}
|
|
247
|
+
isFullMode={isFullMode}
|
|
248
|
+
location={location}
|
|
249
|
+
actions={actions}
|
|
250
|
+
Line={Line}
|
|
251
|
+
index={index}
|
|
252
|
+
deleteWrapper={deleteWrapper}
|
|
253
|
+
updateMessageState={updateMessageState}
|
|
254
|
+
content={lineWrapperContent}
|
|
255
|
+
selectedType={lineWrapperContent.type}
|
|
256
|
+
shiftUp={shiftUp}
|
|
257
|
+
shiftDown={shiftDown}
|
|
258
|
+
lineWrappers={lineWrapperContents.length}
|
|
259
|
+
Templates={Templates}
|
|
260
|
+
getAllTemplates={templateActions.getAllTemplates}
|
|
261
|
+
/>
|
|
262
|
+
);
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const createCallback = () => {
|
|
267
|
+
CapNotification.success({
|
|
268
|
+
message: formatMessage(messages.lineCreateNotification),
|
|
269
|
+
});
|
|
270
|
+
actions.clearEditResponse();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const editCallback = () => {
|
|
274
|
+
CapNotification.success({
|
|
275
|
+
message: formatMessage(messages.lineEditNotification),
|
|
276
|
+
});
|
|
277
|
+
actions.clearEditResponse();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const formatSubmitPayload = (lineWrapperContents) => {
|
|
281
|
+
const [ {
|
|
282
|
+
messageTitle,
|
|
283
|
+
messageContent,
|
|
284
|
+
type,
|
|
285
|
+
messageType,
|
|
286
|
+
previewImageUrl,
|
|
287
|
+
originalContentUrl,
|
|
288
|
+
selectedSticker,
|
|
289
|
+
baseUrl,
|
|
290
|
+
baseSize,
|
|
291
|
+
selectedTemplate,
|
|
292
|
+
assetType,
|
|
293
|
+
actionLinks
|
|
294
|
+
} = {}] = lineWrapperContents;
|
|
295
|
+
let messageData = { type };
|
|
296
|
+
messageData[messageType] = messageContent;
|
|
297
|
+
if (previewImageUrl) {
|
|
298
|
+
messageData.previewImageUrl = previewImageUrl;
|
|
299
|
+
}
|
|
300
|
+
if (originalContentUrl) {
|
|
301
|
+
messageData.originalContentUrl = originalContentUrl;
|
|
302
|
+
}
|
|
303
|
+
if (selectedSticker) {
|
|
304
|
+
messageData.stickerUrl = selectedSticker.stickerUrl;
|
|
305
|
+
messageData.animatedStickerUrl = selectedSticker.animatedStickerUrl;
|
|
306
|
+
messageData.packageId = `${selectedSticker.packageId}`;
|
|
307
|
+
messageData.stickerId = `${selectedSticker.stickerId}`;
|
|
308
|
+
}
|
|
309
|
+
if (baseUrl) {
|
|
310
|
+
messageData.baseUrl = baseUrl;
|
|
311
|
+
messageData.altText = IMAGE_MAP;
|
|
312
|
+
}
|
|
313
|
+
if (baseSize) {
|
|
314
|
+
messageData.baseSize = baseSize;
|
|
315
|
+
}
|
|
316
|
+
return {
|
|
317
|
+
versions: {
|
|
318
|
+
base: {
|
|
319
|
+
content: {
|
|
320
|
+
to: "{{line_id}}",
|
|
321
|
+
messages: [messageData]
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
type: "LINE",
|
|
326
|
+
name: messageTitle,
|
|
327
|
+
definition: {
|
|
328
|
+
"mode": type,
|
|
329
|
+
selectedTemplate,
|
|
330
|
+
actionLinks,
|
|
331
|
+
assetType
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const formatNonStandalonePayload = (lineWrapperContents) => {
|
|
337
|
+
const lineContents = lineWrapperContents.map(({
|
|
338
|
+
messageContent,
|
|
339
|
+
type,
|
|
340
|
+
messageType,
|
|
341
|
+
previewImageUrl,
|
|
342
|
+
originalContentUrl,
|
|
343
|
+
selectedSticker,
|
|
344
|
+
baseUrl,
|
|
345
|
+
baseSize,
|
|
346
|
+
selectedTemplate,
|
|
347
|
+
assetType,
|
|
348
|
+
actionLinks
|
|
349
|
+
}) => {
|
|
350
|
+
let messageData = { type };
|
|
351
|
+
messageData[messageType] = messageContent;
|
|
352
|
+
if (previewImageUrl) {
|
|
353
|
+
messageData.previewImageUrl = previewImageUrl;
|
|
354
|
+
}
|
|
355
|
+
if (originalContentUrl) {
|
|
356
|
+
messageData.originalContentUrl = originalContentUrl;
|
|
357
|
+
}
|
|
358
|
+
if (selectedSticker) {
|
|
359
|
+
messageData.stickerUrl = selectedSticker.stickerUrl;
|
|
360
|
+
messageData.animatedStickerUrl = selectedSticker.animatedStickerUrl;
|
|
361
|
+
messageData.stickerId = `${selectedSticker.stickerId}`;
|
|
362
|
+
messageData.packageId = `${selectedSticker.packageId}`;
|
|
363
|
+
}
|
|
364
|
+
if (baseUrl) {
|
|
365
|
+
messageData.baseUrl = baseUrl;
|
|
366
|
+
messageData.altText = IMAGE_MAP;
|
|
367
|
+
messageData.baseSize = baseSize;
|
|
368
|
+
messageData.selectedTemplate = selectedTemplate;
|
|
369
|
+
messageData.assetType = assetType;
|
|
370
|
+
messageData.actionLinks = actionLinks;
|
|
371
|
+
}
|
|
372
|
+
return messageData;
|
|
373
|
+
});
|
|
374
|
+
return ({
|
|
375
|
+
versions: {
|
|
376
|
+
base: {
|
|
377
|
+
content: {
|
|
378
|
+
messages: lineContents,
|
|
379
|
+
to: "{{line_id}}",
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const onCreateLine = () => {
|
|
387
|
+
actions.createTemplate(
|
|
388
|
+
formatSubmitPayload(lineWrapperContents),
|
|
389
|
+
() => {
|
|
390
|
+
createCallback();
|
|
391
|
+
onCreateComplete();
|
|
392
|
+
}
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const getPreviewSection = () => {
|
|
397
|
+
const accountName = get(lineData, 'selectedLineAccount.name', '');
|
|
398
|
+
const templateContent = lineWrapperContents.map(({ messageContent, type, previewImageUrl, selectedSticker, baseUrl }) => ({
|
|
399
|
+
messageContent,
|
|
400
|
+
previewImageUrl,
|
|
401
|
+
selectedSticker,
|
|
402
|
+
type,
|
|
403
|
+
baseUrl
|
|
404
|
+
}));
|
|
405
|
+
|
|
406
|
+
return (
|
|
407
|
+
<TemplatePreview
|
|
408
|
+
// style={val.customStyling ? val.customStyling : {}}
|
|
409
|
+
channel="LINE"
|
|
410
|
+
content={templateContent}
|
|
411
|
+
LineAccountName={accountName[0]}
|
|
412
|
+
/>
|
|
413
|
+
)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const onEditLine = () => {
|
|
417
|
+
actions.editTemplate(
|
|
418
|
+
{
|
|
419
|
+
...formatSubmitPayload(lineWrapperContents),
|
|
420
|
+
_id: params.id,
|
|
421
|
+
},
|
|
422
|
+
() => {
|
|
423
|
+
editCallback();
|
|
424
|
+
onCreateComplete();
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const onDoneCallback = () => {
|
|
429
|
+
if (isFullMode) {
|
|
430
|
+
if (isEditFlow) {
|
|
431
|
+
return onEditLine;
|
|
432
|
+
}
|
|
433
|
+
return onCreateLine;
|
|
434
|
+
}
|
|
435
|
+
return () => getFormSubscriptionData({
|
|
436
|
+
value: formatNonStandalonePayload(lineWrapperContents),
|
|
437
|
+
_id: params && params.id,
|
|
438
|
+
validity: true,
|
|
439
|
+
type: 'LINE',
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const isLoading = isEditLoading;
|
|
444
|
+
|
|
445
|
+
if (isCreateFlow && !isFullMode && accountSelectFlow) {
|
|
446
|
+
const {
|
|
447
|
+
weCrmAccounts,
|
|
448
|
+
fetchingWeCrmAccounts,
|
|
449
|
+
} = Templates;
|
|
450
|
+
if (isEmpty(weCrmAccounts) && !fetchingWeCrmAccounts) {
|
|
451
|
+
return <FormattedMessage {...messages.noAccountsPresentLine} />;
|
|
452
|
+
}
|
|
453
|
+
const accountOptions = (weCrmAccounts || [{}]).map(({
|
|
454
|
+
name = '',
|
|
455
|
+
uuid,
|
|
456
|
+
}) => ({
|
|
457
|
+
key: uuid,
|
|
458
|
+
value: name,
|
|
459
|
+
title: name,
|
|
460
|
+
icon: <CapIcon.CapIconAvatar text={name[0]} width="auto" height="2rem"/>,
|
|
461
|
+
}));
|
|
462
|
+
const accountHeader = formatMessage(messages.lineAccount);
|
|
463
|
+
return (
|
|
464
|
+
<CapSpin spinning={fetchingWeCrmAccounts}>
|
|
465
|
+
<CapHeader
|
|
466
|
+
title={accountHeader}
|
|
467
|
+
description={formatMessage(messages.chooseAccount)}
|
|
468
|
+
size="regular"
|
|
469
|
+
className="select-account-header"
|
|
470
|
+
/>
|
|
471
|
+
<CapRadioCard
|
|
472
|
+
className="select-account"
|
|
473
|
+
onChange={onAccountSelect}
|
|
474
|
+
panes={accountOptions}
|
|
475
|
+
cardHeight="48px"
|
|
476
|
+
cardWidth="276px"
|
|
477
|
+
size="small"
|
|
478
|
+
defaultValue={selectedAccount}
|
|
479
|
+
selected={selectedAccount}
|
|
480
|
+
/>
|
|
481
|
+
</CapSpin>
|
|
482
|
+
)
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
const getAccountSection = () => {
|
|
486
|
+
const accountName = get(lineData, 'selectedLineAccount.name', '');
|
|
487
|
+
if (createNew && !isFullMode) {
|
|
488
|
+
return (
|
|
489
|
+
<>
|
|
490
|
+
<span>{accountName}</span>
|
|
491
|
+
<CapButton
|
|
492
|
+
onClick={onShowTemplates}
|
|
493
|
+
type="flat"
|
|
494
|
+
style={{ fontWeight: 500, color: FONT_COLOR_05 }}
|
|
495
|
+
>
|
|
496
|
+
<FormattedMessage {...messages.changeAccount} />
|
|
497
|
+
</CapButton>
|
|
498
|
+
</>
|
|
499
|
+
)
|
|
500
|
+
}
|
|
501
|
+
return null;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
return (
|
|
505
|
+
<div className={className}>
|
|
506
|
+
<CapSpin spinning={isLoading}>
|
|
507
|
+
<CapRow>
|
|
508
|
+
<CapColumn span={14}>
|
|
509
|
+
{getAccountSection()}
|
|
510
|
+
<CapHeader
|
|
511
|
+
title={formatMessage(messages.lineCreativeTitle)}
|
|
512
|
+
description={formatMessage(messages.lineCreativeDescription)}
|
|
513
|
+
/>
|
|
514
|
+
{getLineWrappers()}
|
|
515
|
+
<CapButton
|
|
516
|
+
onClick={addLineWrappers}
|
|
517
|
+
disabled={lineWrapperContents.length === (isFullMode ? MAX_LINE_WRAPPER_LIMIT_FULL_MODE : MAX_LINE_WRAPPER_LIMIT)}
|
|
518
|
+
type="flat"
|
|
519
|
+
isAddBtn
|
|
520
|
+
className="add-msg"
|
|
521
|
+
>
|
|
522
|
+
<FormattedMessage {...messages.addMessageButtonLabel} />
|
|
523
|
+
</CapButton>
|
|
524
|
+
</CapColumn>
|
|
525
|
+
<CapColumn span={6}>
|
|
526
|
+
<CapRow>
|
|
527
|
+
<CapColumn span={23} offset={6}>
|
|
528
|
+
{getPreviewSection()}
|
|
529
|
+
</CapColumn>
|
|
530
|
+
</CapRow>
|
|
531
|
+
</CapColumn>
|
|
532
|
+
</CapRow>
|
|
533
|
+
<div className="action-section">
|
|
534
|
+
<CapButton
|
|
535
|
+
onClick={onDoneCallback()}
|
|
536
|
+
disabled={isDoneDisabled()}
|
|
537
|
+
className="create-msg"
|
|
538
|
+
>
|
|
539
|
+
<FormattedMessage {...messages.doneButtonLabel} />
|
|
540
|
+
</CapButton>
|
|
541
|
+
{
|
|
542
|
+
!isFullMode
|
|
543
|
+
? (
|
|
544
|
+
<CapButton
|
|
545
|
+
onClick={handleClose}
|
|
546
|
+
className="cancel-msg"
|
|
547
|
+
type="secondary"
|
|
548
|
+
>
|
|
549
|
+
<FormattedMessage {...messages.cancelButtonLabel} />
|
|
550
|
+
</CapButton>
|
|
551
|
+
)
|
|
552
|
+
: null
|
|
553
|
+
}
|
|
554
|
+
</div>
|
|
555
|
+
</CapSpin>
|
|
556
|
+
</div>
|
|
557
|
+
)
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const mapStateToProps = createStructuredSelector({
|
|
561
|
+
Line: makeSelectCreateLine(),
|
|
562
|
+
lineData: makeSelectLine(),
|
|
563
|
+
Templates: makeSelectTemplates(),
|
|
564
|
+
metaEntities: makeSelectMetaEntities(),
|
|
565
|
+
injectedTags: setInjectedTags(),
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
function mapDispatchToProps(dispatch) {
|
|
569
|
+
return {
|
|
570
|
+
actions: bindActionCreators(compActions, dispatch),
|
|
571
|
+
templateActions: bindActionCreators(templateActionsConfig, dispatch),
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
export default withCreatives({
|
|
576
|
+
WrappedComponent: injectIntl(withStyles(LineContainer, style)),
|
|
577
|
+
mapStateToProps,
|
|
578
|
+
mapDispatchToProps,
|
|
579
|
+
userAuth: true,
|
|
580
|
+
});
|
|
581
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* LineContainer Messages
|
|
3
|
+
*
|
|
4
|
+
* This contains all the text for the LineContainer component.
|
|
5
|
+
*/
|
|
6
|
+
import { defineMessages } from 'react-intl';
|
|
7
|
+
const scope = `creatives.containersV2.LineContainer`;
|
|
8
|
+
|
|
9
|
+
export default defineMessages({
|
|
10
|
+
"lineAccountHeading": {
|
|
11
|
+
id: `${scope}.lineAccountHeading`,
|
|
12
|
+
defaultMessage: 'Line account',
|
|
13
|
+
},
|
|
14
|
+
"lineAccountHeadingChangeLabel": {
|
|
15
|
+
id: `${scope}.lineAccountHeadingChangeLabel`,
|
|
16
|
+
defaultMessage: 'Change',
|
|
17
|
+
},
|
|
18
|
+
"lineCreativeTitle": {
|
|
19
|
+
id: `${scope}.lineCreativeTitle`,
|
|
20
|
+
defaultMessage: 'Line creative',
|
|
21
|
+
},
|
|
22
|
+
"lineCreativeDescription": {
|
|
23
|
+
id: `${scope}.lineCreativeDescription`,
|
|
24
|
+
defaultMessage: 'Select any of the existing templates or create new',
|
|
25
|
+
},
|
|
26
|
+
"addMessageButtonLabel": {
|
|
27
|
+
id: `${scope}.addMessageButtonLabel`,
|
|
28
|
+
defaultMessage: 'Add message',
|
|
29
|
+
},
|
|
30
|
+
"doneButtonLabel": {
|
|
31
|
+
id: `${scope}.doneButtonLabel`,
|
|
32
|
+
defaultMessage: 'Done',
|
|
33
|
+
},
|
|
34
|
+
"cancelButtonLabel": {
|
|
35
|
+
id: `${scope}.cancelButtonLabel`,
|
|
36
|
+
defaultMessage: 'Cancel',
|
|
37
|
+
},
|
|
38
|
+
"lineCreateNotification": {
|
|
39
|
+
id: `${scope}.lineCreateNotification`,
|
|
40
|
+
defaultMessage: 'Line template created successfully',
|
|
41
|
+
},
|
|
42
|
+
"lineEditNotification": {
|
|
43
|
+
id: `${scope}.lineEditNotification`,
|
|
44
|
+
defaultMessage: 'Line template edited successfully',
|
|
45
|
+
},
|
|
46
|
+
"noAccountsPresentLine": {
|
|
47
|
+
id: `${scope}.noAccountsPresentLine`,
|
|
48
|
+
defaultMessage: "Line accounts are not setup for your brand",
|
|
49
|
+
},
|
|
50
|
+
"lineAccount": {
|
|
51
|
+
id: `${scope}.lineAccount`,
|
|
52
|
+
defaultMessage: 'Line account',
|
|
53
|
+
},
|
|
54
|
+
"chooseAccount": {
|
|
55
|
+
id: `${scope}.chooseAccount`,
|
|
56
|
+
defaultMessage: 'Choose the account to send content',
|
|
57
|
+
},
|
|
58
|
+
"changeAccount": {
|
|
59
|
+
id: `${scope}.changeAccount`,
|
|
60
|
+
defaultMessage: 'Change',
|
|
61
|
+
},
|
|
62
|
+
"cancelButtonLabel": {
|
|
63
|
+
id: `${scope}.cancelButtonLabel`,
|
|
64
|
+
defaultMessage: 'Cancel',
|
|
65
|
+
},
|
|
66
|
+
});
|