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