@capillarytech/creatives-library 7.10.59 → 7.10.60

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.
@@ -1,3 +1,5 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
1
3
  exports[`galleryReducer Initial State should match snapshot returns the initial state 1`] = `
2
4
  Object {
3
5
  "assetList": Array [],
@@ -2733,11 +2733,12 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2733
2733
  } else {
2734
2734
  this.setState({injectedTags: data.tags});
2735
2735
  }
2736
- this.props.globalActions.setInjectedTags(data.tags);
2736
+ if (data.tags) {
2737
+ this.props.globalActions.setInjectedTags(data.tags);
2738
+ }
2737
2739
  }
2738
2740
 
2739
2741
  startLoading = (ifEdit) => {
2740
-
2741
2742
  if (ifEdit) {
2742
2743
  this.setState({loading: true});
2743
2744
  }
package/index.js CHANGED
@@ -87,6 +87,10 @@ import SmsTraiCreate from './v2Containers/SmsTrai/Create';
87
87
  import SmsTraiCreateReducer from './v2Containers/SmsTrai/Create/reducer';
88
88
  import SmsTraiCreateSaga from './v2Containers/SmsTrai/Create/sagas';
89
89
 
90
+ import Whatsapp from './v2Containers/Whatsapp';
91
+ import whatsappReducer from './v2Containers/Whatsapp/reducer';
92
+ import whatsappSaga from './v2Containers/Whatsapp/sagas';
93
+
90
94
  export {default as Ebill} from './v2Containers/Ebill';
91
95
  export {default as EbillReducer} from './v2Containers/Ebill/reducer';
92
96
  export {default as EbillSaga} from './v2Containers/Ebill/sagas';
@@ -111,6 +115,7 @@ const FacebookContainer = {Facebook, facebookReducer, facebookSaga};
111
115
  const ViberContainer = {Viber, viberReducer, viberSaga};
112
116
  const FacebookPreviewContainer = { FacebookPreview, facebookPreviewReducer, facebookPreviewSaga };
113
117
  const SmsTraiContainer = {SmsTraiCreate, SmsTraiCreateReducer, SmsTraiCreateSaga};
118
+ const WhatsappContainer = { Whatsapp, whatsappReducer, whatsappSaga };
114
119
 
115
120
  const GalleryContainer = {Gallery, galleryReducer, gallerySagas};
116
121
  const FTPContainer = {FTP, FTPReducer, FTPSagas};
@@ -157,4 +162,5 @@ export { CapContainer,
157
162
  ViberContainer,
158
163
  FacebookPreviewContainer,
159
164
  SmsTraiContainer,
165
+ WhatsappContainer,
160
166
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.10.59",
4
+ "version": "7.10.60",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/routes.js CHANGED
@@ -660,6 +660,8 @@ export default function createRoutes(store) {
660
660
  import('v2Containers/CapFacebookPreview/reducer'),
661
661
  import('v2Containers/SmsTrai/Create/sagas'),
662
662
  import('v2Containers/SmsTrai/Create/reducer'),
663
+ import('v2Containers/Whatsapp/sagas'),
664
+ import('v2Containers/Whatsapp/reducer'),
663
665
  ]);
664
666
 
665
667
  const renderRoute = loadModule(cb);
@@ -683,6 +685,7 @@ export default function createRoutes(store) {
683
685
  viberSagas, viberReducer,
684
686
  capFacebookPreviewSagas, capFacebookPreviewReducer,
685
687
  smsTraiSagas, smsTraiReducer,
688
+ whatsappSagas, whatsappReducer,
686
689
  ]) => {
687
690
  injectReducer('templates', reducer.default);
688
691
  injectReducer('cap', capReducer.default);
@@ -702,6 +705,7 @@ export default function createRoutes(store) {
702
705
  injectReducer('viber', viberReducer.default);
703
706
  injectReducer('facebookPreview', capFacebookPreviewReducer.default);
704
707
  injectReducer('smsTrai', smsTraiReducer.default);
708
+ injectReducer('whatsapp', whatsappReducer.default);
705
709
  injectSagas(gallerySagas.default);
706
710
  injectSagas(sagas.default);
707
711
  injectSagas(capSagas.default);
@@ -720,6 +724,7 @@ export default function createRoutes(store) {
720
724
  injectSagas(viberSagas.default);
721
725
  injectSagas(capFacebookPreviewSagas.default);
722
726
  injectSagas(smsTraiSagas.default);
727
+ injectSagas(whatsappSagas.default);
723
728
  renderRoute(component);
724
729
  });
725
730
  importModules.catch(errorLoading);
package/services/api.js CHANGED
@@ -460,4 +460,9 @@ export const createBulkSMSTemplate = ({templates}) => {
460
460
  export const checkBulkDuplicates = (data) => {
461
461
  const url = `${API_ENDPOINT}/templates/bulk/sms/checkDuplicates`;
462
462
  return request(url, getAPICallObject('POST', data));
463
- };
463
+ };
464
+
465
+ export const createWhatsappTemplate = ({ payload }) => {
466
+ const url = `${API_ENDPOINT}/templates/WHATSAPP`;
467
+ return request(url, getAPICallObject('POST', payload));
468
+ };
package/utils/v2common.js CHANGED
@@ -0,0 +1,13 @@
1
+ export const getObjFromQueryParams = (searchString) => {
2
+ const params = new URLSearchParams(searchString);
3
+ const obj = {};
4
+ // iterate over all keys
5
+ for (const key of params.keys()) {
6
+ if (params.getAll(key).length > 1) {
7
+ obj[key] = params.getAll(key);
8
+ } else {
9
+ obj[key] = params.get(key);
10
+ }
11
+ }
12
+ return obj;
13
+ }
@@ -15,7 +15,7 @@
15
15
  }
16
16
  }
17
17
 
18
- .msgContainer {
18
+ .msg-container {
19
19
  position: absolute;
20
20
  top: 20%;
21
21
  left: 23%;
@@ -238,6 +238,21 @@
238
238
  }
239
239
  }
240
240
  }
241
+
242
+ .whatsapp-brand-name {
243
+ position: absolute;
244
+ top: 11%;
245
+ left: 38%;
246
+ color: white;
247
+ font-size: small;
248
+ }
249
+ .whatsapp-message-container{
250
+ max-height: 292px;
251
+ margin-left: 28px;
252
+ }
253
+ .whatsapp-content{
254
+ margin: 2px 6px 1px 7px;
255
+ }
241
256
  }
242
257
 
243
258
  .align-center {
@@ -291,7 +306,7 @@
291
306
  }
292
307
 
293
308
 
294
- .msgContainer {
309
+ .msg-container {
295
310
  position: absolute;
296
311
  top: 14%;
297
312
  left: 29%;
@@ -399,4 +414,11 @@
399
414
  span {
400
415
  font-size: $FONT_SIZE_VS;
401
416
  }
417
+ }
418
+ .whatsapp-brand-name{
419
+ position: absolute;
420
+ top: 11%;
421
+ left: 38%;
422
+ color: white;
423
+ font-size: small;
402
424
  }
@@ -10,13 +10,17 @@ import React from 'react';
10
10
  import _ from 'lodash';
11
11
  import { injectIntl, FormattedMessage, intlShape } from 'react-intl';
12
12
  // import styled from 'styled-components';
13
- import {CapColumn, CapRow, CapHeading, CapIcon, CapButton, CapImage} from '@capillarytech/cap-ui-library';
13
+ import { CapColumn, CapRow, CapHeading, CapIcon, CapButton, CapImage, CapLabel } from '@capillarytech/cap-ui-library';
14
14
  import './_templatePreview.scss';
15
15
  import {updateCharCount} from '../../utils/smsCharCountV2';
16
16
  import messages from './messages';
17
- import { WECHAT } from '../../v2Containers/CreativesContainer/constants';
17
+ import {
18
+ WECHAT,
19
+ WHATSAPP,
20
+ } from '../../v2Containers/CreativesContainer/constants';
18
21
  import Carousel from '../Carousel';
19
22
  import { VIBER, FACEBOOK } from '../../v2Containers/App/constants';
23
+ import whatsappMobileAndroid from './assets/images/whatsapp_mobile_android.svg'
20
24
  const wechatBodyNew = require('./assets/images/wechat_mobile_android.svg');
21
25
  const smsMobileAndroid = require('./assets/images/sms_mobile_android.svg');
22
26
  const lineMobileAndroid = require('../../assets/line.png');
@@ -28,9 +32,20 @@ const lineVideoPlaceholder = require('../../assets/rich-video-placeholder.svg');
28
32
  const androidPushMessagePhone = require('./assets/images/androidPushMessage.svg');
29
33
  const iPhonePushMessagePhone = require('./assets/images/iPhonePushMessage.svg');
30
34
 
31
- import { CAP_COLOR_03, CAP_WHITE, FONT_COLOR_01, CAP_G08, CAP_G06, CAP_G15, CAP_PURPLE01, CAP_G16 } from '@capillarytech/cap-ui-library/styled/variables';
35
+ import {
36
+ CAP_COLOR_03,
37
+ CAP_WHITE,
38
+ FONT_COLOR_01,
39
+ CAP_G06,
40
+ CAP_G15,
41
+ CAP_PURPLE01,
42
+ CAP_G16,
43
+ CAP_SPACE_08,
44
+ CAP_SPACE_16,
45
+ } from '@capillarytech/cap-ui-library/styled/variables';
32
46
  import { TEMPLATE, IMAGE_CAROUSEL, IMAGE, STICKER, TEXT, IMAGE_MAP, VIDEO } from '../../v2Containers/Line/Container/constants';
33
47
  import CapFacebookPreview from '../../v2Containers/CapFacebookPreview';
48
+ import WhatsappStatusContainer from '../WhatsappStatusContainer';
34
49
 
35
50
  class TemplatePreview extends React.Component { // eslint-disable-line react/prefer-stateless-function
36
51
  onPreviewContentClicked = (channel) => {
@@ -132,7 +147,18 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
132
147
 
133
148
  render() {
134
149
  let content = channel && channel.toLowerCase() === 'sms' ? [this.props.content] : this.props.content;
135
- const { channel, showTestAndPreviewIcon, module, viberBrandName, viberAccountName } = this.props;
150
+ const {
151
+ channel,
152
+ showTestAndPreviewIcon,
153
+ module,
154
+ viberBrandName,
155
+ viberAccountName,
156
+ whatsappAccountName,
157
+ whatsappContentLen = 0,
158
+ intl,
159
+ templateData,
160
+ } = this.props;
161
+ const { formatMessage } = intl;
136
162
  const { buttonText, imageURL, messageContent: viberMessageContent } = content || {};
137
163
  let smsDetails = {};
138
164
  // let smsText = '';
@@ -187,6 +213,13 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
187
213
  'background-color': CAP_G15,
188
214
  'width': '81%',
189
215
  };
216
+ const whatsappSectionStyle = {
217
+ 'padding': `4px 0 ${CAP_SPACE_08}`,
218
+ 'border-radius': '6px',
219
+ 'background-color': CAP_G15,
220
+ 'width': '88%',
221
+ 'left': '10%',
222
+ };
190
223
  const getVideoContent = ({
191
224
  video,
192
225
  actionUrl,
@@ -259,6 +292,8 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
259
292
  </div>
260
293
  );
261
294
 
295
+ const whatsappUpdatedAccountName = whatsappAccountName || _.get(templateData, 'versions.base.content.whatsapp.accountName', '');
296
+
262
297
  return (
263
298
  <CapRow>
264
299
  {this.props.showCount && (channel && channel.toLowerCase() !== FACEBOOK) && <CapColumn span={16}>
@@ -271,6 +306,17 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
271
306
  {smsDetails.optoutUrlPresent && <CapHeading type="h6">
272
307
  <FormattedMessage {...messages.optoutCharactersTotal} values={{optoutUrlLength: smsDetails.optouturlLength}} />
273
308
  </CapHeading>}
309
+ {channel?.toLowerCase() === WHATSAPP.toLowerCase() ? (
310
+ <>
311
+ <WhatsappStatusContainer template={templateData} />
312
+ <CapHeading type="h3" className='margin-t-12'>
313
+ <FormattedMessage {...messages.whatsappCharactersTotal} values={{charCount: content?.templateMsg?.length}} />
314
+ </CapHeading>
315
+ <CapHeading type="h6">
316
+ <FormattedMessage {...messages.whatsappUnsubscribeLength} />
317
+ </CapHeading>
318
+ </>
319
+ ) : null}
274
320
  </CapColumn>}
275
321
  <CapColumn span={this.props.showCount ? 8 : 24}>
276
322
  {showTestAndPreview && (
@@ -308,7 +354,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
308
354
  <div>
309
355
  <div className="shell-v2 align-center" id="sms-preview">
310
356
  <CapImage className="preview-image sms" src={smsMobileAndroid} alt="Preview is being generated"/>
311
- <div className="msgContainer sms">
357
+ <div className="msg-container sms">
312
358
  <div className={"message-pop sms"}>
313
359
  {content && content.length && content.map((msg, index) =>
314
360
  <CapColumn key={`"message-pop-content-${index}`} className="message-pop-item align-left" style={{ background: '#FFFFFF', color: '#091e42'}}>
