@capillarytech/creatives-library 6.13.2 → 6.13.4

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.
@@ -0,0 +1,700 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { bindActionCreators } from 'redux';
3
+ import { createStructuredSelector } from 'reselect';
4
+ import { injectIntl, FormattedMessage } from 'react-intl';
5
+ // import { connect } from 'react-redux';
6
+ import { get } from 'lodash';
7
+ import withCreatives from '../../hoc/withCreatives';
8
+ import {
9
+ CapHeader,
10
+ CapRow,
11
+ CapColumn,
12
+ CapSpin,
13
+ CapLabel,
14
+ CapInput,
15
+ CapHeading,
16
+ CapDivider,
17
+ CapIcon,
18
+ CapButton,
19
+ CapUploader,
20
+ CapDrawer,
21
+ CapNotification,
22
+ CapImage,
23
+ } from '@capillarytech/cap-ui-library';
24
+ import { makeSelectViber, makeSelectCreateViber } from './selectors';
25
+ import * as viberActions from './actions';
26
+ import { validateTags } from '../../utils/tagValidations';
27
+ import TemplatePreview from '../../v2Components/TemplatePreview';
28
+ import './_viber.scss';
29
+ import {
30
+ CAP_G09,
31
+ CAP_SPACE_08,
32
+ CAP_SPACE_12,
33
+ FONT_COLOR_05,
34
+ CAP_SPACE_32,
35
+ CAP_SPACE_24,
36
+ CAP_WHITE,
37
+ CAP_SPACE_16,
38
+ CAP_G07,
39
+ } from '@capillarytech/cap-ui-library/styled/variables';
40
+ import LabelHOC from '@capillarytech/cap-ui-library/assets/HOCs/ComponentWithLabelHOC';
41
+ import styled from 'styled-components';
42
+ import messages from './messages';
43
+ import TagList from '../TagList';
44
+ import { makeSelectMetaEntities, setInjectedTags } from '../Cap/selectors';
45
+ import Gallery from '../Assets/Gallery';
46
+ import {
47
+ ALLOWED_EXTENSIONS_REGEX,
48
+ VIBER_IMG_HEIGHT,
49
+ VIBER_IMG_WIDTH,
50
+ VIBER_IMG_SIZE,
51
+ charLimit,
52
+ } from './constants';
53
+ const { CapHeadingSpan } = CapHeading;
54
+ const { TextArea } = CapInput;
55
+
56
+ const Viber = (props) => {
57
+ const {
58
+ intl,
59
+ supportedExtensions,
60
+ isFullMode,
61
+ injectedTags,
62
+ location,
63
+ metaEntities,
64
+ globalActions,
65
+ handleClose,
66
+ onCreateComplete,
67
+ params,
68
+ actions,
69
+ viber,
70
+ } = props || {};
71
+
72
+ const { formatMessage } = intl;
73
+ const [isImageError, updateImageErrorMessage] = useState(false);
74
+ const [isImage, updateImageStatus] = useState(false);
75
+ const [imageSrc, updateImageSrc] = useState();
76
+ const [isDrawerRequired, updateDrawerRequirement] = useState(false);
77
+ const [messageContent, updateTextMessageContent] = useState('');
78
+ const [buttonText, updateButtonText] = useState('');
79
+ const [buttonURL, updateButtonUrl] = useState('');
80
+ const [errorMessageTextarea, updateErrorMessageTextArea] = useState(false);
81
+ const [imagePreview, updateImagePreview] = useState();
82
+ const [isEditLoading, updateEditLoading] = useState(false);
83
+ const [isEditFlow, checkEditFlow] = useState(false);
84
+ const [messageTitle, updateTextMessageTitle] = useState('');
85
+ const [errorMessageTitle, updateErrorMessageTitle] = useState(false);
86
+
87
+ const StyledHeader = styled(CapHeader)`
88
+ margin-bottom: 14px;
89
+ `;
90
+ const ViberFooter = styled.div`
91
+ background-color: ${CAP_WHITE};
92
+ position: fixed;
93
+ bottom: 0;
94
+ width: 100%;
95
+ margin-left: -32px;
96
+ padding: ${CAP_SPACE_32} ${CAP_SPACE_24};
97
+
98
+ .ant-btn {
99
+ margin-right: ${CAP_SPACE_16};
100
+ }
101
+ }
102
+ `;
103
+
104
+ const paramObj = params || {};
105
+
106
+ useEffect(() => {
107
+ const { id } = paramObj;
108
+ if (id) {
109
+ updateEditLoading(true);
110
+ actions.getTemplateDetails(id, updateEditLoading);
111
+ checkEditFlow(true);
112
+ }
113
+ }, [paramObj.id]);
114
+
115
+ useEffect(() => {
116
+ if (params && params.id) {
117
+ const { viber: editViberContent = {} } = get(viber, `templateDetails.versions.base.content`, {});
118
+ const editMessageTitle = get(viber, 'templateDetails.name');
119
+ updateTextMessageTitle(editMessageTitle);
120
+ updateTextMessageContent(editViberContent.text || '');
121
+ updateButtonText(editViberContent.buttonText || '');
122
+ updateButtonUrl(editViberContent.buttonURL || '');
123
+ if (editViberContent.imageURL) {
124
+ updateImageSrc(editViberContent.imageURL);
125
+ updateImagePreview(editViberContent.imageURL);
126
+ updateImageStatus(true);
127
+ }
128
+ }
129
+ }, [viber[`templateDetails`]]);
130
+
131
+ // Common container for TEXT, IMAGE and Button
132
+ const container = (icon, message, data) => (<CapRow
133
+ style={{
134
+ border: `solid 1px ${CAP_G07}`,
135
+ marginBottom: '20px',
136
+ }}>
137
+ <CapRow style={{ padding: `${CAP_SPACE_12} ${CAP_SPACE_24} 0px` }}>
138
+ <CapIcon type={icon}/>
139
+ <CapHeading type="h4" style={{position: 'absolute', display: 'inline-block', top: '13px', paddingLeft: '10px'}}>
140
+ {message}
141
+ </CapHeading>
142
+ </CapRow>
143
+ <CapDivider className="cap-divider-margin"/>
144
+ <CapRow style={{ padding: `0 ${CAP_SPACE_24} 22px` }}>
145
+ {data}
146
+ </CapRow>
147
+ </CapRow>);
148
+
149
+ // ******************** Text area Code start here ******************************
150
+
151
+ // Tags Code start from here
152
+ useEffect(() => {
153
+ const type = location && location.query && location.query.type;
154
+ const getTagsQuery = {
155
+ layout: 'LINE',
156
+ type: 'TAG',
157
+ context: type ? 'outbound' : 'default',
158
+ embedded: type || 'full',
159
+ };
160
+ globalActions.fetchSchemaForEntity(getTagsQuery);
161
+ }, []);
162
+
163
+ const onTagSelect = (data) => {
164
+ const messageData = `${messageContent}{{${data}}}`;
165
+ updateTextMessageContent(messageData);
166
+ updateTextContentError(messageData);
167
+ };
168
+
169
+ const handleOnTagsContextChange = (data) => {
170
+ const query = {
171
+ layout: 'LINE',
172
+ type: 'TAG',
173
+ context:
174
+ (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
175
+ embedded:
176
+ location.query.type === 'embedded'
177
+ ? location.query.type
178
+ : 'full',
179
+ };
180
+ globalActions.fetchSchemaForEntity(query);
181
+ };
182
+
183
+ const tags = metaEntities && metaEntities.tags
184
+ ? metaEntities.tags.standard
185
+ : [];
186
+
187
+ // tags Code end here
188
+
189
+ // validation on Text area and tags validation
190
+ const updateTextContentError = (value) => {
191
+ let errorMessage = false;
192
+ const { valid } = validateTags({
193
+ content: value,
194
+ tagsParam: tags,
195
+ injectedTagsParams: injectedTags,
196
+ location,
197
+ tagModule: 'outbound',
198
+ }) || {};
199
+ if (value.trim() === '') {
200
+ errorMessage = formatMessage(messages.emptyContentErrorMessage);
201
+ } else if (value.length > charLimit) {
202
+ errorMessage = formatMessage(messages.limitExceededContentErrorMessage);
203
+ } else if (!valid) {
204
+ errorMessage = formatMessage(messages.invalidTagError);
205
+ }
206
+ updateErrorMessageTextArea(errorMessage);
207
+ };
208
+
209
+ // on change event of Text Area
210
+ const onTextContentChange = ({ target: { value } }) => {
211
+ updateTextMessageContent(value);
212
+ updateTextContentError(value);
213
+ };
214
+
215
+ const onTextTitleChange = ({ target: { value } }) => {
216
+ updateTextMessageTitle(value);
217
+ updateTextTitleError(value);
218
+ };
219
+
220
+ const updateTextTitleError = (value) => {
221
+ let errorMessage = false;
222
+ if (value === '') {
223
+ errorMessage = formatMessage(messages.emptyTitleErrorMessage);
224
+ }
225
+ updateErrorMessageTitle(errorMessage);
226
+ };
227
+ // Text Area container
228
+ const TextAreaViber = (<>
229
+ <TextArea
230
+ id={'viber_textarea'}
231
+ label={(
232
+ <>
233
+ <FormattedMessage {...messages.textMessage} />
234
+ <CapLabel
235
+ type="label2" style={{display: 'inline-block',
236
+ float: 'right'}}>
237
+ {(messageContent || '').length}/{charLimit} {" "}
238
+ <FormattedMessage {...messages.characters} />
239
+
240
+ </CapLabel>
241
+ </>
242
+ )}
243
+ autosize={false}
244
+ onChange={onTextContentChange}
245
+ className={`${errorMessageTextarea ? 'error' : ''}`}
246
+ errorMessage={errorMessageTextarea}
247
+ defaultValue={messageContent || ''}
248
+ value={messageContent || ''}
249
+ rows={5}
250
+ cols={2}
251
+ />
252
+ <TagList
253
+ key={'viber_tags'}
254
+ moduleFilterEnabled={location && location.query && location.query.type !== 'embedded'}
255
+ label={formatMessage(messages.addLabels)}
256
+ onTagSelect={onTagSelect}
257
+ onContextChange={handleOnTagsContextChange}
258
+ location={location}
259
+ tags={tags}
260
+ injectedTags={injectedTags || {}}
261
+ id={'viber_tags'}
262
+ userLocale={localStorage.getItem('jlocale') || 'en'}
263
+ />
264
+ </>);
265
+
266
+ // ******************** Text area Code End here ******************************
267
+
268
+ // ******************** Image section Code start here ******************************
269
+ useEffect(() => {
270
+ if (viber[`uploadedAssetData0`] && Object.keys(viber[`uploadedAssetData0`]).length) {
271
+ const imgSrc = get(viber, `uploadedAssetData0.metaInfo.secure_file_path`, '');
272
+ actions.clearViberAsset(0);
273
+ if (imgSrc) {
274
+ updateImageSrc(imgSrc);
275
+ updateImageStatus(true);
276
+ }
277
+ }
278
+ }, [viber[`uploadedAssetData0`]]);
279
+
280
+ const submitAction = (data, incorrectFile) => {
281
+ const {
282
+ file: {size},
283
+ fileParams: {
284
+ height,
285
+ width,
286
+ },
287
+ } = data;
288
+ if (incorrectFile || size > VIBER_IMG_SIZE || height > VIBER_IMG_HEIGHT || width > VIBER_IMG_WIDTH) {
289
+ updateImageErrorMessage(formatMessage(messages.viberImageIncorrectSize));
290
+ } else {
291
+ updateImageErrorMessage('');
292
+ actions.uploadViberAsset(
293
+ data.file,
294
+ data.type,
295
+ data.fileParams,
296
+ 0,
297
+ );
298
+ }
299
+ };
300
+
301
+ const uploadImages = (e, {files}) => {
302
+ if (e) {
303
+ e.preventDefault();
304
+ }
305
+ const _URL = window.URL || window.webkitURL;
306
+ let incorrectFile = false;
307
+ const file = files[0];
308
+ if (!ALLOWED_EXTENSIONS_REGEX.test(file.name)) {
309
+ incorrectFile = true;
310
+ }
311
+ const img = new Image();
312
+ img.src = _URL.createObjectURL(file);
313
+ img.onload = () => {
314
+ const fileParams = {
315
+ width: img.width,
316
+ height: img.height,
317
+ error: file && (file.size / (1e+6) > 3),
318
+ };
319
+ submitAction({file, type: 'image', fileParams}, incorrectFile);
320
+ };
321
+ if (e) {
322
+ const event = e;
323
+ event.target.value = null;
324
+ }
325
+ };
326
+
327
+ const ImageComponent = () => (<>
328
+ <CapHeader
329
+ title={formatMessage(messages.uploadImage)}
330
+ description={formatMessage(messages.imageDesc)}
331
+ size="regular"
332
+ />
333
+ <div
334
+ className={`image-container ${props.ifError ? 'error' : ''}`}
335
+ style={{
336
+ marginTop: 20,
337
+ backgroundColor: CAP_G09,
338
+ }}
339
+ >
340
+ {isImage && (<CapImage src={imageSrc} alt="viber-image-src" height="400" />)}
341
+ </div></>
342
+ );
343
+
344
+ const setDrawerVisibility = (drawervisibleFlag) => updateDrawerRequirement(drawervisibleFlag);
345
+
346
+ const onGalleryClick = (event) => {
347
+ event.stopPropagation();
348
+ setDrawerVisibility(true);
349
+ };
350
+
351
+ const capUploaderCustomRequest = (uploadData) => {
352
+ uploadImages(undefined, {files: [uploadData.file]});
353
+ };
354
+ const onReUpload = () => {
355
+ updateImageStatus(false);
356
+ // deleteUploadedImgList(index);
357
+ updateImageSrc('');
358
+ updateImagePreview('');
359
+ };
360
+ const getViberImageSection = () => {
361
+ if (!isImage) {
362
+ return (<>
363
+ <CapUploader.CapDragger
364
+ customRequest={capUploaderCustomRequest}
365
+ className="form-builder-dragger"
366
+ >
367
+ <CapHeading className="dragger-title" type="h7">
368
+ <FormattedMessage {...messages.dragAndDrop} />
369
+ </CapHeading>
370
+ <CapHeading className="dragger-or" type="label6">
371
+ <FormattedMessage {...messages.or} />
372
+ </CapHeading>
373
+ <CapButton className="dragger-button" type="secondary" style={{marginRight: CAP_SPACE_08}}>
374
+ <FormattedMessage {...messages.uploadComputer} />
375
+ </CapButton>
376
+ <CapButton
377
+ className="dragger-button"
378
+ type="secondary"
379
+ style={{marginLeft: CAP_SPACE_08}}
380
+ onClick={onGalleryClick}
381
+ >
382
+ <FormattedMessage {...messages.uploadGallery} />
383
+ </CapButton>
384
+ </CapUploader.CapDragger>
385
+ <div style={{marginTop: '15px' }}>
386
+ <CapHeadingSpan type="label2" style={{marginTop: CAP_SPACE_12, marginRight: '46px' }}>
387
+ <FormattedMessage {...messages.imageDimenstionDescription} />
388
+ </CapHeadingSpan>
389
+ <CapHeadingSpan type="label2" style={{marginTop: CAP_SPACE_12 }}>
390
+ <FormattedMessage {...messages.imageSizeDescription} />
391
+ </CapHeadingSpan>
392
+ </div>
393
+
394
+ </>
395
+ );
396
+ }
397
+ return (
398
+ <CapButton
399
+ className="dragger-button"
400
+ type="flat"
401
+ style={{
402
+ top: 0,
403
+ position: 'absolute',
404
+ right: 0,
405
+ color: FONT_COLOR_05,
406
+ }}
407
+ onClick={onReUpload}
408
+ >
409
+ <FormattedMessage {...messages.imageReUpload} />
410
+ </CapButton>
411
+ );
412
+ };
413
+
414
+ const getGalleryDrawerContent = () => {
415
+ const locationGallery = {
416
+ pathname: `/assets`,
417
+ search: '',
418
+ query: !isFullMode ? {type: 'embedded', module: 'library'} : {},
419
+ };
420
+ return (
421
+ <>
422
+ <CapHeading type="h3">
423
+ {formatMessage(messages.imageGallery)}
424
+ </CapHeading>
425
+ <Gallery
426
+ location={locationGallery}
427
+ isFullMode={isFullMode}
428
+ isLineAsset
429
+ onGalleryImageSelect={onGalleryImageSelect}
430
+ />
431
+ </>
432
+ );
433
+ };
434
+
435
+ const onGalleryImageSelect = (imageTemplate) => {
436
+ const image = get(imageTemplate, 'metaInfo.secure_file_path');
437
+ const imageURL = get(imageTemplate, 'metaInfo.secure_file_path_preview');
438
+ updateDrawerRequirement(false);
439
+ if (!ALLOWED_EXTENSIONS_REGEX.test(image)) {
440
+ updateImageErrorMessage(formatMessage(messages.viberImageIncorrectSize));
441
+ } else {
442
+ updateImageErrorMessage('');
443
+ updateImageStatus(true);
444
+ updateImageSrc(image);
445
+ updateImagePreview(imageURL);
446
+ }
447
+ };
448
+
449
+ const WithLabel = LabelHOC(ImageComponent);
450
+ const ImageViber = <>
451
+ <WithLabel
452
+ key={`viber-with-label`}
453
+ errorMessage={isImageError} ifError={!!isImageError}
454
+ />
455
+ <form encType="multipart/form-data" id={`viber_form`}>
456
+ <input
457
+ key={`viber_imgFile`}
458
+ style={{ display: 'none' }}
459
+ id="fileName"
460
+ type="file"
461
+ onChange={(e) => uploadImages(e, { files: e.target.files })}
462
+ accept={supportedExtensions || "image/*"}
463
+ />
464
+ {getViberImageSection()}
465
+ <CapDrawer
466
+ content={getGalleryDrawerContent()}
467
+ visible={isDrawerRequired}
468
+ width={430}
469
+ onClose={() => updateDrawerRequirement(false)}
470
+ />
471
+ </form>
472
+ </>;
473
+ // ******************** Image section End here ******************************
474
+
475
+
476
+ // ******************** Button Code start here ******************************
477
+
478
+ const onChangeButtonText = ({ target: { value } }) => {
479
+ updateButtonText(value);
480
+ };
481
+
482
+ const onChangeButtonUrl = ({ target: { value } }) => {
483
+ updateButtonUrl(value);
484
+ };
485
+ const getPreviewSection = () =>
486
+ // const accountName = get(lineData, 'selectedLineAccount.name', '');
487
+ (
488
+ <TemplatePreview
489
+ channel="VIBER"
490
+ content={{imageURL: imagePreview, buttonText, messageContent}}
491
+ viberAccountName={"MUJI"}
492
+ />
493
+ );
494
+
495
+ const ButtonViber = (<>
496
+ <CapInput
497
+ id="viber-button-text"
498
+ type="input" onChange={onChangeButtonText}
499
+ label={formatMessage(messages.buttonText)}
500
+ defaultValue={buttonText}
501
+ value={buttonText}
502
+ style={{paddingBottom: '11px'}}
503
+ />
504
+ <CapInput
505
+ id="viber-button-url"
506
+ type="input"
507
+ onChange={onChangeButtonUrl}
508
+ defaultValue={buttonURL}
509
+ value={buttonURL}
510
+ label={formatMessage(messages.buttonUrl)}
511
+ />
512
+ </>);
513
+
514
+ // ******************** Button Code End here ******************************
515
+ const formatSubmitPayload = () => {
516
+ const messageData = {
517
+ text: messageContent,
518
+ };
519
+ if (imageSrc) {
520
+ messageData.imageURL = imageSrc;
521
+ }
522
+ if (buttonText && buttonURL) {
523
+ messageData.buttonText = buttonText;
524
+ messageData.buttonURL = buttonURL;
525
+ }
526
+ return {
527
+ versions: {
528
+ base: {
529
+ content: {
530
+ destinations: [
531
+ {
532
+ to: {
533
+ phoneNumber: "{{viber_user_id}}",
534
+ },
535
+ },
536
+ ],
537
+ viber: {...messageData},
538
+ },
539
+ },
540
+ },
541
+ type: "VIBER",
542
+ name: messageTitle,
543
+ };
544
+ };
545
+
546
+ const createCallback = (errorMessage, isEdit) => {
547
+ if (!errorMessage) {
548
+ CapNotification.success({
549
+ message: formatMessage(messages.viberCreateNotification),
550
+ });
551
+ if (isEdit) {
552
+ actions.clearEditResponse();
553
+ } else {
554
+ actions.clearCreateResponse();
555
+ }
556
+ } else {
557
+ CapNotification.error({
558
+ message: errorMessage,
559
+ });
560
+ }
561
+ };
562
+
563
+ const onCreateViber = () => {
564
+ actions.createTemplate(
565
+ formatSubmitPayload(),
566
+ (resp, errorMessage) => {
567
+ createCallback(errorMessage);
568
+ onCreateComplete();
569
+ }
570
+ );
571
+ };
572
+
573
+ const onEditViber = () => {
574
+ actions.editTemplate(
575
+ {
576
+ ...formatSubmitPayload(),
577
+ _id: params.id,
578
+ },
579
+ (resp, errorMessage) => {
580
+ createCallback(errorMessage, true);
581
+ onCreateComplete();
582
+ });
583
+ };
584
+ const onDoneCallback = () => {
585
+ if (isFullMode) {
586
+ if (isEditFlow) {
587
+ return onEditViber;
588
+ }
589
+ return onCreateViber;
590
+ }
591
+ return '';
592
+ };
593
+
594
+ const isDisableDone = () => {
595
+ // textbox area should not empty and should have max 1000 charactor
596
+ if (messageContent.trim() === '' || errorMessageTextarea) {
597
+ return true;
598
+ }
599
+ // cannot send text + image only messages, Need to add button details or remove one of the components in order to proceed
600
+ const trimedButtonText = buttonText.trim();
601
+ const trimedButtonUrl = buttonURL.trim();
602
+ if (messageContent !== '' && imageSrc && (trimedButtonUrl === '' && trimedButtonUrl === '')) {
603
+ return true;
604
+ }
605
+ // if button is being added than button url and button Text both are mandatory
606
+ if (( trimedButtonText === '' && trimedButtonUrl !== '') || ( trimedButtonUrl !== '' && trimedButtonUrl === '')) {
607
+ return true;
608
+ }
609
+ return false;
610
+ };
611
+
612
+ return (
613
+ <>
614
+ <CapSpin spinning={isEditLoading}>
615
+ <CapRow>
616
+ <CapColumn span={14}>
617
+ <StyledHeader
618
+ title={formatMessage(messages.viberCreativeTitle)}
619
+ description={formatMessage(messages.viberCreativeDesc)}
620
+ size="regular"
621
+ />
622
+ {
623
+ isFullMode
624
+ ? (
625
+ <CapInput
626
+ id={`viber_input`}
627
+ onChange={onTextTitleChange}
628
+ errorMessage={errorMessageTitle}
629
+ className="text-template-title"
630
+ placeholder={formatMessage(messages.textMessageTitlePlaceholder)}
631
+ defaultValue={messageTitle || ''}
632
+ value={messageTitle || ''}
633
+ size="default"
634
+ label={formatMessage(messages.textMessageTitleLabel)}
635
+ style={{marginBottom: 20}}
636
+ />
637
+ )
638
+ : null
639
+ }
640
+ {container("message", <FormattedMessage {...messages.message} />, TextAreaViber)}
641
+ {container("image", <FormattedMessage {...messages.image} />, ImageViber)}
642
+ {container("button", <FormattedMessage {...messages.button} />, ButtonViber)}
643
+ <div style={{marginBottom: '100px'}}/>
644
+ </CapColumn>
645
+ <CapColumn span={6}>
646
+ <CapRow>
647
+ <CapColumn span={23} offset={6}>
648
+ {getPreviewSection()}
649
+ <CapHeading
650
+ type="h3"
651
+ style={{margin: '24px 0px 0px 28px'}}
652
+ >
653
+ <FormattedMessage {...messages.message} />: {" "}
654
+ ({(messageContent || '').length}/{charLimit} {" "}
655
+ <FormattedMessage {...messages.characters} />)
656
+ </CapHeading>
657
+ </CapColumn>
658
+ </CapRow>
659
+ </CapColumn>
660
+ </CapRow>
661
+ <ViberFooter>
662
+ <CapButton
663
+ onClick={onDoneCallback()}
664
+ disabled={isDisableDone()}
665
+ className="create-msg"
666
+ >
667
+ <FormattedMessage {...messages.doneButtonLabel} />
668
+ </CapButton>
669
+ <CapButton
670
+ onClick={handleClose}
671
+ className="cancel-msg"
672
+ type="secondary"
673
+ >
674
+ <FormattedMessage {...messages.cancelButtonLabel} />
675
+ </CapButton>
676
+ </ViberFooter>
677
+ </CapSpin>
678
+
679
+ </>
680
+ );
681
+ };
682
+
683
+ const mapStateToProps = createStructuredSelector({
684
+ metaEntities: makeSelectMetaEntities(),
685
+ injectedTags: setInjectedTags(),
686
+ viberData: makeSelectViber(),
687
+ viber: makeSelectCreateViber(),
688
+ });
689
+
690
+ const mapDispatchToProps = (dispatch) => ({
691
+ actions: bindActionCreators(viberActions, dispatch),
692
+ });
693
+
694
+
695
+ export default withCreatives({
696
+ WrappedComponent: injectIntl(Viber),
697
+ mapStateToProps,
698
+ mapDispatchToProps,
699
+ userAuth: true,
700
+ });