@capillarytech/creatives-library 7.17.116 → 7.17.118-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/containers/App/constants.js +1 -0
- package/package.json +1 -1
- package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +16 -12
- package/utils/common.js +5 -0
- package/v2Components/CapImageUpload/constants.js +6 -0
- package/v2Components/CapImageUpload/index.js +15 -16
- package/v2Components/CapImageUpload/messages.js +1 -5
- package/v2Components/CapVideoUpload/constants.js +5 -0
- package/v2Components/CapVideoUpload/index.js +28 -8
- package/v2Components/CapVideoUpload/index.scss +4 -1
- package/v2Components/CapVideoUpload/messages.js +4 -4
- package/v2Components/FormBuilder/index.js +19 -1
- package/v2Components/FormBuilder/messages.js +4 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +21 -0
- package/v2Components/TemplatePreview/index.js +56 -45
- package/v2Containers/CreativesContainer/SlideBoxContent.js +10 -4
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +1 -0
- package/v2Containers/CreativesContainer/messages.js +4 -0
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +11 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +225 -0
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +35 -20
- package/v2Containers/Templates/_templates.scss +9 -4
- package/v2Containers/Templates/index.js +29 -8
- package/v2Containers/Viber/constants.js +58 -0
- package/v2Containers/Viber/index.js +409 -421
- package/v2Containers/Viber/index.scss +113 -0
- package/v2Containers/Viber/messages.js +68 -0
- package/v2Containers/Viber/style.js +20 -0
- package/v2Containers/Viber/tests/index.test.js +297 -0
- package/v2Containers/Viber/tests/mockData.js +134 -0
|
@@ -16,6 +16,7 @@ export const BADGES_UI_ENABLED = 'BADGES_UI_ENABLED';
|
|
|
16
16
|
export const JP_LOCALE_HIDE_FEATURE = 'JP_LOCALE_HIDE_FEATURE';
|
|
17
17
|
export const ENABLE_WECHAT = 'ENABLE_WECHAT';
|
|
18
18
|
export const ENABLE_CUSTOMER_BARCODE_TAG = "ENABLE_CUSTOMER_BARCODE_TAG";
|
|
19
|
+
export const EMAIL_UNSUBSCRIBE_TAG_MANDATORY = "EMAIL_UNSUBSCRIBE_TAG_MANDATORY";
|
|
19
20
|
|
|
20
21
|
export const CARD_RELATED_TAGS = [
|
|
21
22
|
'card_series',
|
package/package.json
CHANGED
|
@@ -273,12 +273,8 @@ describe("Creatives testing template creation", () => {
|
|
|
273
273
|
fireEvent.change(templateNameInput, {
|
|
274
274
|
target: { value: 'viber_test_template' },
|
|
275
275
|
});
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
/Text message/,
|
|
279
|
-
{},
|
|
280
|
-
);
|
|
281
|
-
const msgBox = templateTextInput.parentElement.nextSibling.firstChild;
|
|
276
|
+
const msgBox = screen.getByPlaceholderText(/Enter message/i);
|
|
277
|
+
msgBox.focus();
|
|
282
278
|
//Enter a template text message
|
|
283
279
|
fireEvent.change(msgBox, {
|
|
284
280
|
target: { value: 'viber_template_message' },
|
|
@@ -306,24 +302,32 @@ describe("Creatives testing template creation", () => {
|
|
|
306
302
|
// first click opens the popup, and second click closes it, clicking twice is intentional
|
|
307
303
|
userEvent.click(addLabel);
|
|
308
304
|
userEvent.click(addLabel);
|
|
305
|
+
const imageRadio = creativesScreen.getByRole('radio', {name: /image/i});
|
|
306
|
+
fireEvent.click(imageRadio);
|
|
309
307
|
const imageUploader = creativesScreen.getByRole('button', {
|
|
310
|
-
name: /drag and drop image here or
|
|
308
|
+
name: /drag and drop image here or select from computer gallery/i,
|
|
311
309
|
});
|
|
312
310
|
expect(within(imageUploader).getByRole('button', {
|
|
313
|
-
name: /
|
|
311
|
+
name: /select from computer/i,
|
|
314
312
|
})).toBeInTheDocument();
|
|
315
313
|
const galleryBtn = within(imageUploader).getByRole('button', {
|
|
316
314
|
name: globalMessages.gallery.defaultMessage,
|
|
317
315
|
});
|
|
318
316
|
|
|
319
317
|
//configuring CTA button
|
|
320
|
-
const
|
|
321
|
-
|
|
318
|
+
const ctaRadioBtn = creativesScreen.getByRole('radio', {
|
|
319
|
+
name: /call to action create a button that lets customers respond to your messages or take action/i,
|
|
320
|
+
});
|
|
321
|
+
fireEvent.click(ctaRadioBtn);
|
|
322
|
+
const btnTextBox = await creativesScreen.findByPlaceholderText(
|
|
323
|
+
'Enter button text',
|
|
324
|
+
);
|
|
322
325
|
fireEvent.change(btnTextBox, {
|
|
323
326
|
target: { value: 'button' },
|
|
324
327
|
});
|
|
325
|
-
const
|
|
326
|
-
|
|
328
|
+
const btnUrlBox = await creativesScreen.findByPlaceholderText(
|
|
329
|
+
'Enter button url',
|
|
330
|
+
);
|
|
327
331
|
fireEvent.change(btnUrlBox, {
|
|
328
332
|
target: { value: 'button' },
|
|
329
333
|
});
|
package/utils/common.js
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
ENABLE_CUSTOMER_BARCODE_TAG,
|
|
19
19
|
BADGES_UI_ENABLED,
|
|
20
20
|
BADGES_ENROLL,
|
|
21
|
+
EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
|
|
21
22
|
BADGES_ISSUE,
|
|
22
23
|
ENABLE_WECHAT,
|
|
23
24
|
} from '../containers/App/constants';
|
|
@@ -112,6 +113,10 @@ export const hasCustomerBarcodeFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
|
112
113
|
ENABLE_CUSTOMER_BARCODE_TAG,
|
|
113
114
|
);
|
|
114
115
|
|
|
116
|
+
export const isEmailUnsubscribeTagMandatory = Auth.hasFeatureAccess.bind(
|
|
117
|
+
null,
|
|
118
|
+
EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
|
|
119
|
+
);
|
|
115
120
|
//filtering tags based on scope
|
|
116
121
|
export const filterTags = (tagsToFilter, tagsList) => tagsList?.filter(
|
|
117
122
|
(tag) => !tagsToFilter?.includes(tag?.definition?.value)
|
|
@@ -20,7 +20,8 @@ import { injectIntl, FormattedMessage, intlShape} from 'react-intl';
|
|
|
20
20
|
import { isEmpty, get } from 'lodash';
|
|
21
21
|
import './index.scss';
|
|
22
22
|
import Gallery from '../../v2Containers/Assets/Gallery';
|
|
23
|
-
import {
|
|
23
|
+
import { MAX_SUPPORTED_IMAGE_SIZE } from './constants';
|
|
24
|
+
import { FACEBOOK, INAPP, RCS, WHATSAPP, VIBER } from "../../v2Containers/CreativesContainer/constants";
|
|
24
25
|
|
|
25
26
|
import messages from './messages';
|
|
26
27
|
function CapImageUpload(props) {
|
|
@@ -173,6 +174,17 @@ function CapImageUpload(props) {
|
|
|
173
174
|
);
|
|
174
175
|
}, []);
|
|
175
176
|
|
|
177
|
+
const getImageSizeLabel = () => (
|
|
178
|
+
<CapHeadingSpan type="label2">
|
|
179
|
+
<FormattedMessage
|
|
180
|
+
{...messages.imageSize}
|
|
181
|
+
values={{
|
|
182
|
+
size: MAX_SUPPORTED_IMAGE_SIZE[channel],
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
</CapHeadingSpan>
|
|
186
|
+
);
|
|
187
|
+
|
|
176
188
|
const getImageSection = useCallback(() => {
|
|
177
189
|
if (imageSrc === "") {
|
|
178
190
|
return (<>
|
|
@@ -244,9 +256,7 @@ function CapImageUpload(props) {
|
|
|
244
256
|
<div className="image-info-wrapper">
|
|
245
257
|
{channel === WHATSAPP && (
|
|
246
258
|
<>
|
|
247
|
-
|
|
248
|
-
<FormattedMessage {...messages.maxImageSize} />
|
|
249
|
-
</CapHeadingSpan>
|
|
259
|
+
{getImageSizeLabel}
|
|
250
260
|
<CapHeadingSpan type="label2">
|
|
251
261
|
<FormattedMessage {...messages.whatsappAspectRatio} />
|
|
252
262
|
</CapHeadingSpan>
|
|
@@ -262,18 +272,7 @@ function CapImageUpload(props) {
|
|
|
262
272
|
<FormattedMessage {...messages.aspectRatio} />
|
|
263
273
|
</CapHeadingSpan>
|
|
264
274
|
)}
|
|
265
|
-
{
|
|
266
|
-
<CapHeadingSpan type="label2" className="image-size">
|
|
267
|
-
<FormattedMessage {...messages.imageSize} />
|
|
268
|
-
</CapHeadingSpan>
|
|
269
|
-
)}
|
|
270
|
-
{
|
|
271
|
-
channel === INAPP && (
|
|
272
|
-
<CapHeadingSpan type="label2" className="image-size">
|
|
273
|
-
<FormattedMessage {...messages.maxImageSize} />
|
|
274
|
-
</CapHeadingSpan>
|
|
275
|
-
)
|
|
276
|
-
}
|
|
275
|
+
{[RCS, VIBER, INAPP].includes(channel) && getImageSizeLabel()}
|
|
277
276
|
<CapHeadingSpan type="label2" className="image-format">
|
|
278
277
|
{channel === INAPP ? <FormattedMessage {...messages.format2} /> : <FormattedMessage {...messages.format} />}
|
|
279
278
|
</CapHeadingSpan>
|
|
@@ -2,10 +2,6 @@ import { defineMessages } from 'react-intl';
|
|
|
2
2
|
const scope = `creatives.componentsV2.CapImageUpload`;
|
|
3
3
|
|
|
4
4
|
export default defineMessages({
|
|
5
|
-
maxImageSize: {
|
|
6
|
-
id: `${scope}.maxImageSize`,
|
|
7
|
-
defaultMessage: 'Size upto: 5MB',
|
|
8
|
-
},
|
|
9
5
|
whatsappAspectRatio: {
|
|
10
6
|
id: `${scope}.whatsappAspectRatio`,
|
|
11
7
|
defaultMessage: 'Max aspect ratio: 1.91:1',
|
|
@@ -61,6 +57,6 @@ export default defineMessages({
|
|
|
61
57
|
},
|
|
62
58
|
imageSize: {
|
|
63
59
|
id: `${scope}.imageSize`,
|
|
64
|
-
defaultMessage: 'Size upto:
|
|
60
|
+
defaultMessage: 'Size upto: {size}MB',
|
|
65
61
|
},
|
|
66
62
|
});
|
|
@@ -19,8 +19,9 @@ import {
|
|
|
19
19
|
} from '@capillarytech/cap-ui-library';
|
|
20
20
|
import messages from './messages';
|
|
21
21
|
import {bytes2Size, getDecodedFileName} from '../../utils/common';
|
|
22
|
-
import { WHATSAPP } from './constants';
|
|
22
|
+
import { SUPPORTED_FILE_FORMATS, WHATSAPP, DEFAULT } from './constants';
|
|
23
23
|
import './index.scss';
|
|
24
|
+
import { VIBER } from '../../v2Containers/CreativesContainer/constants';
|
|
24
25
|
|
|
25
26
|
function CapVideoUpload(props) {
|
|
26
27
|
const {
|
|
@@ -230,6 +231,7 @@ function CapVideoUpload(props) {
|
|
|
230
231
|
videoWidth: metaVideoWidth,
|
|
231
232
|
previewUrl,
|
|
232
233
|
fileHandle,
|
|
234
|
+
videoDuration,
|
|
233
235
|
}
|
|
234
236
|
);
|
|
235
237
|
}
|
|
@@ -276,6 +278,16 @@ function CapVideoUpload(props) {
|
|
|
276
278
|
</Fragment>
|
|
277
279
|
);
|
|
278
280
|
};
|
|
281
|
+
|
|
282
|
+
const getVideoSizeDescription = () => (
|
|
283
|
+
<CapHeading.CapHeadingSpan type="label2">
|
|
284
|
+
<FormattedMessage
|
|
285
|
+
{...messages.videoSizeDescription}
|
|
286
|
+
values={{ size: bytes2Size(videoSize) }}
|
|
287
|
+
/>
|
|
288
|
+
</CapHeading.CapHeadingSpan>
|
|
289
|
+
);
|
|
290
|
+
|
|
279
291
|
return (
|
|
280
292
|
<CapSpin spinning={isSpinning}>
|
|
281
293
|
<div style={style} className="cap-custom-video-upload">
|
|
@@ -295,26 +307,34 @@ function CapVideoUpload(props) {
|
|
|
295
307
|
onClose={() => updateTemplateDrawerRequirement(false)}
|
|
296
308
|
/>
|
|
297
309
|
</form>
|
|
298
|
-
{channel
|
|
310
|
+
{![WHATSAPP, VIBER].includes(channel) &&
|
|
299
311
|
<>
|
|
300
312
|
<CapHeading.CapHeadingSpan type="h6" className="video-description">
|
|
301
313
|
<FormattedMessage {...messages.videoRatioDescription} />
|
|
302
314
|
</CapHeading.CapHeadingSpan>
|
|
303
315
|
{' '}
|
|
304
316
|
<CapHeading.CapHeadingSpan type="h6" className="video-description file-format">
|
|
305
|
-
<FormattedMessage {...messages.fileFormat} />
|
|
306
|
-
|
|
317
|
+
<FormattedMessage {...messages.fileFormat} values={{ format: SUPPORTED_FILE_FORMATS[DEFAULT] }} />
|
|
307
318
|
</CapHeading.CapHeadingSpan>
|
|
308
319
|
<CapHeading.CapHeadingSpan type="h6" className="video-description video-details">
|
|
309
320
|
<FormattedMessage {...messages.videoSizeDescription} values={{size: bytes2Size(videoSize)}} />
|
|
310
321
|
</CapHeading.CapHeadingSpan>
|
|
311
|
-
</>
|
|
322
|
+
</>}
|
|
323
|
+
{channel === WHATSAPP &&
|
|
312
324
|
<>
|
|
313
|
-
|
|
314
|
-
|
|
325
|
+
{getVideoSizeDescription()}
|
|
326
|
+
<CapHeading.CapHeadingSpan type="label2" className="whatsapp-format">
|
|
327
|
+
<FormattedMessage {...messages.fileFormat} values={{ format: SUPPORTED_FILE_FORMATS[DEFAULT] }} />
|
|
315
328
|
</CapHeading.CapHeadingSpan>
|
|
329
|
+
</>}
|
|
330
|
+
{channel === VIBER &&
|
|
331
|
+
<>
|
|
332
|
+
{getVideoSizeDescription()}
|
|
316
333
|
<CapHeading.CapHeadingSpan type="label2" className="whatsapp-format">
|
|
317
|
-
<FormattedMessage {...messages.
|
|
334
|
+
<FormattedMessage {...messages.fileFormat} values={{ format: SUPPORTED_FILE_FORMATS[channel] }} />
|
|
335
|
+
</CapHeading.CapHeadingSpan>
|
|
336
|
+
<CapHeading.CapHeadingSpan type="label2" className="video-duration">
|
|
337
|
+
<FormattedMessage {...messages.viberMaxDuration} />
|
|
318
338
|
</CapHeading.CapHeadingSpan>
|
|
319
339
|
</>}
|
|
320
340
|
</div>
|
|
@@ -57,10 +57,10 @@ export default defineMessages({
|
|
|
57
57
|
},
|
|
58
58
|
fileFormat: {
|
|
59
59
|
id: `${scope}.fileFormat`,
|
|
60
|
-
defaultMessage: 'Format:
|
|
60
|
+
defaultMessage: 'Format: {format}',
|
|
61
61
|
},
|
|
62
|
-
|
|
63
|
-
id: `${scope}.
|
|
64
|
-
defaultMessage: '
|
|
62
|
+
viberMaxDuration: {
|
|
63
|
+
id: `${scope}.viberMaxDuration`,
|
|
64
|
+
defaultMessage: 'Max Duration: 600 seconds',
|
|
65
65
|
},
|
|
66
66
|
});
|
|
@@ -55,6 +55,7 @@ import { AI_SUGGESTION_API_URL, CONTENT_RECOMMENDATION_BOT } from './constants';
|
|
|
55
55
|
import { GET_TRANSLATION_MAPPED } from '../../containers/TagList/constants';
|
|
56
56
|
import moment from 'moment';
|
|
57
57
|
import { CUSTOMER_BARCODE_TAG , COPY_OF} from '../../containers/App/constants';
|
|
58
|
+
import { isEmailUnsubscribeTagMandatory } from '../../utils/common';
|
|
58
59
|
const TabPane = Tabs.TabPane;
|
|
59
60
|
const {Column} = Table;
|
|
60
61
|
const {TextArea} = CapInput;
|
|
@@ -989,6 +990,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
989
990
|
if (tagValidationResponse.isBraceError){
|
|
990
991
|
errorString += this.props.intl.formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
991
992
|
}
|
|
993
|
+
if (tagValidationResponse?.isContentEmpty) {
|
|
994
|
+
errorString += this.props.intl.formatMessage(messages.emailBodyEmptyError);
|
|
995
|
+
}
|
|
992
996
|
}
|
|
993
997
|
}
|
|
994
998
|
}
|
|
@@ -1127,6 +1131,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1127
1131
|
response.missingTags = [];
|
|
1128
1132
|
response.unsupportedTags = [];
|
|
1129
1133
|
response.isBraceError = false;
|
|
1134
|
+
response.isContentEmpty = false;
|
|
1135
|
+
const contentForValidation = isEmail ? convert(content) : content ;
|
|
1130
1136
|
if(tags && tags.length) {
|
|
1131
1137
|
_.forEach(tags, (tag) => {
|
|
1132
1138
|
_.forEach(tag.definition.supportedModules, (module) => {
|
|
@@ -1144,6 +1150,19 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1144
1150
|
let matchImg = regexImgSrc.exec(content);
|
|
1145
1151
|
const regexCustomerBarcode = /{{customer_barcode}}(?![^<]*>)/g;
|
|
1146
1152
|
let matchCustomerBarcode = regexCustomerBarcode.exec(content);
|
|
1153
|
+
// \S matches anything other than a space, a tab, a newline, or a carriage return.
|
|
1154
|
+
const validString= /\S/.test(contentForValidation);
|
|
1155
|
+
if (isEmailUnsubscribeTagMandatory() && isEmail) {
|
|
1156
|
+
const missingTagIndex = response?.missingTags?.indexOf("unsubscribe");
|
|
1157
|
+
if(missingTagIndex != -1) { //skip regex tags for mandatory tags also
|
|
1158
|
+
response?.missingTags?.splice(missingTagIndex, 1);
|
|
1159
|
+
if (validString) {
|
|
1160
|
+
response.valid = true;
|
|
1161
|
+
} else {
|
|
1162
|
+
response.isContentEmpty = true;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1147
1166
|
while (match !== null ) {
|
|
1148
1167
|
const tagValue = match[0].substring(this.indexOfEnd(match[0], '{{'), match[0].indexOf('}}'));
|
|
1149
1168
|
match = regex.exec(content);
|
|
@@ -1177,7 +1196,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1177
1196
|
}
|
|
1178
1197
|
}
|
|
1179
1198
|
}
|
|
1180
|
-
const contentForValidation = isEmail ? convert(content) : content ;
|
|
1181
1199
|
if(!validateIfTagClosed(contentForValidation)){
|
|
1182
1200
|
response.isBraceError = true;
|
|
1183
1201
|
response.valid = false;
|
|
@@ -86,4 +86,8 @@ export default defineMessages({
|
|
|
86
86
|
id: 'creatives.componentsV2.FormBuilder.imageReUpload',
|
|
87
87
|
defaultMessage: 'Re upload',
|
|
88
88
|
},
|
|
89
|
+
emailBodyEmptyError: {
|
|
90
|
+
id: 'creatives.componentsV2.FormBuilder.emailBodyEmptyError',
|
|
91
|
+
defaultMessage: 'Email body cannot be empty',
|
|
92
|
+
},
|
|
89
93
|
});
|
|
@@ -991,4 +991,25 @@
|
|
|
991
991
|
.media-img-inapp {
|
|
992
992
|
width: 100%;
|
|
993
993
|
height: 100%;
|
|
994
|
+
}
|
|
995
|
+
.empty-placeholder {
|
|
996
|
+
padding-bottom: $CAP_SPACE_16;
|
|
997
|
+
}
|
|
998
|
+
.viber-button-base {
|
|
999
|
+
border-radius: $CAP_SPACE_16;
|
|
1000
|
+
background-color: $CAP_PURPLE01;
|
|
1001
|
+
margin-top: $CAP_SPACE_12;
|
|
1002
|
+
text-align: center;
|
|
1003
|
+
width: 8.75rem;
|
|
1004
|
+
height: $CAP_SPACE_20;
|
|
1005
|
+
margin-left: $CAP_SPACE_08;
|
|
1006
|
+
}
|
|
1007
|
+
.viber-button-card-text {
|
|
1008
|
+
font-size: $CAP_SPACE_12;
|
|
1009
|
+
font-weight: 500;
|
|
1010
|
+
display: -webkit-box;
|
|
1011
|
+
-webkit-line-clamp: 1;
|
|
1012
|
+
-webkit-box-orient: vertical;
|
|
1013
|
+
overflow: hidden;
|
|
1014
|
+
color: $CAP_WHITE;
|
|
994
1015
|
}
|
|
@@ -11,7 +11,17 @@ import _ from 'lodash';
|
|
|
11
11
|
import { injectIntl, FormattedMessage, intlShape } from 'react-intl';
|
|
12
12
|
// import styled from 'styled-components';
|
|
13
13
|
import { CapColumn, CapRow, CapHeading, CapIcon, CapButton, CapImage, CapLabel, CapDivider, CapTooltip } from '@capillarytech/cap-ui-library';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
CAP_COLOR_03,
|
|
16
|
+
CAP_WHITE,
|
|
17
|
+
FONT_COLOR_01,
|
|
18
|
+
CAP_G06,
|
|
19
|
+
CAP_G15,
|
|
20
|
+
CAP_PURPLE01,
|
|
21
|
+
CAP_G16,
|
|
22
|
+
CAP_SPACE_08,
|
|
23
|
+
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
24
|
+
import isEmpty from 'lodash/isEmpty';
|
|
15
25
|
import './_templatePreview.scss';
|
|
16
26
|
import {updateCharCount} from '../../utils/smsCharCountV2';
|
|
17
27
|
import messages from './messages';
|
|
@@ -36,6 +46,13 @@ import inAppMobileIOSFull from './assets/images/inapp_mobile_ios_full.svg';
|
|
|
36
46
|
import videoPlay from '../../assets/videoPlay.svg';
|
|
37
47
|
import zaloMessage from '../../v2Containers/Zalo/messages';
|
|
38
48
|
import { handlePreviewInNewTab } from '../../utils/common';
|
|
49
|
+
import { TEMPLATE, IMAGE_CAROUSEL, IMAGE, STICKER, TEXT, IMAGE_MAP, VIDEO } from '../../v2Containers/Line/Container/constants';
|
|
50
|
+
import CapFacebookPreview from '../../v2Containers/CapFacebookPreview';
|
|
51
|
+
import WhatsappStatusContainer from '../WhatsappStatusContainer';
|
|
52
|
+
import { getWhatsappQuickReply } from '../../v2Containers/Whatsapp/utils';
|
|
53
|
+
import { QUICK_REPLY } from '../../v2Containers/Whatsapp/constants';
|
|
54
|
+
import { ANDROID, INAPP_MESSAGE_LAYOUT_TYPES } from '../../v2Containers/InApp/constants';
|
|
55
|
+
|
|
39
56
|
const wechatBodyNew = require('./assets/images/wechat_mobile_android.svg');
|
|
40
57
|
const smsMobileAndroid = require('./assets/images/sms_mobile_android.svg');
|
|
41
58
|
const smsMobileIos = require('./assets/images/sms_mobile_ios.svg');
|
|
@@ -49,23 +66,6 @@ const lineVideoPlaceholder = require('../../assets/rich-video-placeholder.svg');
|
|
|
49
66
|
const androidPushMessagePhone = require('./assets/images/androidPushMessage.svg');
|
|
50
67
|
const iPhonePushMessagePhone = require('./assets/images/iPhonePushMessage.svg');
|
|
51
68
|
|
|
52
|
-
import {
|
|
53
|
-
CAP_COLOR_03,
|
|
54
|
-
CAP_WHITE,
|
|
55
|
-
FONT_COLOR_01,
|
|
56
|
-
CAP_G06,
|
|
57
|
-
CAP_G15,
|
|
58
|
-
CAP_PURPLE01,
|
|
59
|
-
CAP_G16,
|
|
60
|
-
CAP_SPACE_08,
|
|
61
|
-
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
62
|
-
import { TEMPLATE, IMAGE_CAROUSEL, IMAGE, STICKER, TEXT, IMAGE_MAP, VIDEO } from '../../v2Containers/Line/Container/constants';
|
|
63
|
-
import CapFacebookPreview from '../../v2Containers/CapFacebookPreview';
|
|
64
|
-
import WhatsappStatusContainer from '../WhatsappStatusContainer';
|
|
65
|
-
import { getWhatsappQuickReply } from '../../v2Containers/Whatsapp/utils';
|
|
66
|
-
import { QUICK_REPLY } from '../../v2Containers/Whatsapp/constants';
|
|
67
|
-
import { ANDROID, INAPP_MESSAGE_LAYOUT_TYPES } from '../../v2Containers/InApp/constants';
|
|
68
|
-
|
|
69
69
|
export class TemplatePreview extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
70
70
|
onPreviewContentClicked = (channel) => {
|
|
71
71
|
const IOSContent = (this.props.templateDataRaw && this.props.templateDataRaw.versions.base.IOS) ||
|
|
@@ -184,8 +184,14 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
184
184
|
} = this.props;
|
|
185
185
|
let content = channel && channel.toLowerCase() === 'sms' ? [this.props.content] : this.props.content;
|
|
186
186
|
const { formatMessage } = intl;
|
|
187
|
-
const {
|
|
187
|
+
const { rcsPreviewContent, inAppPreviewContent, viberPreviewContent } = content || {};
|
|
188
188
|
const { rcsImageSrc, rcsTitle, rcsDesc, buttonText: rcsButtonText } = rcsPreviewContent || {};
|
|
189
|
+
const {
|
|
190
|
+
videoParams,
|
|
191
|
+
imageURL,
|
|
192
|
+
buttonText: viberButtonText,
|
|
193
|
+
messageContent: viberMessageContent,
|
|
194
|
+
} = viberPreviewContent || {};
|
|
189
195
|
const {mediaPreview = {}, templateTitle = "", templateMsg = "", ctaData} = inAppPreviewContent || {};
|
|
190
196
|
let smsDetails = {};
|
|
191
197
|
// let smsText = '';
|
|
@@ -920,35 +926,40 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
920
926
|
}}
|
|
921
927
|
/>
|
|
922
928
|
)}
|
|
923
|
-
{/*
|
|
924
|
-
{
|
|
925
|
-
<
|
|
926
|
-
|
|
927
|
-
"border-radius": "16px",
|
|
928
|
-
"background-color": CAP_PURPLE01,
|
|
929
|
-
"margin-top": "14px",
|
|
930
|
-
"text-align": "center",
|
|
931
|
-
width: "140px",
|
|
932
|
-
height: "20px",
|
|
933
|
-
"margin-left": "8px",
|
|
934
|
-
}}
|
|
929
|
+
{/* Video Viber preview */}
|
|
930
|
+
{videoParams?.viberVideoSrc && (
|
|
931
|
+
<CapTooltip
|
|
932
|
+
title={formatMessage(messages.videoPreviewTooltip)}
|
|
935
933
|
>
|
|
936
|
-
<
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
"
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
934
|
+
<div className="video-preview">
|
|
935
|
+
<CapImage
|
|
936
|
+
src={videoParams?.viberVideoPreviewImg}
|
|
937
|
+
className="whatsapp-image"
|
|
938
|
+
alt={formatMessage(messages.previewGenerated)}
|
|
939
|
+
rest={{
|
|
940
|
+
style: {
|
|
941
|
+
maxWidth: "100%",
|
|
942
|
+
marginBottom: 5,
|
|
943
|
+
},
|
|
944
|
+
}}
|
|
945
|
+
/>
|
|
946
|
+
<div className="icon-position">
|
|
947
|
+
<CapImage
|
|
948
|
+
className="video-icon"
|
|
949
|
+
src={videoPlay} />
|
|
950
|
+
</div>
|
|
951
|
+
</div>
|
|
952
|
+
</CapTooltip>
|
|
953
|
+
)}
|
|
954
|
+
{/* button viber preview */}
|
|
955
|
+
{viberButtonText && (
|
|
956
|
+
<CapLabel className="viber-button-base">
|
|
957
|
+
<p className="viber-button-card-text">
|
|
958
|
+
{viberButtonText || ""}
|
|
948
959
|
</p>
|
|
949
|
-
</
|
|
960
|
+
</CapLabel>
|
|
950
961
|
)}
|
|
951
|
-
<div
|
|
962
|
+
<div className="empty-placeholder"></div>
|
|
952
963
|
</div>
|
|
953
964
|
</div>
|
|
954
965
|
</div>
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import get from 'lodash/get';
|
|
5
|
+
import isEmpty from 'lodash/isEmpty';
|
|
5
6
|
import cloneDeep from 'lodash/cloneDeep';
|
|
6
7
|
import TemplatesV2 from '../TemplatesV2';
|
|
7
8
|
import TemplatePreview from '../../v2Components/TemplatePreview';
|
|
@@ -308,11 +309,16 @@ export function SlideBoxContent(props) {
|
|
|
308
309
|
}
|
|
309
310
|
case constants.VIBER: {
|
|
310
311
|
const template = cloneDeep(templateDataObject);
|
|
311
|
-
const { text = "",
|
|
312
|
+
const { text = "", button = {}, image = {}, video = {} } = get(template, 'versions.base.content.content', {});
|
|
313
|
+
const { url: viberImageUrl = "" } = image;
|
|
314
|
+
const { url: viberVideoUrl = "", thumbnailUrl = '' } = video;
|
|
312
315
|
template.content = {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
+
viberPreviewContent: {
|
|
317
|
+
...(!isEmpty(image) && { imageURL: viberImageUrl }),
|
|
318
|
+
...(!isEmpty(video) && { videoParams: { viberVideoSrc: viberVideoUrl, viberVideoPreviewImg: thumbnailUrl }}),
|
|
319
|
+
buttonText: button?.text,
|
|
320
|
+
messageContent: text,
|
|
321
|
+
},
|
|
316
322
|
};
|
|
317
323
|
return template.content;
|
|
318
324
|
}
|
|
@@ -70,6 +70,7 @@ export function SlideBoxHeader(props) {
|
|
|
70
70
|
whatsapp: <FormattedMessage {...messages.whatsappTemplate} />,
|
|
71
71
|
rcs: <FormattedMessage {...messages.rcsCreative} />,
|
|
72
72
|
zalo: <FormattedMessage {...messages.zaloTemplate} />,
|
|
73
|
+
viber: <FormattedMessage {...messages.viberTemplate} />,
|
|
73
74
|
};
|
|
74
75
|
return labels[currentChannel.toLowerCase()];
|
|
75
76
|
};
|
|
@@ -322,6 +322,10 @@ export default defineMessages({
|
|
|
322
322
|
id: `${scope}.zaloTemplate`,
|
|
323
323
|
defaultMessage: `Zalo template`,
|
|
324
324
|
},
|
|
325
|
+
"viberTemplate": {
|
|
326
|
+
id: `${scope}.viberTemplate`,
|
|
327
|
+
defaultMessage: `Viber template`,
|
|
328
|
+
},
|
|
325
329
|
"learnTips": {
|
|
326
330
|
id: `${scope}.learnTips`,
|
|
327
331
|
defaultMessage: `Learn tips to get approved`,
|
|
@@ -3,6 +3,7 @@ import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
|
|
|
3
3
|
|
|
4
4
|
import { SlideBoxContent } from '../SlideBoxContent';
|
|
5
5
|
import mockdata from '../../mockdata';
|
|
6
|
+
import { templateDetailsImage, templateDetailsVideo, templateDetailsText, templateDetails_ } from '../../Viber/tests/mockData';
|
|
6
7
|
|
|
7
8
|
const {
|
|
8
9
|
whatsappEditTemplateData,
|
|
@@ -86,4 +87,14 @@ describe('Test SlideBoxContent container', () => {
|
|
|
86
87
|
renderFunction('LINE', 'preview', linePreviewTemplateData2);
|
|
87
88
|
expect(renderedComponent).toMatchSnapshot();
|
|
88
89
|
});
|
|
90
|
+
it('Should render correct component for viber channel preview mode', () => {
|
|
91
|
+
renderFunction('VIBER', 'preview', templateDetails_);
|
|
92
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
93
|
+
renderFunction('VIBER', 'preview', templateDetailsImage);
|
|
94
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
95
|
+
renderFunction('VIBER', 'preview', templateDetailsVideo);
|
|
96
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
97
|
+
renderFunction('VIBER', 'preview', templateDetailsText);
|
|
98
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
99
|
+
});
|
|
89
100
|
});
|