@@ -336,7 +382,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
336
382
  {channel && channel.toLowerCase() === 'wechat' ?
337
383
  ( <div className="shell-v2 align-center" id="sms-preview">
338
384
  <CapImage className="preview-image" src={(channel || '').toLowerCase() === 'wechat' ? wechatBodyNew : smsMobileAndroid} alt="Preview is being generated"/>
339
- <div className="msgContainer wechat">
385
+ <div className="msg-container wechat">
340
386
  <div className="message-pop align-left" style={{ background: `${this.props.channel.toLowerCase() === 'wechat' ? '#ffffff' : '#3F51B5'}`, color: `${this.props.channel.toLowerCase() === 'wechat' ? '#333333' : '#ffffff'}`}}>{content}
341
387
  </div>
342
388
  </div>
@@ -396,7 +442,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
396
442
  <div className="shell-v2 align-center" id="sms-preview">
397
443
  <CapImage className="preview-image" src={lineMobileAndroid} alt={this.props.intl.formatMessage(messages.previewGenerated)}/>
398
444
  <div
399
- className="msgContainer line-preview"
445
+ className="msg-container line-preview"
400
446
  style={{
401
447
  maxHeight: 330,
402
448
  overflow: 'scroll',
@@ -564,7 +610,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
564
610
  <CapImage className="preview-image" src={viberMobileAndroid} alt={this.props.intl.formatMessage(messages.previewGenerated)}/>
565
611
  <div style={{ position: 'absolute', top: '12%', left: '36%'}}>{viberBrandName}</div>
566
612
  <div
567
- className="msgContainer viber-preview"
613
+ className="msg-container viber-preview"
568
614
  style={{
569
615
  maxHeight: 292,
570
616
  marginLeft: 28,
@@ -638,6 +684,41 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
638
684
  </div>
639
685
  ) : ''
640
686
  }
687
+ {
688
+ channel?.toUpperCase() === WHATSAPP ? (
689
+ <>
690
+ <div className='shell-v2 align-center'>
691
+ <CapImage
692
+ className='preview-image'
693
+ src={whatsappMobileAndroid}
694
+ alt={formatMessage(messages.previewGenerated)}
695
+ />
696
+ <CapLabel className='whatsapp-brand-name'>
697
+ {whatsappUpdatedAccountName || ''}
698
+ </CapLabel>
699
+ <div className='msg-container whatsapp-message-container'>
700
+ <div className='message-pop align-left' style={whatsappSectionStyle}>
701
+ <CapLabel className='whatsapp-content'>
702
+ {content?.templateMsg || ''}
703
+ </CapLabel>
704
+ </div>
705
+ </div>
706
+ </div>
707
+ <CapHeading
708
+ type='h3'
709
+ style={{ textAlign: 'center' }}
710
+ className='margin-t-16'
711
+ >
712
+ <FormattedMessage
713
+ {...messages.whatsappMessageLength}
714
+ values={{ length: 36 + whatsappContentLen }}
715
+ />
716
+ </CapHeading>
717
+ </>
718
+ ) : (
719
+ ''
720
+ )
721
+ }
641
722
  {channel && channel.toLowerCase() === FACEBOOK && (
642
723
  <div style={{position: 'absolute', left: '80%'}} id="facebook-preview">
643
724
  <CapFacebookPreview
@@ -22,10 +22,22 @@ export default defineMessages({
22
22
  id: 'creatives.componentsV2.TemplatePreview.charactersTotal',
23
23
  defaultMessage: "{smsCount} SMS ({charCount} characters)",
24
24
  },
25
+ whatsappCharactersTotal: {
26
+ id: 'creatives.componentsV2.TemplatePreview.whatsappCharactersTotal',
27
+ defaultMessage: "{charCount} characters",
28
+ },
25
29
  optoutCharactersTotal: {
26
30
  id: 'app.components.TemplatePreview.optoutCharactersTotal',
27
31
  defaultMessage: "Includes optout tag ({optoutUrlLength} characters)",
28
32
  },
33
+ whatsappUnsubscribeLength: {
34
+ id: 'app.components.TemplatePreview.whatsappUnsubscribeLength',
35
+ defaultMessage: "Includes 36 characters of (Click {{unsubscribe}} to unsubscribe)",
36
+ },
37
+ whatsappMessageLength: {
38
+ id: 'app.components.TemplatePreview.whatsappMessageLength',
39
+ defaultMessage: "1 Message ({length} characters)",
40
+ },
29
41
  smsFormatType: {
30
42
  id: 'creatives.componentsV2.TemplatePreview.smsFormatType',
31
43
  defaultMessage: 'Message has unicode characters',
@@ -47,6 +47,7 @@ export const PREVIEW = 'preview';
47
47
 
48
48
  export const VIBER = 'viber';
49
49
  export const FACEBOOK = 'facebook';
50
+ export const WHATSAPP = 'whatsapp';
50
51
 
51
52
  export const TRACK_EDIT_SMS = 'editSms';
52
53
  export const TRACK_EDIT_EMAIL = 'editEmail';
@@ -107,4 +108,6 @@ export const FB_AD_CALL_TO_ACTION = {
107
108
  export const CREATIVES = 'creatives';
108
109
  export const LOYALTY = 'loyalty';
109
110
 
110
- export const FAILURE = 'FAILURE';
111
+ export const FAILURE = 'FAILURE';
112
+ export const DATE_DISPLAY_FORMAT = 'D MMM YYYY';
113
+ export const TIME_DISPLAY_FORMAT = 'hh:mm A';
@@ -1,3 +1,5 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
1
3
  exports[`galleryReducer Initial State should match snapshot returns the initial state 1`] = `
2
4
  Object {
3
5
  "assetList": Array [],
@@ -80,6 +80,14 @@ export default defineMessages({
80
80
  id: `creatives.containersV2.promotions`,
81
81
  defaultMessage: 'Promotions',
82
82
  },
83
+ "templateNameLabel": {
84
+ id: `creatives.containersV2.templateNameLabel`,
85
+ defaultMessage: 'Template name',
86
+ },
87
+ "templateNamePlaceholder": {
88
+ id: `creatives.containersV2.templateNamePlaceholder`,
89
+ defaultMessage: 'Enter template name',
90
+ },
83
91
 
84
92
  //refresh due to org change messages
85
93
 
@@ -149,6 +157,9 @@ export default defineMessages({
149
157
  id: `creatives.containersV2.watchMore`,
150
158
  defaultMessage: 'Watch More',
151
159
  },
152
-
160
+ "done": {
161
+ id: `creatives.containersV2.done`,
162
+ defaultMessage: 'Done',
163
+ },
153
164
  });
154
165
 
@@ -21,6 +21,8 @@ import * as constants from './constants';
21
21
  import LineContainer from '../Line/Container';
22
22
  import FTP from '../FTP';
23
23
  import Viber from '../Viber';
24
+ import Whatsapp from '../Whatsapp';
25
+ import { getWhatsappContent } from '../Whatsapp/utils';
24
26
  import * as commonUtil from '../../utils/common';
25
27
  const CreativesWrapper = styled.div`
26
28
  .ant-popover,
@@ -143,6 +145,7 @@ function SlideBoxContent(props) {
143
145
  showDisabledFBInfo,
144
146
  orgUnitId,
145
147
  smsRegister,
148
+ enableNewChannels,
146
149
  } = props;
147
150
  const type = (messageDetails.type || '').toLowerCase(); // type is context in get tags values : outbound | dvs | referral | loyalty | coupons
148
151
  const query = { type: !isFullMode && 'embedded', module: isFullMode ? 'default' : 'library', isEditFromCampaigns: (templateData || {}).isEditFromCampaigns};
@@ -170,11 +173,12 @@ function SlideBoxContent(props) {
170
173
  });
171
174
 
172
175
 
173
- const isCreateSms = slidBoxContent === 'createTemplate' && channel === constants.SMS;
174
- const isCreateFacebook = slidBoxContent === 'createTemplate' && channel === constants.FACEBOOK;
175
-
176
- const isCreateMPush = slidBoxContent === 'createTemplate' && channel === constants.MOBILE_PUSH;
177
- const isCreateCallTask = slidBoxContent === 'createTemplate' && channel === constants.CALL_TASK;
176
+ const isCreate = slidBoxContent === 'createTemplate';
177
+ const isCreateSms = isCreate && channel === constants.SMS;
178
+ const isCreateFacebook = isCreate && channel === constants.FACEBOOK;
179
+ const isCreateWhatsapp = isCreate && channel === constants.WHATSAPP;
180
+ const isCreateMPush = isCreate && channel === constants.MOBILE_PUSH;
181
+ const isCreateCallTask = isCreate && channel === constants.CALL_TASK;
178
182
  let isEditSms = false;
179
183
  let isEditEmailWithId = false;
180
184
  let isEmailEditWithContent = false;
@@ -185,7 +189,8 @@ function SlideBoxContent(props) {
185
189
  let isEditMPush = false;
186
190
  let isEditFacebook = false;
187
191
  let isEditFTP = false;
188
- const isEmailCreate = slidBoxContent === 'createTemplate' && channel === constants.EMAIL;
192
+ let isEditWhatsapp = false;
193
+ const isEmailCreate = isCreate && channel === constants.EMAIL;
189
194
  if (templateData && channel) {
190
195
  channel = templateData.type;// for edit mode with template data
191
196
  isEditSms = slidBoxContent === 'editTemplate' && channel === constants.SMS;
@@ -194,7 +199,8 @@ function SlideBoxContent(props) {
194
199
  isEditEmailWithId = slidBoxContent === 'editTemplate' && channel === constants.EMAIL && templateData._id;
195
200
  isEmailEditWithContent = slidBoxContent === 'editTemplate' && channel === constants.EMAIL && !templateData._id;
196
201
  isEditFacebook = slidBoxContent === 'editTemplate' && channel === constants.FACEBOOK;
197
- isPreview = slidBoxContent === 'preview' && (channel === constants.SMS || channel === constants.LINE || channel === constants.VIBER || channel === constants.FACEBOOK);
202
+ isEditWhatsapp = slidBoxContent === 'editTemplate' && channel === constants.WHATSAPP;
203
+ isPreview = slidBoxContent === 'preview' && (channel === constants.SMS || channel === constants.LINE || channel === constants.VIBER || channel === constants.FACEBOOK || channel === constants.WHATSAPP);
198
204
  isEmailPreview = slidBoxContent === 'preview' && channel === constants.EMAIL;
199
205
  isMpushPreview = slidBoxContent === 'preview' && channel === constants.MOBILE_PUSH;
200
206
  isEditFTP = slidBoxContent === 'editTemplate' && [constants.NO_COMMUNICATION, constants.FTP].includes(channel);
@@ -321,6 +327,11 @@ function SlideBoxContent(props) {
321
327
  };
322
328
  return fbContent;
323
329
  }
330
+ case constants.WHATSAPP: {
331
+ return {
332
+ templateMsg: getWhatsappContent(templateDataObject),
333
+ };
334
+ }
324
335
  default:
325
336
  return get(templateDataObject, `versions.base.content`);
326
337
  }
@@ -355,6 +366,7 @@ function SlideBoxContent(props) {
355
366
  showDisabledFBInfo={showDisabledFBInfo}
356
367
  orgUnitId={orgUnitId}
357
368
  smsRegister={smsRegister}
369
+ enableNewChannels={enableNewChannels}
358
370
  />
359
371
  )}
360
372
  {isPreview && (
@@ -362,6 +374,7 @@ function SlideBoxContent(props) {
362
374
  content={getChannelPreviewContent(templateData)}
363
375
  viberBrandName={selectedAccount || ""}
364
376
  viberAccountName={(selectedAccount || "")[0]}
377
+ whatsappAccountName={selectedAccount}
365
378
  unicodeEnabled={get(templateData, `versions.base['unicode-validity']`)}
366
379
  channel={(templateData.type || '').toLowerCase()}
367
380
  charCounterEnabled={channel === constants.SMS}
@@ -678,6 +691,28 @@ function SlideBoxContent(props) {
678
691
  templateData={templateData}
679
692
  createNew/> }
680
693
 
694
+ {isCreateWhatsapp && (<Whatsapp
695
+ isFullMode={isFullMode}
696
+ onCreateComplete={onCreateComplete}
697
+ handleClose={handleClose}/>
698
+ )}
699
+
700
+ {isEditWhatsapp && (<Whatsapp
701
+ isFullMode={isFullMode}
702
+ templateData={templateData}
703
+ getFormData={getFormData}
704
+ getDefaultTags={type}
705
+ forwardedTags={forwardedTags}
706
+ params={{
707
+ id: templateData._id,
708
+ }}
709
+ location={{
710
+ pathname: `/whatsapp/edit`,
711
+ query,
712
+ search: '',
713
+ }}/>
714
+ )}
715
+
681
716
  </CreativesWrapper>
682
717
  );
683
718
  }
@@ -1,35 +1,63 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { FormattedMessage } from 'react-intl';
4
+ import get from 'lodash/get';
4
5
  import { CapHeader, CapIcons, CapLabel, CapSteps } from '@capillarytech/cap-ui-library';
5
6
  import moment from 'moment';
6
7
  import PropTypes from 'prop-types';
7
8
  import messages from './messages';
9
+ import whatsppMsg from '../Whatsapp/messages';
10
+ import globalMessages from '../Cap/messages'
8
11
  import { MAP_TEMPLATE } from '../WeChat/Wrapper/constants';
9
- import { NO_COMMUNICATION, FTP } from '../App/constants';
12
+ import { NO_COMMUNICATION, FTP, WHATSAPP } from '../App/constants';
10
13
  import { isTraiDLTEnable } from '../../utils/common';
14
+ import { formatString } from '../../utils/Formatter';
15
+ import {
16
+ CAP_SPACE_12,
17
+ } from '@capillarytech/cap-ui-library/styled/variables';
18
+ const { CapLabelInline } = CapLabel;
19
+ const StyledLabel = styled(CapLabelInline)`
20
+ margin-right: ${CAP_SPACE_12};
21
+ `;
11
22
  const PrefixWrapper = styled.div`
12
23
  margin-right: 16px;
13
24
  `;
14
- function getChannelLabel(channel = '') {
15
- const labels = {
16
- sms: 'SMS',
17
- email: 'Email',
18
- mobilepush: 'Push notification',
19
- wechat: 'Wechat',
20
- no_communication: 'NO_COMMUNICATION',
21
- ftp: 'FTP',
22
- };
23
- return labels[channel.toLowerCase()];
24
- }
25
+ const renderWhatsappData = (type, value) => (
26
+ <StyledLabel type={type}>
27
+ {value}
28
+ </StyledLabel>
29
+ )
30
+ function SlideBoxHeader(props) {
25
31
 
26
32
 
27
- function SlideBoxHeader(props) {
28
33
  const { slidBoxContent, templateData, onShowTemplates, creativesMode, isFullMode, showPrefix, shouldShowTemplateName, channel, templateNameRenderProp, weChatTemplateType, onWeChatMaptemplateStepChange, weChatMaptemplateStep, templateStep, smsRegister } = props;
29
34
  const showTemplateNameHeader = isFullMode && shouldShowTemplateName;
30
35
  const mapTemplateCreate = !showTemplateNameHeader && slidBoxContent === 'createTemplate' && weChatTemplateType === MAP_TEMPLATE && templateStep !== 'modeSelection';
31
36
  const isTraiDlt = isTraiDLTEnable(isFullMode, smsRegister);
32
37
  const showCreateTraiSMSHeader = isTraiDlt && channel.toLowerCase() === "sms";
38
+ const isWhatsappEdit = channel.toLowerCase() === WHATSAPP && slidBoxContent === 'editTemplate';
39
+ const whatsappOverview = isWhatsappEdit && isFullMode;
40
+ const headerMessage = whatsappOverview ? messages.whatsappOverview : messages.editMessageContent;
41
+ const {
42
+ whatsappTemplateName,
43
+ whatsappTemplateCategory,
44
+ } = templateData || {};
45
+ const whatsappName = whatsappTemplateName || templateData?.name;
46
+ const whatsappCategory = whatsappTemplateCategory || get(templateData, `versions.base.content.whatsapp.category`, '');
47
+
48
+
49
+ const getChannelLabel = (currentChannel = '') => {
50
+ const labels = {
51
+ sms: 'SMS',
52
+ email: 'Email',
53
+ mobilepush: 'Push notification',
54
+ wechat: 'Wechat',
55
+ no_communication: 'NO_COMMUNICATION',
56
+ ftp: 'FTP',
57
+ whatsapp: <FormattedMessage {...messages.whatsappTemplate} />,
58
+ };
59
+ return labels[currentChannel.toLowerCase()];
60
+ };
33
61
 
34
62
  return (
35
63
  <div key="creatives-container-slidebox-header-content">
@@ -57,7 +85,20 @@ function SlideBoxHeader(props) {
57
85
  )}
58
86
  {!showTemplateNameHeader && slidBoxContent === 'editTemplate' && (
59
87
  <CapHeader
60
- title={<FormattedMessage {...messages.editMessageContent} values={{channel: getChannelLabel(channel)}}/>}
88
+ title={<FormattedMessage {...headerMessage} values={{channel: getChannelLabel(channel)}}/>}
89
+ description={
90
+ isWhatsappEdit && (
91
+ <>
92
+ {renderWhatsappData("label1", <FormattedMessage {...globalMessages.templateNameLabel} />)}
93
+ {renderWhatsappData("label2", whatsappName)}
94
+ {renderWhatsappData("label3", <FormattedMessage {...whatsppMsg.labelSeperator} />)}
95
+ {renderWhatsappData("label1", <FormattedMessage {...whatsppMsg.templateCategoryLabel} />)}
96
+ {renderWhatsappData("label2", formatString(whatsappCategory))}
97
+ {renderWhatsappData("label3", <FormattedMessage {...whatsppMsg.labelSeperator} />)}
98
+ {renderWhatsappData("label1", <FormattedMessage {...whatsppMsg.languageLabel} />)}
99
+ {renderWhatsappData("label2", <FormattedMessage {...whatsppMsg.templateLanguageEnglish} />)}
100
+ </>)
101
+ }
61
102
  prefix={creativesMode !== 'edit' && !isFullMode && showPrefix &&
62
103
  <PrefixWrapper>
63
104
  <CapIcons.backIcon onClick={onShowTemplates} />
@@ -16,6 +16,7 @@ export const FACEBOOK = "FACEBOOK";
16
16
  export const FTP = "FTP";
17
17
  export const NO_COMMUNICATION = "NO_COMMUNICATION";
18
18
  export const VIBER = "VIBER";
19
+ export const WHATSAPP = "WHATSAPP";
19
20
 
20
21
  export const SHOW_CONTANER_LOADER = "app/CreativesContainer/SHOW_CONTANER_LOADER";
21
22
  export const HIDE_CONTAINER_LOADER = "app/CreativesContainer/HIDE_CONTAINER_LOADER";