@capillarytech/creatives-library 7.17.118 → 7.17.119

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.
Files changed (29) hide show
  1. package/package.json +1 -1
  2. package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +16 -12
  3. package/v2Components/CapImageUpload/constants.js +6 -0
  4. package/v2Components/CapImageUpload/index.js +16 -17
  5. package/v2Components/CapImageUpload/index.scss +3 -0
  6. package/v2Components/CapImageUpload/messages.js +3 -7
  7. package/v2Components/CapVideoUpload/constants.js +6 -0
  8. package/v2Components/CapVideoUpload/index.js +46 -20
  9. package/v2Components/CapVideoUpload/index.scss +4 -1
  10. package/v2Components/CapVideoUpload/messages.js +10 -6
  11. package/v2Components/FormBuilder/constants.js +0 -2
  12. package/v2Components/FormBuilder/index.js +8 -4
  13. package/v2Components/TemplatePreview/_templatePreview.scss +21 -0
  14. package/v2Components/TemplatePreview/index.js +56 -45
  15. package/v2Containers/CreativesContainer/SlideBoxContent.js +10 -4
  16. package/v2Containers/CreativesContainer/SlideBoxHeader.js +1 -0
  17. package/v2Containers/CreativesContainer/messages.js +4 -0
  18. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +11 -0
  19. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +225 -0
  20. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +40 -25
  21. package/v2Containers/Templates/_templates.scss +9 -4
  22. package/v2Containers/Templates/index.js +29 -8
  23. package/v2Containers/Viber/constants.js +58 -0
  24. package/v2Containers/Viber/index.js +403 -421
  25. package/v2Containers/Viber/index.scss +113 -0
  26. package/v2Containers/Viber/messages.js +68 -0
  27. package/v2Containers/Viber/style.js +20 -0
  28. package/v2Containers/Viber/tests/index.test.js +297 -0
  29. package/v2Containers/Viber/tests/mockData.js +134 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.17.118",
4
+ "version": "7.17.119",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -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
- const templateTextInput = await creativesScreen.getByText(
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 your computer gallery/i,
308
+ name: /drag and drop image here or select from computer gallery/i,
311
309
  });
