@capillarytech/creatives-library 7.12.50 → 7.12.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/app.js +0 -1
- package/package.json +1 -1
- package/services/api.js +15 -2
- package/v2Components/CapImageUpload/index.js +33 -17
- package/v2Components/CapImageUpload/messages.js +11 -3
- package/v2Components/CapWhatsappCTA/constants.js +12 -1
- package/v2Components/CapWhatsappCTA/index.js +88 -29
- package/v2Components/CapWhatsappCTA/index.scss +4 -6
- package/v2Components/CapWhatsappCTA/messages.js +24 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +9 -8
- package/v2Components/TemplatePreview/index.js +8 -6
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +3 -19
- package/v2Components/TemplatePreview/tests/index.test.js +0 -2
- package/v2Components/WhatsappStatusContainer/index.js +42 -52
- package/v2Containers/Cap/tests/index.test.js +2 -2
- package/v2Containers/CreativesContainer/SlideBoxContent.js +8 -8
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +28 -36
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +165 -344
- package/v2Containers/CreativesContainer/tests/index.test.js +0 -3
- package/v2Containers/Line/Container/ImageCarousel/Content.js +15 -29
- package/v2Containers/Line/Container/ImageCarousel/constants.js +3 -0
- package/v2Containers/Line/Container/ImageCarousel/index.js +28 -40
- package/v2Containers/Line/Container/ImageCarousel/messages.js +2 -2
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +9851 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +21113 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/content.test.js +71 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/index.test.js +58 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/mockData.js +1322 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/utils.test.js +13 -0
- package/v2Containers/Line/Container/ImageCarousel/utils.js +12 -0
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +84451 -0
- package/v2Containers/Line/Container/Wrapper/tests/index.test.js +58 -0
- package/v2Containers/Line/Container/Wrapper/tests/mockData.js +171 -0
- package/v2Containers/Line/Container/index.js +5 -1
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +63597 -0
- package/v2Containers/Line/Container/tests/index.test.js +105 -0
- package/v2Containers/Line/Container/tests/mockData.js +1334 -0
- package/v2Containers/Templates/_templates.scss +5 -0
- package/v2Containers/Templates/actions.js +7 -0
- package/v2Containers/Templates/constants.js +9 -1
- package/v2Containers/Templates/index.js +45 -30
- package/v2Containers/Templates/messages.js +1 -1
- package/v2Containers/Templates/reducer.js +15 -0
- package/v2Containers/Templates/sagas.js +32 -0
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1774 -1881
- package/v2Containers/Templates/tests/index.test.js +14 -3
- package/v2Containers/Whatsapp/actions.js +22 -0
- package/v2Containers/Whatsapp/constants.js +56 -23
- package/v2Containers/Whatsapp/index.js +204 -66
- package/v2Containers/Whatsapp/index.scss +18 -2
- package/v2Containers/Whatsapp/messages.js +35 -7
- package/v2Containers/Whatsapp/reducer.js +35 -1
- package/v2Containers/Whatsapp/sagas.js +30 -1
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +44349 -32926
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +15 -21
- package/v2Containers/Whatsapp/utils.js +16 -9
- package/v2Containers/mockdata.js +210 -555
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/jsx-boolean-value */
|
|
2
2
|
/* eslint-disable camelcase */
|
|
3
3
|
/* eslint-disable no-undef */
|
|
4
|
-
import React, { useState, useEffect } from 'react';
|
|
4
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
5
5
|
import { bindActionCreators } from 'redux';
|
|
6
6
|
import { createStructuredSelector } from 'reselect';
|
|
7
7
|
import { injectIntl, FormattedMessage } from 'react-intl';
|
|
@@ -43,7 +43,8 @@ import {
|
|
|
43
43
|
UNSUBSCRIBE_TEXT_LENGTH,
|
|
44
44
|
TEMPLATE_MESSAGE_MAX_LENGTH,
|
|
45
45
|
WHATSAPP,
|
|
46
|
-
|
|
46
|
+
TWILIO_CATEGORY_OPTIONS,
|
|
47
|
+
KARIX_CATEGORY_OPTIONS,
|
|
47
48
|
LANGUAGE_OPTIONS,
|
|
48
49
|
WHATSAPP_STATUSES,
|
|
49
50
|
TAG,
|
|
@@ -55,14 +56,19 @@ import {
|
|
|
55
56
|
WHATSAPP_MEDIA_TYPES,
|
|
56
57
|
WHATSAPP_BUTTON_TYPES,
|
|
57
58
|
INITIAL_CTA_DATA,
|
|
59
|
+
ALLOWED_IMAGE_EXTENSIONS_REGEX,
|
|
60
|
+
WHATSAPP_IMG_SIZE,
|
|
61
|
+
HOST_KARIX,
|
|
58
62
|
} from './constants';
|
|
59
63
|
import { DATE_DISPLAY_FORMAT, TIME_DISPLAY_FORMAT } from '../App/constants';
|
|
60
64
|
import messages from './messages';
|
|
61
65
|
import globalMessages from '../Cap/messages';
|
|
62
66
|
import withCreatives from '../../hoc/withCreatives';
|
|
63
67
|
import TemplatePreview from '../../v2Components/TemplatePreview';
|
|
68
|
+
import CapImageUpload from '../../v2Components/CapImageUpload';
|
|
64
69
|
import TagList from '../TagList';
|
|
65
70
|
import { validateTags } from '../../utils/tagValidations';
|
|
71
|
+
import { capitalizeString } from '../../utils/Formatter';
|
|
66
72
|
import CapWhatsappCTA from '../../v2Components/CapWhatsappCTA';
|
|
67
73
|
import {
|
|
68
74
|
PHONE_NUMBER,
|
|
@@ -104,14 +110,19 @@ export const Whatsapp = (props) => {
|
|
|
104
110
|
const [templateLanguage, setTemplateLanguage] = useState(
|
|
105
111
|
formatMessage(messages.select),
|
|
106
112
|
);
|
|
113
|
+
const [templateMediaType, setTemplateMediaType] = useState(
|
|
114
|
+
WHATSAPP_MEDIA_TYPES.TEXT,
|
|
115
|
+
);
|
|
107
116
|
const [templateMessage, setTemplateMessage] = useState('');
|
|
108
117
|
const [templateMessageError, setTemplateMessageError] = useState(false);
|
|
109
118
|
const [addedVarCount, setAddedVarCount] = useState(0);
|
|
110
119
|
const [accountId, setAccountId] = useState('');
|
|
111
120
|
const [accessToken, setAccessToken] = useState('');
|
|
112
|
-
const [
|
|
121
|
+
const [host, setHost] = useState('');
|
|
113
122
|
const [spin, setSpin] = useState(false);
|
|
114
123
|
const [unsubscribeRequired, setUnsubscribeRequired] = useState(false);
|
|
124
|
+
const [whatsappImageSrc, setWhatsappImageSrc] = useState('');
|
|
125
|
+
const [karixFileHandle, setKarixFileHandle] = useState('');
|
|
115
126
|
//for edit only
|
|
116
127
|
const [isEditFlow, setEditFlow] = useState(false);
|
|
117
128
|
const [templateDate, setTemplateDate] = useState('');
|
|
@@ -129,6 +140,8 @@ export const Whatsapp = (props) => {
|
|
|
129
140
|
|
|
130
141
|
const validVarRegex = /{{([1-9]|1[0-9])}}/g;
|
|
131
142
|
|
|
143
|
+
const isBtnTypeCta = buttonType === WHATSAPP_BUTTON_TYPES.CTA;
|
|
144
|
+
const isMediaTypeImage = templateMediaType === WHATSAPP_MEDIA_TYPES.IMAGE;
|
|
132
145
|
const WhatsappFooter = styled.div`
|
|
133
146
|
background-color: ${CAP_WHITE};
|
|
134
147
|
position: fixed;
|
|
@@ -148,14 +161,17 @@ export const Whatsapp = (props) => {
|
|
|
148
161
|
useEffect(() => {
|
|
149
162
|
const accountObj = accountData.selectedWhatsappAccount || {};
|
|
150
163
|
if (!isEmpty(accountObj)) {
|
|
151
|
-
const {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
164
|
+
const { connectionProperties = {}, hostName = '' } = accountObj;
|
|
165
|
+
if (hostName === HOST_KARIX) {
|
|
166
|
+
const { authToken = '', wabaId = '' } = connectionProperties;
|
|
167
|
+
setAccessToken(authToken);
|
|
168
|
+
setAccountId(wabaId);
|
|
169
|
+
} else {
|
|
170
|
+
const { auth_token = '', account_sid = '' } = connectionProperties;
|
|
171
|
+
setAccessToken(auth_token);
|
|
172
|
+
setAccountId(account_sid);
|
|
173
|
+
}
|
|
174
|
+
setHost(hostName);
|
|
159
175
|
}
|
|
160
176
|
}, [accountData.selectedWhatsappAccount]);
|
|
161
177
|
|
|
@@ -192,6 +208,9 @@ export const Whatsapp = (props) => {
|
|
|
192
208
|
status = WHATSAPP_STATUSES.unsubmitted,
|
|
193
209
|
rejection_reason = null,
|
|
194
210
|
languages = [],
|
|
211
|
+
mediaType = WHATSAPP_MEDIA_TYPES.TEXT,
|
|
212
|
+
imageUrl = '',
|
|
213
|
+
karixFileHandle = '',
|
|
195
214
|
buttonType: btnType = WHATSAPP_BUTTON_TYPES.NONE,
|
|
196
215
|
buttons = [],
|
|
197
216
|
} = editContent;
|
|
@@ -199,6 +218,9 @@ export const Whatsapp = (props) => {
|
|
|
199
218
|
setTemplateStatus(status);
|
|
200
219
|
setTemplateRejectionReason(rejection_reason);
|
|
201
220
|
setTemplateLanguage(languages[0]?.language);
|
|
221
|
+
setTemplateMediaType(mediaType);
|
|
222
|
+
setWhatsappImageSrc(imageUrl);
|
|
223
|
+
setKarixFileHandle(karixFileHandle);
|
|
202
224
|
setButtonType(btnType);
|
|
203
225
|
if (btnType === WHATSAPP_BUTTON_TYPES.CTA && buttons.length > 0) {
|
|
204
226
|
setCtadata(
|
|
@@ -407,7 +429,12 @@ export const Whatsapp = (props) => {
|
|
|
407
429
|
</CapRow>
|
|
408
430
|
);
|
|
409
431
|
|
|
410
|
-
const
|
|
432
|
+
const karixCategoryOptions = KARIX_CATEGORY_OPTIONS.map((option) => ({
|
|
433
|
+
value: option.value,
|
|
434
|
+
label: renderTemplateCategoryLabel(option.tooltipLabel, option.label),
|
|
435
|
+
}));
|
|
436
|
+
|
|
437
|
+
const twilioCategoryOptions = TWILIO_CATEGORY_OPTIONS.map((option) => ({
|
|
411
438
|
value: option.value,
|
|
412
439
|
label: renderTemplateCategoryLabel(option.tooltipLabel, option.label),
|
|
413
440
|
}));
|
|
@@ -415,16 +442,22 @@ export const Whatsapp = (props) => {
|
|
|
415
442
|
const mediaRadioOptions = [
|
|
416
443
|
{
|
|
417
444
|
value: WHATSAPP_MEDIA_TYPES.TEXT,
|
|
418
|
-
label: formatMessage(messages.
|
|
445
|
+
label: formatMessage(messages.mediaText),
|
|
419
446
|
},
|
|
420
447
|
{
|
|
421
448
|
value: WHATSAPP_MEDIA_TYPES.IMAGE,
|
|
422
449
|
label: (
|
|
423
|
-
<CapTooltip
|
|
450
|
+
<CapTooltip
|
|
451
|
+
title={
|
|
452
|
+
host !== HOST_KARIX
|
|
453
|
+
? formatMessage(messages.disabledFeatureTooltip)
|
|
454
|
+
: ''
|
|
455
|
+
}
|
|
456
|
+
>
|
|
424
457
|
{formatMessage(messages.mediaImage)}
|
|
425
458
|
</CapTooltip>
|
|
426
459
|
),
|
|
427
|
-
disabled:
|
|
460
|
+
disabled: host !== HOST_KARIX,
|
|
428
461
|
},
|
|
429
462
|
{
|
|
430
463
|
value: WHATSAPP_MEDIA_TYPES.VIDEO,
|
|
@@ -435,6 +468,15 @@ export const Whatsapp = (props) => {
|
|
|
435
468
|
),
|
|
436
469
|
disabled: true,
|
|
437
470
|
},
|
|
471
|
+
{
|
|
472
|
+
value: WHATSAPP_MEDIA_TYPES.DOCUMENT,
|
|
473
|
+
label: (
|
|
474
|
+
<CapTooltip title={formatMessage(messages.disabledFeatureTooltip)}>
|
|
475
|
+
{formatMessage(messages.mediaDocument)}
|
|
476
|
+
</CapTooltip>
|
|
477
|
+
),
|
|
478
|
+
disabled: true,
|
|
479
|
+
},
|
|
438
480
|
];
|
|
439
481
|
|
|
440
482
|
const onChangeButtonType = ({ target: { value } }) => {
|
|
@@ -484,11 +526,13 @@ export const Whatsapp = (props) => {
|
|
|
484
526
|
</CapHeading>
|
|
485
527
|
<CapLabel>{formatMessage(messages.ctaDesc)}</CapLabel>
|
|
486
528
|
</div>
|
|
487
|
-
{
|
|
529
|
+
{isBtnTypeCta && (
|
|
488
530
|
<CapWhatsappCTA
|
|
489
531
|
ctaData={ctaData}
|
|
490
532
|
updateHandler={updateHandler}
|
|
491
533
|
deleteHandler={deleteHandler}
|
|
534
|
+
isEditFlow={isEditFlow}
|
|
535
|
+
hostName={host}
|
|
492
536
|
/>
|
|
493
537
|
)}
|
|
494
538
|
</>
|
|
@@ -504,8 +548,7 @@ export const Whatsapp = (props) => {
|
|
|
504
548
|
<div
|
|
505
549
|
className="whatsapp-button-quick-reply"
|
|
506
550
|
style={{
|
|
507
|
-
marginTop:
|
|
508
|
-
buttonType === WHATSAPP_BUTTON_TYPES.CTA ? '0px' : '24px',
|
|
551
|
+
marginTop: isBtnTypeCta ? '0px' : '24px',
|
|
509
552
|
opacity: isEditFlow ? '' : '0.4',
|
|
510
553
|
}}
|
|
511
554
|
>
|
|
@@ -609,17 +652,55 @@ export const Whatsapp = (props) => {
|
|
|
609
652
|
}
|
|
610
653
|
/>
|
|
611
654
|
<CapRadioGroup
|
|
612
|
-
|
|
613
|
-
options={buttonRadioOptions || []}
|
|
655
|
+
options={buttonRadioOptions}
|
|
614
656
|
value={buttonType}
|
|
615
657
|
onChange={onChangeButtonType}
|
|
616
|
-
className=
|
|
617
|
-
isEditFlow ? 'whatsapp-btn-radio-edit' : ''
|
|
618
|
-
}`}
|
|
658
|
+
className="whatsapp-btn-radio-group"
|
|
619
659
|
/>
|
|
620
660
|
</>
|
|
621
661
|
);
|
|
622
662
|
|
|
663
|
+
const uploadWhatsappImage = (file, type, fileParams) => {
|
|
664
|
+
const whatsappParams = {
|
|
665
|
+
source: WHATSAPP.toLowerCase(),
|
|
666
|
+
wabaId: accountId,
|
|
667
|
+
accessToken,
|
|
668
|
+
};
|
|
669
|
+
actions.uploadWhatsappAsset(file, type, fileParams, 0, whatsappParams);
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
const setUpdateWhatsappImageSrc = useCallback(
|
|
673
|
+
(filePath, fileHandle) => {
|
|
674
|
+
setWhatsappImageSrc(filePath);
|
|
675
|
+
setKarixFileHandle(fileHandle);
|
|
676
|
+
actions.clearWhatsappAsset(0);
|
|
677
|
+
},
|
|
678
|
+
[whatsappImageSrc],
|
|
679
|
+
);
|
|
680
|
+
|
|
681
|
+
const updateOnWhatsappImageReUpload = useCallback(() => {
|
|
682
|
+
setWhatsappImageSrc('');
|
|
683
|
+
setKarixFileHandle('');
|
|
684
|
+
}, [whatsappImageSrc]);
|
|
685
|
+
|
|
686
|
+
const renderImageComponent = () => (
|
|
687
|
+
<CapImageUpload
|
|
688
|
+
style={{ paddingTop: '20px' }}
|
|
689
|
+
allowedExtensionsRegex={ALLOWED_IMAGE_EXTENSIONS_REGEX}
|
|
690
|
+
imgSize={WHATSAPP_IMG_SIZE}
|
|
691
|
+
uploadAsset={uploadWhatsappImage}
|
|
692
|
+
isFullMode={isFullMode}
|
|
693
|
+
imageSrc={whatsappImageSrc}
|
|
694
|
+
updateImageSrc={setUpdateWhatsappImageSrc}
|
|
695
|
+
updateOnReUpload={updateOnWhatsappImageReUpload}
|
|
696
|
+
index={0}
|
|
697
|
+
className="cap-custom-image-upload"
|
|
698
|
+
key="whatsapp-uploaded-image"
|
|
699
|
+
imageData={editData}
|
|
700
|
+
channel={WHATSAPP}
|
|
701
|
+
/>
|
|
702
|
+
);
|
|
703
|
+
|
|
623
704
|
const onTemplateNameChange = ({ target: { value } }) => {
|
|
624
705
|
setTemplateName(value);
|
|
625
706
|
templateNameErrorHandler(value);
|
|
@@ -647,6 +728,10 @@ export const Whatsapp = (props) => {
|
|
|
647
728
|
setTemplateLanguage(value);
|
|
648
729
|
};
|
|
649
730
|
|
|
731
|
+
const onTemplateMediaTypeChange = ({ target: { value } }) => {
|
|
732
|
+
setTemplateMediaType(value);
|
|
733
|
+
};
|
|
734
|
+
|
|
650
735
|
const onAddVar = () => {
|
|
651
736
|
const validVarArr = templateMessage.match(validVarRegex) || [];
|
|
652
737
|
const tempMsg = `${templateMessage}{{${validVarArr.length + 1}}}`;
|
|
@@ -765,16 +850,20 @@ export const Whatsapp = (props) => {
|
|
|
765
850
|
content: getPayloadContent(),
|
|
766
851
|
},
|
|
767
852
|
],
|
|
768
|
-
...(
|
|
853
|
+
...(isBtnTypeCta && {
|
|
769
854
|
buttonType,
|
|
770
855
|
buttons: getCtaPayload(),
|
|
771
856
|
}),
|
|
772
|
-
mediaType:
|
|
857
|
+
mediaType: templateMediaType,
|
|
858
|
+
...(isMediaTypeImage && {
|
|
859
|
+
imageUrl: whatsappImageSrc,
|
|
860
|
+
karixFileHandle,
|
|
861
|
+
}),
|
|
773
862
|
varMapped: !isFullMode ? varMap : {},
|
|
774
863
|
templateEditor: !isFullMode && tempMsgArray.join(''),
|
|
775
864
|
accountId,
|
|
776
865
|
accessToken,
|
|
777
|
-
|
|
866
|
+
hostName: host,
|
|
778
867
|
},
|
|
779
868
|
},
|
|
780
869
|
},
|
|
@@ -782,7 +871,7 @@ export const Whatsapp = (props) => {
|
|
|
782
871
|
type: WHATSAPP,
|
|
783
872
|
});
|
|
784
873
|
|
|
785
|
-
const actionCallback = ({ errorMessage
|
|
874
|
+
const actionCallback = ({ errorMessage }) => {
|
|
786
875
|
const error = errorMessage?.message || errorMessage;
|
|
787
876
|
if (!error) {
|
|
788
877
|
CapNotification.success({
|
|
@@ -842,24 +931,41 @@ export const Whatsapp = (props) => {
|
|
|
842
931
|
if (templateMessage.trim() === '' || templateMessageError) {
|
|
843
932
|
return true;
|
|
844
933
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
//if button type is cta and 1st button is saved
|
|
849
|
-
return false;
|
|
850
|
-
} else if (
|
|
851
|
-
ctaData.length === 2 &&
|
|
852
|
-
ctaData[0].isSaved &&
|
|
853
|
-
ctaData[1].isSaved
|
|
854
|
-
) {
|
|
855
|
-
//if button type is cta and 2nd button is saved
|
|
856
|
-
return false;
|
|
934
|
+
//if media type is image and image is not uploaded
|
|
935
|
+
if (isMediaTypeImage && karixFileHandle === '') {
|
|
936
|
+
return true;
|
|
857
937
|
}
|
|
858
|
-
//
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
938
|
+
//cta
|
|
939
|
+
if (isBtnTypeCta) {
|
|
940
|
+
if (ctaData.length === 1 && ctaData[0].isSaved) {
|
|
941
|
+
//if button type is cta and 1st button is saved
|
|
942
|
+
return false;
|
|
943
|
+
} else if (
|
|
944
|
+
ctaData.length === 2 &&
|
|
945
|
+
ctaData[0].isSaved &&
|
|
946
|
+
ctaData[1].isSaved
|
|
947
|
+
) {
|
|
948
|
+
//if button type is cta and 2nd button is saved
|
|
949
|
+
return false;
|
|
950
|
+
}
|
|
951
|
+
//if button type is cta and there are no buttons saved
|
|
952
|
+
return true;
|
|
953
|
+
}
|
|
954
|
+
return false;
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
const renderMediaSection = () => (
|
|
958
|
+
<>
|
|
959
|
+
{renderLabel('mediaLabel')}
|
|
960
|
+
<CapRadioGroup
|
|
961
|
+
id="whatsapp-media-radio"
|
|
962
|
+
options={mediaRadioOptions}
|
|
963
|
+
value={templateMediaType}
|
|
964
|
+
onChange={onTemplateMediaTypeChange}
|
|
965
|
+
className="whatsapp-media-radio"
|
|
966
|
+
/>
|
|
967
|
+
</>
|
|
968
|
+
);
|
|
863
969
|
|
|
864
970
|
const createModeContent = (
|
|
865
971
|
<>
|
|
@@ -896,7 +1002,9 @@ export const Whatsapp = (props) => {
|
|
|
896
1002
|
{renderLabel('templateCategoryLabel')}
|
|
897
1003
|
<CapSelect
|
|
898
1004
|
id="select-whatsapp-category"
|
|
899
|
-
options={
|
|
1005
|
+
options={
|
|
1006
|
+
host === HOST_KARIX ? karixCategoryOptions : twilioCategoryOptions
|
|
1007
|
+
}
|
|
900
1008
|
onChange={onTemplateCategoryChange}
|
|
901
1009
|
value={templateCategory}
|
|
902
1010
|
/>
|
|
@@ -909,13 +1017,11 @@ export const Whatsapp = (props) => {
|
|
|
909
1017
|
value={templateLanguage}
|
|
910
1018
|
/>
|
|
911
1019
|
{/* template media type */}
|
|
912
|
-
{
|
|
913
|
-
|
|
914
|
-
options={mediaRadioOptions || []}
|
|
915
|
-
defaultValue={WHATSAPP_MEDIA_TYPES.TEXT}
|
|
916
|
-
/>
|
|
1020
|
+
{renderMediaSection()}
|
|
1021
|
+
{isMediaTypeImage && renderImageComponent()}
|
|
917
1022
|
{/* template message create flow */}
|
|
918
1023
|
<CapHeader
|
|
1024
|
+
className={`${isMediaTypeImage ? 'whatsapp-heading-spacing' : ''}`}
|
|
919
1025
|
title={
|
|
920
1026
|
<CapHeading type="h4" className="whatsapp-render-heading">
|
|
921
1027
|
{formatMessage(messages.templateMessageLabel)}
|
|
@@ -952,7 +1058,7 @@ export const Whatsapp = (props) => {
|
|
|
952
1058
|
/>
|
|
953
1059
|
<CapRow className="whatsapp-create-template-message-input">
|
|
954
1060
|
<TextArea
|
|
955
|
-
id=
|
|
1061
|
+
id="whatsapp-create-template-message-input"
|
|
956
1062
|
autosize={{ minRows: 3, maxRows: 5 }}
|
|
957
1063
|
placeholder={formatMessage(messages.templateMessagePlaceholder)}
|
|
958
1064
|
onChange={onTemplateMessageChange}
|
|
@@ -1139,6 +1245,11 @@ export const Whatsapp = (props) => {
|
|
|
1139
1245
|
type={getTemplateStatusType()}
|
|
1140
1246
|
/>
|
|
1141
1247
|
)}
|
|
1248
|
+
{/* template media type */}
|
|
1249
|
+
{renderLabel('mediaLabel')}
|
|
1250
|
+
<CapLabel type="label15">{capitalizeString(templateMediaType)}</CapLabel>
|
|
1251
|
+
{isMediaTypeImage && renderImageComponent()}
|
|
1252
|
+
|
|
1142
1253
|
<CapRow className="whatsapp-render-heading">
|
|
1143
1254
|
<CapHeader
|
|
1144
1255
|
title={
|
|
@@ -1181,13 +1292,26 @@ export const Whatsapp = (props) => {
|
|
|
1181
1292
|
) : (
|
|
1182
1293
|
''
|
|
1183
1294
|
)}
|
|
1184
|
-
|
|
1185
|
-
<
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
<
|
|
1190
|
-
|
|
1295
|
+
{/* button section view in edit mode*/}
|
|
1296
|
+
<CapRow>
|
|
1297
|
+
<CapHeading type="h4" className="whatsapp-render-heading">
|
|
1298
|
+
{formatMessage(messages.btnLabel)}
|
|
1299
|
+
</CapHeading>
|
|
1300
|
+
<CapLabel type="label15">
|
|
1301
|
+
{isBtnTypeCta
|
|
1302
|
+
? formatMessage(messages.btnTypeCTA)
|
|
1303
|
+
: formatMessage(messages.btnTypeNone)}
|
|
1304
|
+
</CapLabel>
|
|
1305
|
+
{isBtnTypeCta && (
|
|
1306
|
+
<CapWhatsappCTA
|
|
1307
|
+
ctaData={ctaData}
|
|
1308
|
+
updateHandler={updateHandler}
|
|
1309
|
+
deleteHandler={deleteHandler}
|
|
1310
|
+
isEditFlow={isEditFlow}
|
|
1311
|
+
hostName={host}
|
|
1312
|
+
/>
|
|
1313
|
+
)}
|
|
1314
|
+
</CapRow>
|
|
1191
1315
|
</>
|
|
1192
1316
|
);
|
|
1193
1317
|
//edit methods end
|
|
@@ -1210,13 +1334,15 @@ export const Whatsapp = (props) => {
|
|
|
1210
1334
|
<TemplatePreview
|
|
1211
1335
|
channel={WHATSAPP}
|
|
1212
1336
|
content={{
|
|
1337
|
+
...(isMediaTypeImage && {
|
|
1338
|
+
whatsappImageSrc,
|
|
1339
|
+
}),
|
|
1213
1340
|
templateMsg,
|
|
1214
|
-
...(
|
|
1341
|
+
...(isBtnTypeCta && {
|
|
1215
1342
|
ctaData,
|
|
1216
1343
|
}),
|
|
1217
1344
|
}}
|
|
1218
1345
|
whatsappContentLen={computeTextLength()}
|
|
1219
|
-
whatsappAccountName={accountName}
|
|
1220
1346
|
/>
|
|
1221
1347
|
);
|
|
1222
1348
|
};
|
|
@@ -1225,6 +1351,7 @@ export const Whatsapp = (props) => {
|
|
|
1225
1351
|
isTagValidationError ||
|
|
1226
1352
|
Object.values(varMap).some((inputValue) => inputValue === '') ||
|
|
1227
1353
|
computeTextLength() > TEMPLATE_MESSAGE_MAX_LENGTH;
|
|
1354
|
+
|
|
1228
1355
|
return (
|
|
1229
1356
|
<CapSpin spinning={spin}>
|
|
1230
1357
|
<CapRow className="cap-whatsapp-creatives">
|
|
@@ -1239,13 +1366,24 @@ export const Whatsapp = (props) => {
|
|
|
1239
1366
|
<WhatsappFooter>
|
|
1240
1367
|
{!isEditFlow && (
|
|
1241
1368
|
<>
|
|
1242
|
-
<
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1369
|
+
<CapTooltip
|
|
1370
|
+
title={
|
|
1371
|
+
isDisableDone()
|
|
1372
|
+
? formatMessage(messages.sendForApprovalToolTip)
|
|
1373
|
+
: ''
|
|
1374
|
+
}
|
|
1375
|
+
placement={'right'}
|
|
1246
1376
|
>
|
|
1247
|
-
<
|
|
1248
|
-
|
|
1377
|
+
<div className="button-disabled-tooltip-wrapper">
|
|
1378
|
+
<CapButton
|
|
1379
|
+
onClick={onDoneCallback()}
|
|
1380
|
+
disabled={isDisableDone()}
|
|
1381
|
+
className="whatsapp-create-btn"
|
|
1382
|
+
>
|
|
1383
|
+
<FormattedMessage {...messages.sendForApprovalButtonLabel} />
|
|
1384
|
+
</CapButton>
|
|
1385
|
+
</div>
|
|
1386
|
+
</CapTooltip>
|
|
1249
1387
|
<CapButton
|
|
1250
1388
|
onClick={handleClose}
|
|
1251
1389
|
className="whatsapp-cancel-btn"
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
@import '~@capillarytech/cap-ui-library/styles/_variables';
|
|
2
2
|
|
|
3
3
|
.cap-whatsapp-creatives {
|
|
4
|
+
.whatsapp-heading-spacing {
|
|
5
|
+
margin-top: $CAP_SPACE_16;
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
.whatsapp-render-heading {
|
|
5
9
|
margin-top: $CAP_SPACE_16;
|
|
6
10
|
margin-bottom: 6px;
|
|
@@ -67,8 +71,7 @@
|
|
|
67
71
|
text-overflow: ellipsis;
|
|
68
72
|
}
|
|
69
73
|
|
|
70
|
-
.whatsapp-edit-disabled
|
|
71
|
-
.whatsapp-btn-radio-edit {
|
|
74
|
+
.whatsapp-edit-disabled {
|
|
72
75
|
cursor: not-allowed;
|
|
73
76
|
opacity: 0.5;
|
|
74
77
|
overflow-wrap: anywhere;
|
|
@@ -115,4 +118,17 @@
|
|
|
115
118
|
font-weight: normal;
|
|
116
119
|
font-size: 12px;
|
|
117
120
|
}
|
|
121
|
+
|
|
122
|
+
.whatsapp-media-radio>label.ant-radio-wrapper {
|
|
123
|
+
margin-right: 50px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.cap-custom-image-upload {
|
|
127
|
+
.dragger-button.re-upload {
|
|
128
|
+
top: -175px;
|
|
129
|
+
position: relative;
|
|
130
|
+
left: 525px;
|
|
131
|
+
color: $FONT_COLOR_05;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
118
134
|
}
|
|
@@ -66,6 +66,30 @@ export default defineMessages({
|
|
|
66
66
|
defaultMessage:
|
|
67
67
|
'Send confirmations, reminders, or other updates to customers about their reservations.',
|
|
68
68
|
},
|
|
69
|
+
transactional: {
|
|
70
|
+
id: `${prefix}.transactional`,
|
|
71
|
+
defaultMessage: 'Transactional',
|
|
72
|
+
},
|
|
73
|
+
transactionalTooltip: {
|
|
74
|
+
id: `${prefix}.transactionalTooltip`,
|
|
75
|
+
defaultMessage: 'Send account updates, order updates, alerts, and more to share important information.',
|
|
76
|
+
},
|
|
77
|
+
marketing: {
|
|
78
|
+
id: `${prefix}.marketing`,
|
|
79
|
+
defaultMessage: 'Marketing',
|
|
80
|
+
},
|
|
81
|
+
marketingTooltip: {
|
|
82
|
+
id: `${prefix}.marketingTooltip`,
|
|
83
|
+
defaultMessage: 'Send promotional offers, product announcements, and more to increase awareness and engagement.',
|
|
84
|
+
},
|
|
85
|
+
otp: {
|
|
86
|
+
id: `${prefix}.otp`,
|
|
87
|
+
defaultMessage: 'Otp',
|
|
88
|
+
},
|
|
89
|
+
otpTooltip: {
|
|
90
|
+
id: `${prefix}.otpTooltip`,
|
|
91
|
+
defaultMessage: 'Send codes that allow your customers to securely access their accounts.',
|
|
92
|
+
},
|
|
69
93
|
messageLanguageLabel: {
|
|
70
94
|
id: `${prefix}.messageLanguageLabel`,
|
|
71
95
|
defaultMessage: 'Message language',
|
|
@@ -78,9 +102,9 @@ export default defineMessages({
|
|
|
78
102
|
id: `${prefix}.mediaLabel`,
|
|
79
103
|
defaultMessage: 'Media',
|
|
80
104
|
},
|
|
81
|
-
|
|
82
|
-
id: `${prefix}.
|
|
83
|
-
defaultMessage: 'Text
|
|
105
|
+
mediaText: {
|
|
106
|
+
id: `${prefix}.mediaText`,
|
|
107
|
+
defaultMessage: 'Text',
|
|
84
108
|
},
|
|
85
109
|
mediaImage: {
|
|
86
110
|
id: `${prefix}.mediaImage`,
|
|
@@ -90,6 +114,10 @@ export default defineMessages({
|
|
|
90
114
|
id: `${prefix}.mediaVideo`,
|
|
91
115
|
defaultMessage: 'Video',
|
|
92
116
|
},
|
|
117
|
+
mediaDocument: {
|
|
118
|
+
id: `${prefix}.mediaDocument`,
|
|
119
|
+
defaultMessage: 'Document',
|
|
120
|
+
},
|
|
93
121
|
disabledFeatureTooltip: {
|
|
94
122
|
id: `${prefix}.disabledFeatureTooltip`,
|
|
95
123
|
defaultMessage: 'Not yet enabled. Coming soon!',
|
|
@@ -157,6 +185,10 @@ export default defineMessages({
|
|
|
157
185
|
id: `${prefix}.sendForApprovalButtonLabel`,
|
|
158
186
|
defaultMessage: 'Send for approval',
|
|
159
187
|
},
|
|
188
|
+
sendForApprovalToolTip: {
|
|
189
|
+
id: `${prefix}.sendForApprovalToolTip`,
|
|
190
|
+
defaultMessage: 'Please add all mandatory fields to proceed further',
|
|
191
|
+
},
|
|
160
192
|
cancelButtonLabel: {
|
|
161
193
|
id: `${prefix}.cancelButtonLabel`,
|
|
162
194
|
defaultMessage: 'Cancel',
|
|
@@ -264,10 +296,6 @@ export default defineMessages({
|
|
|
264
296
|
id: `${prefix}.optional`,
|
|
265
297
|
defaultMessage: '(Optional)',
|
|
266
298
|
},
|
|
267
|
-
disabledButtonsSection: {
|
|
268
|
-
id: `${prefix}.disabledButtonsSection`,
|
|
269
|
-
defaultMessage: 'Buttons are not editable once template is sent for approval',
|
|
270
|
-
},
|
|
271
299
|
|
|
272
300
|
afrikaans: {
|
|
273
301
|
id: `${prefix}.afrikaans`,
|
|
@@ -8,9 +8,16 @@ import {
|
|
|
8
8
|
GET_TEMPLATE_DETAILS_SUCCESS,
|
|
9
9
|
GET_TEMPLATE_DETAILS_FAILURE,
|
|
10
10
|
RESET_EDIT_TEMPLATE,
|
|
11
|
+
UPLOAD_WHATSAPP_ASSET_REQUEST,
|
|
12
|
+
UPLOAD_WHATSAPP_ASSET_SUCCESS,
|
|
13
|
+
UPLOAD_WHATSAPP_ASSET_FAILURE,
|
|
14
|
+
CLEAR_WHATSAPP_ASSET,
|
|
11
15
|
} from './constants';
|
|
12
16
|
|
|
13
|
-
const initialState = fromJS({
|
|
17
|
+
const initialState = fromJS({
|
|
18
|
+
uploadedAssetData: {},
|
|
19
|
+
createTemplateInProgress: false,
|
|
20
|
+
});
|
|
14
21
|
|
|
15
22
|
function whatsappReducer(state = initialState, action) {
|
|
16
23
|
switch (action.type) {
|
|
@@ -46,6 +53,33 @@ function whatsappReducer(state = initialState, action) {
|
|
|
46
53
|
return state.set('getTemplateDetailsInProgress', false);
|
|
47
54
|
case RESET_EDIT_TEMPLATE:
|
|
48
55
|
return state.set('templateDetails', {});
|
|
56
|
+
case UPLOAD_WHATSAPP_ASSET_REQUEST:
|
|
57
|
+
return state.set('uploadAssetSuccess', false).set('assetUploading', true);
|
|
58
|
+
case UPLOAD_WHATSAPP_ASSET_SUCCESS:
|
|
59
|
+
return state
|
|
60
|
+
.set(
|
|
61
|
+
'uploadAssetSuccess',
|
|
62
|
+
action.statusCode !== undefined &&
|
|
63
|
+
action.statusCode !== '' &&
|
|
64
|
+
action.statusCode < 300,
|
|
65
|
+
)
|
|
66
|
+
.set('assetUploading', false)
|
|
67
|
+
.set(
|
|
68
|
+
action.templateType !== undefined
|
|
69
|
+
? `uploadedAssetData${action.templateType}`
|
|
70
|
+
: 'uploadedAssetData',
|
|
71
|
+
action.data,
|
|
72
|
+
);
|
|
73
|
+
case UPLOAD_WHATSAPP_ASSET_FAILURE:
|
|
74
|
+
return state
|
|
75
|
+
.set('uploadAssetSuccess', false)
|
|
76
|
+
.set('assetUploading', false);
|
|
77
|
+
case CLEAR_WHATSAPP_ASSET:
|
|
78
|
+
return state.delete(
|
|
79
|
+
action.templateType !== undefined
|
|
80
|
+
? `uploadedAssetData${action.templateType}`
|
|
81
|
+
: 'uploadedAssetData',
|
|
82
|
+
);
|
|
49
83
|
default:
|
|
50
84
|
return state;
|
|
51
85
|
}
|