312
310
  expect(within(imageUploader).getByRole('button', {
313
- name: /your computer/i,
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 btnText = creativesScreen.getByText(/button text/i);
321
- const btnTextBox = btnText.nextSibling.firstChild;
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 btnUrl = creativesScreen.getByText(/button url/i);
326
- const btnUrlBox = btnUrl.nextSibling.firstChild;
328
+ const btnUrlBox = await creativesScreen.findByPlaceholderText(
329
+ 'Enter button url',
330
+ );
327
331
  fireEvent.change(btnUrlBox, {
328
332
  target: { value: 'button' },
329
333
  });
@@ -0,0 +1,6 @@
1
+ export const MAX_SUPPORTED_IMAGE_SIZE = {
2
+ VIBER: 10,
3
+ RCS: 2,
4
+ INAPP: 5,
5
+ WHATSAPP: 5,
6
+ };
@@ -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 { FACEBOOK, INAPP, RCS, WHATSAPP } from "../../v2Containers/CreativesContainer/constants";
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,12 +174,23 @@ function CapImageUpload(props) {
173
174
  );
174
175
  }, []);
175
176
 
177
+ const getImageSizeLabel = () => (
178
+ <CapHeadingSpan type="label2">
179
+ <FormattedMessage
180
+ {...messages.channelImageSize}
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 (<>
179
191
  <CapUploader.CapDragger
180
192
  customRequest={capUploaderCustomRequest}
181
- className="form-builder-dragger"
193
+ className="form-builder-dragger grey-background"
182
194
  showUploadList={!isImageError}
183
195
  >
184
196
  <CapHeading className="dragger-title" type="h7">
@@ -244,9 +256,7 @@ function CapImageUpload(props) {
244
256
  <div className="image-info-wrapper">
245
257
  {channel === WHATSAPP && (
246
258
  <>
247
- <CapHeadingSpan type="label2">
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
- {channel === RCS && (
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>
@@ -14,4 +14,7 @@ $classPrefix: cap-custom-image-upload;
14
14
  justify-content: space-between;
15
15
  margin-top: 8px;
16
16
  }
17
+ .grey-background div {
18
+ background: $CAP_G10;
19
+ }
17
20
  }
@@ -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',
@@ -59,8 +55,8 @@ export default defineMessages({
59
55
  id: `${scope}.aspectRatio`,
60
56
  defaultMessage: 'Aspect ratio: 1:1',
61
57
  },
62
- imageSize: {
63
- id: `${scope}.imageSize`,
64
- defaultMessage: 'Size upto: 2MB',
58
+ channelImageSize: {
59
+ id: `${scope}.channelImageSize`,
60
+ defaultMessage: 'Size upto: {size}MB',
65
61
  },
66
62
  });
@@ -1 +1,7 @@
1
1
  export const WHATSAPP = 'WHATSAPP';
2
+ export const DEFAULT = 'DEFAULT';
3
+ export const SUPPORTED_FILE_FORMATS = {
4
+ VIBER: '3GP, MP4, MOV, M4V',
5
+ DEFAULT: 'MP4',
6
+ };
7
+ export const VIBER_MAX_DURATION = 600; // seconds
@@ -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, VIBER_MAX_DURATION } from './constants';
23
23
  import './index.scss';
24
+ import { VIBER } from '../../v2Containers/CreativesContainer/constants';
24
25
 
25
26
  function CapVideoUpload(props) {
26
27
  const {
@@ -41,7 +42,7 @@ function CapVideoUpload(props) {
41
42
  } = props;
42
43
  const [isVideoError, updateVideoErrorMessage] = useState(false);
43
44
  const [isVideo, updateVideoStatus] = useState(false);
44
- const [videoDuration, updateVideoDuration] = useState('');
45
+ const [videoDuration, updateVideoDuration] = useState(null);
45
46
  const [isPlaying, updateIsPlaying] = useState(false);
46
47
  const [isSpinning, setSpinning] = useState(false);
47
48
 
@@ -99,6 +100,7 @@ function CapVideoUpload(props) {
99
100
  videoName: metaVideoName,
100
101
  videoId: metaVideoId,
101
102
  fileHandle: karixFileHandle,
103
+ videoDuration: null,
102
104
  },
103
105
  );
104
106
  }
@@ -199,6 +201,7 @@ function CapVideoUpload(props) {
199
201
  }
200
202
  const onReUpload = () => {
201
203
  updateVideoStatus(false);
204
+ updateVideoDuration(null);
202
205
  onVideoUploadUpdateAssestList(
203
206
  index,
204
207
  {
@@ -207,7 +210,7 @@ function CapVideoUpload(props) {
207
210
  videoHeight: "",
208
211
  videoWidth: "",
209
212
  videoSrc: "",
210
- videoDuration: "",
213
+ videoDuration: null,
211
214
  videoId: "",
212
215
  fileHandle: "",
213
216
  }
@@ -217,12 +220,13 @@ function CapVideoUpload(props) {
217
220
  const updateMetadataLoaded = () => {
218
221
  const { current: { duration, videoHeight: metaVideoHeight, videoWidth: metaVideoWidth } = {} } = videoEl;
219
222
  if (duration) {
220
- const value = moment('1900-01-01 00:00:00').add(duration, 'seconds').format("HH.mm.ss"); // to get the duration of video
221
- updateVideoDuration(value);
223
+ updateVideoDuration(duration);
222
224
  if (videoWidth === undefined && videoHeight === undefined) {
223
- onVideoUploadUpdateAssestList(
224
- index,
225
- {
225
+ if (
226
+ channel !== VIBER ||
227
+ (channel === VIBER && duration <= VIBER_MAX_DURATION)
228
+ ) {
229
+ onVideoUploadUpdateAssestList(index, {
226
230
  videoSrc,
227
231
  videoId,
228
232
  videoName,
@@ -230,12 +234,16 @@ function CapVideoUpload(props) {
230
234
  videoWidth: metaVideoWidth,
231
235
  previewUrl,
232
236
  fileHandle,
233
- }
234
- );
237
+ videoDuration: duration,
238
+ });
239
+ } else {
240
+ onReUpload();
241
+ updateVideoErrorMessage(formatMessage(messages.videoDurationError));
242
+ }
235
243
  }
236
244
  }
237
245
  };
238
-
246
+ const videoDurationValue = moment('1900-01-01 00:00:00').add(videoDuration, 'seconds').format("HH.mm.ss"); // to get the duration of video
239
247
  return (
240
248
  <Fragment key={videoSrc}>
241
249
  <div style={{ overflow: 'hidden' }}>
@@ -264,11 +272,11 @@ function CapVideoUpload(props) {
264
272
  </video>
265
273
  {showVideoNameAndDuration &&
266
274
  <div className="video-info">
267
- <CapHeading type="h6">
275
+ <CapHeading type="h4">
268
276
  {getDecodedFileName(videoName)}
269
277
  </CapHeading>
270
278
  <CapHeading type="h6">
271
- {videoDuration}
279
+ {videoDurationValue}
272
280
  </CapHeading>
273
281
  </div>
274
282
  }
@@ -276,6 +284,16 @@ function CapVideoUpload(props) {
276
284
  </Fragment>
277
285
  );
278
286
  };
287
+
288
+ const getVideoSizeDescription = () => (
289
+ <CapHeading.CapHeadingSpan type="label2">
290
+ <FormattedMessage
291
+ {...messages.videoSizeDescription}
292
+ values={{ size: bytes2Size(videoSize) }}
293
+ />
294
+ </CapHeading.CapHeadingSpan>
295
+ );
296
+
279
297
  return (
280
298
  <CapSpin spinning={isSpinning}>
281
299
  <div style={style} className="cap-custom-video-upload">
@@ -295,26 +313,34 @@ function CapVideoUpload(props) {
295
313
  onClose={() => updateTemplateDrawerRequirement(false)}
296
314
  />
297
315
  </form>
298
- {channel !== WHATSAPP ?
316
+ {![WHATSAPP, VIBER].includes(channel) &&
299
317
  <>
300
318
  <CapHeading.CapHeadingSpan type="h6" className="video-description">
301
319
  <FormattedMessage {...messages.videoRatioDescription} />
302
320
  </CapHeading.CapHeadingSpan>
303
321
  {' '}
304
322
  <CapHeading.CapHeadingSpan type="h6" className="video-description file-format">
305
- <FormattedMessage {...messages.fileFormat} />
306
-
323
+ <FormattedMessage {...messages.channelFileFormat} values={{ format: SUPPORTED_FILE_FORMATS[DEFAULT] }} />
307
324
  </CapHeading.CapHeadingSpan>
308
325
  <CapHeading.CapHeadingSpan type="h6" className="video-description video-details">
309
326
  <FormattedMessage {...messages.videoSizeDescription} values={{size: bytes2Size(videoSize)}} />
310
327
  </CapHeading.CapHeadingSpan>
311
- </> :
328
+ </>}
329
+ {channel === WHATSAPP &&
312
330
  <>
313
- <CapHeading.CapHeadingSpan type="label2" className="">
314
- <FormattedMessage {...messages.videoSizeDescription} values={{size: bytes2Size(videoSize)}} />
331
+ {getVideoSizeDescription()}
332
+ <CapHeading.CapHeadingSpan type="label2" className="whatsapp-format">
333
+ <FormattedMessage {...messages.channelFileFormat} values={{ format: SUPPORTED_FILE_FORMATS[DEFAULT] }} />
315
334
  </CapHeading.CapHeadingSpan>
335
+ </>}
336
+ {channel === VIBER &&
337
+ <>
338
+ {getVideoSizeDescription()}
316
339
  <CapHeading.CapHeadingSpan type="label2" className="whatsapp-format">
317
- <FormattedMessage {...messages.whatsappFileFormat} />
340
+ <FormattedMessage {...messages.channelFileFormat} values={{ format: SUPPORTED_FILE_FORMATS.VIBER }} />
341
+ </CapHeading.CapHeadingSpan>
342
+ <CapHeading.CapHeadingSpan type="label2" className="video-duration">
343
+ <FormattedMessage {...messages.viberMaxDuration} />
318
344
  </CapHeading.CapHeadingSpan>
319
345
  </>}
320
346
  </div>
@@ -46,4 +46,7 @@ $classPrefix: cap-custom-video-upload;
46
46
  }
47
47
  .video-panel {
48
48
  display: flex;
49
- }
49
+ }
50
+ .video-duration {
51
+ margin-left: 8rem;
52
+ }
@@ -55,12 +55,16 @@ export default defineMessages({
55
55
  id: `${scope}.imageReUpload`,
56
56
  defaultMessage: 'Re upload',
57
57
  },
58
- fileFormat: {
59
- id: `${scope}.fileFormat`,
60
- defaultMessage: 'Format: MP4',
58
+ channelFileFormat: {
59
+ id: `${scope}.channelFileFormat`,
60
+ defaultMessage: 'Format: {format}',
61
61
  },
62
- whatsappFileFormat: {
63
- id: `${scope}.whatsappFileFormat`,
64
- defaultMessage: 'Format: MP4',
62
+ viberMaxDuration: {
63
+ id: `${scope}.viberMaxDuration`,
64
+ defaultMessage: 'Max Duration: 600 seconds',
65
+ },
66
+ videoDurationError: {
67
+ id: `${scope}.videoDurationError`,
68
+ defaultMessage: 'Video duration should not exceed 600 seconds',
65
69
  },
66
70
  });
@@ -1,3 +1 @@
1
- export const AI_SUGGESTION_API_URL = `wss://${window.location.host}/arya/api/v1/ask-aira-service/content_gen/get_ai_suggestions`;
2
- export const CONTENT_RECOMMENDATION_BOT = "CONTENT_RECOMMENDATION_BOT";
3
1
  export const OUTBOUND = 'OUTBOUND';
@@ -51,7 +51,7 @@ import { SMS, MOBILE_PUSH, LINE, ENABLE_AI_SUGGESTIONS } from '../../v2Container
51
51
  import { validateIfTagClosed } from '../../utils/tagValidations';
52
52
  import globalMessages from '../../v2Containers/Cap/messages';
53
53
  import { convert } from 'html-to-text';
54
- import { AI_SUGGESTION_API_URL, CONTENT_RECOMMENDATION_BOT, OUTBOUND } from './constants';
54
+ import { OUTBOUND } 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';
@@ -2375,13 +2375,17 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2375
2375
  && hasAiSuggestionsEnabled
2376
2376
  && this.props.isFullMode
2377
2377
  && (
2378
- <CapAskAira
2378
+ <CapAskAira.ContentGenerationBot
2379
2379
  text={messageContent || ""}
2380
2380
  setText={(x) => {
2381
2381
  this.updateFormData(x, val);
2382
2382
  }}
2383
- botType={CONTENT_RECOMMENDATION_BOT}
2384
- websocketUrl={AI_SUGGESTION_API_URL}
2383
+ iconPlacement="float-br"
2384
+ rootStyle={{
2385
+ // 1rem is the margin-bottom of textarea
2386
+ bottom: 'calc(1rem + 0.2rem)',
2387
+ right: '0.2rem',
2388
+ }}
2385
2389
  />
2386
2390
  )}
2387
2391
  </CapColumn>
@@ -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 { isEmpty } from 'lodash';
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 { buttonText, imageURL, rcsPreviewContent, inAppPreviewContent, messageContent: viberMessageContent } = content || {};
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
- {/* button viber preview */}
924
- {buttonText && (
925
- <div
926
- style={{
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
- <p
937
- style={{
938
- "font-size": "12px",
939
- "font-weight": "500",
940
- display: "-webkit-box",
941
- "-webkit-line-clamp": "1",
942
- "-webkit-box-orient": "vertical",
943
- overflow: "hidden",
944
- color: CAP_WHITE,
945
- }}
946
- >
947
- {buttonText || ""}
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
- </div>
960
+ </CapLabel>
950
961
  )}
951
- <div style={{ paddingBottom: 32 }}></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';
@@ -309,11 +310,16 @@ export function SlideBoxContent(props) {
309
310
  }
310
311
  case constants.VIBER: {
311
312
  const template = cloneDeep(templateDataObject);
312
- const { text = "", imageURL = "", buttonText = "" } = get(template, 'versions.base.content.viber', {});
313
+ const { text = "", button = {}, image = {}, video = {} } = get(template, 'versions.base.content.content', {});
314
+ const { url: viberImageUrl = "" } = image;
315
+ const { url: viberVideoUrl = "", thumbnailUrl = '' } = video;
313
316
  template.content = {
314
- messageContent: text,
315
- imageURL,
316
- buttonText,
317
+ viberPreviewContent: {
318
+ ...(!isEmpty(image) && { imageURL: viberImageUrl }),
319
+ ...(!isEmpty(video) && { videoParams: { viberVideoSrc: viberVideoUrl, viberVideoPreviewImg: thumbnailUrl }}),
320
+ buttonText: button?.text,
321
+ messageContent: text,
322
+ },
317
323
  };
318
324
  return template.content;
319
325
  }
@@ -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
  });