@capillarytech/creatives-library 7.11.2 → 7.11.3
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/package.json +1 -1
- package/v2Components/TemplatePreview/index.js +1 -1
- package/v2Components/TemplatePreview/messages.js +1 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +1 -1
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +16 -1
- package/v2Containers/CreativesContainer/constants.js +2 -0
- package/v2Containers/CreativesContainer/index.js +2 -0
- package/v2Containers/CreativesContainer/messages.js +4 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +15 -2
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +20 -1
- package/v2Containers/Templates/_templates.scss +23 -6
- package/v2Containers/Whatsapp/constants.js +1 -1
- package/v2Containers/Whatsapp/index.js +24 -12
- package/v2Containers/Whatsapp/index.scss +2 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +22742 -1245
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +33 -0
- package/v2Containers/Whatsapp/tests/index.test.js +13 -0
- package/v2Containers/Whatsapp/tests/utils.test.js +5 -1
- package/v2Containers/Whatsapp/utils.js +13 -2
package/package.json
CHANGED
|
@@ -32,7 +32,7 @@ export default defineMessages({
|
|
|
32
32
|
},
|
|
33
33
|
whatsappUnsubscribeLength: {
|
|
34
34
|
id: 'app.components.TemplatePreview.whatsappUnsubscribeLength',
|
|
35
|
-
defaultMessage: "Includes
|
|
35
|
+
defaultMessage: "Includes 37 characters of (Click {{unsubscribe}} to unsubscribe)",
|
|
36
36
|
},
|
|
37
37
|
whatsappMessageLength: {
|
|
38
38
|
id: 'app.components.TemplatePreview.whatsappMessageLength',
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { FormattedMessage } from 'react-intl';
|
|
4
4
|
import get from 'lodash/get';
|
|
5
|
-
import { CapHeader, CapIcons, CapLabel, CapSteps } from '@capillarytech/cap-ui-library';
|
|
5
|
+
import { CapHeader, CapIcons, CapLabel, CapLink, CapSteps, CapIcon } from '@capillarytech/cap-ui-library';
|
|
6
6
|
import moment from 'moment';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import messages from './messages';
|
|
@@ -15,6 +15,8 @@ import { formatString } from '../../utils/Formatter';
|
|
|
15
15
|
import {
|
|
16
16
|
CAP_SPACE_12,
|
|
17
17
|
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
18
|
+
import { WHATSAPP_HELP_DOC_LINK } from './constants';
|
|
19
|
+
|
|
18
20
|
const { CapLabelInline } = CapLabel;
|
|
19
21
|
const StyledLabel = styled(CapLabelInline)`
|
|
20
22
|
margin-right: ${CAP_SPACE_12};
|
|
@@ -35,6 +37,7 @@ export function SlideBoxHeader(props) {
|
|
|
35
37
|
const isTraiDlt = isTraiDLTEnable(isFullMode, smsRegister);
|
|
36
38
|
const showCreateTraiSMSHeader = isTraiDlt && channel.toLowerCase() === "sms";
|
|
37
39
|
const isWhatsappEdit = channel.toLowerCase() === WHATSAPP && slidBoxContent === 'editTemplate';
|
|
40
|
+
const isWhatsappCreate = channel.toLowerCase() === WHATSAPP && slidBoxContent === 'createTemplate';
|
|
38
41
|
const whatsappOverview = isWhatsappEdit && isFullMode;
|
|
39
42
|
const headerMessage = whatsappOverview ? messages.whatsappOverview : messages.editMessageContent;
|
|
40
43
|
const {
|
|
@@ -58,6 +61,10 @@ export function SlideBoxHeader(props) {
|
|
|
58
61
|
return labels[currentChannel.toLowerCase()];
|
|
59
62
|
};
|
|
60
63
|
|
|
64
|
+
const openWhatsappHelpDoc = () => {
|
|
65
|
+
window.open(WHATSAPP_HELP_DOC_LINK, '_blank')
|
|
66
|
+
}
|
|
67
|
+
|
|
61
68
|
return (
|
|
62
69
|
<div key="creatives-container-slidebox-header-content">
|
|
63
70
|
{slidBoxContent === 'templates' && !showTemplateNameHeader && (
|
|
@@ -115,6 +122,14 @@ export function SlideBoxHeader(props) {
|
|
|
115
122
|
}
|
|
116
123
|
/>
|
|
117
124
|
)}
|
|
125
|
+
{isWhatsappCreate && (
|
|
126
|
+
<CapLink
|
|
127
|
+
onClick={openWhatsappHelpDoc}
|
|
128
|
+
title={<FormattedMessage {...messages.learnTips} />}
|
|
129
|
+
suffix={<CapIcon type="open-in-new" size="s" />}
|
|
130
|
+
className="learn-tips-link"
|
|
131
|
+
/>
|
|
132
|
+
)}
|
|
118
133
|
{mapTemplateCreate && (
|
|
119
134
|
<CapSteps
|
|
120
135
|
onChange={onWeChatMaptemplateStepChange}
|
|
@@ -20,3 +20,5 @@ export const WHATSAPP = "WHATSAPP";
|
|
|
20
20
|
|
|
21
21
|
export const SHOW_CONTANER_LOADER = "app/CreativesContainer/SHOW_CONTANER_LOADER";
|
|
22
22
|
export const HIDE_CONTAINER_LOADER = "app/CreativesContainer/HIDE_CONTAINER_LOADER";
|
|
23
|
+
|
|
24
|
+
export const WHATSAPP_HELP_DOC_LINK = "https://support.capillarytech.com/en/support/solutions/articles/4000180620-create-whatsapp-template";
|
|
@@ -368,6 +368,7 @@ export class Creatives extends React.Component {
|
|
|
368
368
|
case constants.WHATSAPP: {
|
|
369
369
|
const {
|
|
370
370
|
templateConfigs: {
|
|
371
|
+
id,
|
|
371
372
|
name,
|
|
372
373
|
template,
|
|
373
374
|
varMapped,
|
|
@@ -377,6 +378,7 @@ export class Creatives extends React.Component {
|
|
|
377
378
|
} = {},
|
|
378
379
|
} = templateData;
|
|
379
380
|
creativesTemplateData = {
|
|
381
|
+
_id: id,
|
|
380
382
|
type: constants.WHATSAPP,
|
|
381
383
|
edit: true,
|
|
382
384
|
name,
|
|
@@ -31,9 +31,11 @@ exports[`Test SlideBoxContent container Should render correct component for what
|
|
|
31
31
|
templateData={
|
|
32
32
|
Object {
|
|
33
33
|
"_id": "620e213d39bd394c58aeaaca",
|
|
34
|
+
"channel": "WHATSAPP",
|
|
34
35
|
"mode": "edit",
|
|
35
36
|
"modeType": "",
|
|
36
37
|
"type": "WHATSAPP",
|
|
38
|
+
"validity": true,
|
|
37
39
|
"whatsappTemplateCategory": "ALERT_UPDATE",
|
|
38
40
|
"whatsappTemplateName": "amit123456",
|
|
39
41
|
}
|
|
@@ -49,8 +51,19 @@ exports[`Test SlideBoxContent container Should render correct component for what
|
|
|
49
51
|
charCounterEnabled={false}
|
|
50
52
|
content={
|
|
51
53
|
Object {
|
|
52
|
-
"templateMsg":
|
|
53
|
-
|
|
54
|
+
"templateMsg": <React.Fragment>
|
|
55
|
+
<CapLabel
|
|
56
|
+
type="label5"
|
|
57
|
+
>
|
|
58
|
+
1234567890
|
|
59
|
+
</CapLabel>
|
|
60
|
+
<CapLabel
|
|
61
|
+
type="label11"
|
|
62
|
+
>
|
|
63
|
+
|
|
64
|
+
Click {{unsubscribe}} to unsubscribe
|
|
65
|
+
</CapLabel>
|
|
66
|
+
</React.Fragment>,
|
|
54
67
|
}
|
|
55
68
|
}
|
|
56
69
|
showCount={true}
|
|
@@ -3,7 +3,26 @@
|
|
|
3
3
|
exports[`Test SlideBoxHeader container Should render correct component for whatsapp channel create mode 1`] = `
|
|
4
4
|
<div
|
|
5
5
|
key="creatives-container-slidebox-header-content"
|
|
6
|
-
|
|
6
|
+
>
|
|
7
|
+
<CapLink
|
|
8
|
+
className="learn-tips-link"
|
|
9
|
+
disabled={false}
|
|
10
|
+
onClick={[Function]}
|
|
11
|
+
suffix={
|
|
12
|
+
<CapIcon
|
|
13
|
+
size="s"
|
|
14
|
+
type="open-in-new"
|
|
15
|
+
/>
|
|
16
|
+
}
|
|
17
|
+
title={
|
|
18
|
+
<FormattedMessage
|
|
19
|
+
defaultMessage="Learn tips to get approved"
|
|
20
|
+
id="creatives.containersV2.Creatives.learnTips"
|
|
21
|
+
values={Object {}}
|
|
22
|
+
/>
|
|
23
|
+
}
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
7
26
|
`;
|
|
8
27
|
|
|
9
28
|
exports[`Test SlideBoxHeader container Should render correct component for whatsapp channel edit mode 1`] = `
|
|
@@ -6,12 +6,29 @@
|
|
|
6
6
|
padding: unset;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
|
|
10
|
+
@media screen and (max-width: 1172px) {
|
|
11
|
+
.creatives-templates-list.full-mode{
|
|
12
|
+
.pagination-container {
|
|
13
|
+
.cap-custom-card-list-row {
|
|
14
|
+
.cap-custom-card-list-col{
|
|
15
|
+
&:nth-child(3n+3) { //every 4th child
|
|
16
|
+
margin-right: unset;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@media screen and (min-width: 1172px) {
|
|
25
|
+
.creatives-templates-list.full-mode{
|
|
26
|
+
.pagination-container {
|
|
27
|
+
.cap-custom-card-list-row {
|
|
28
|
+
.cap-custom-card-list-col{
|
|
29
|
+
&:nth-child(4n+4) { //every 4th child
|
|
30
|
+
margin-right: unset;
|
|
31
|
+
}
|
|
15
32
|
}
|
|
16
33
|
}
|
|
17
34
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
CAP_GREEN02,
|
|
11
11
|
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
12
12
|
|
|
13
|
-
export const UNSUBSCRIBE_TEXT_LENGTH =
|
|
13
|
+
export const UNSUBSCRIBE_TEXT_LENGTH = 37;
|
|
14
14
|
export const TEMPLATE_MESSAGE_MAX_LENGTH = 1024;
|
|
15
15
|
export const WHATSAPP = 'WHATSAPP';
|
|
16
16
|
|
|
@@ -410,8 +410,8 @@ export const Whatsapp = (props) => {
|
|
|
410
410
|
<CapHeading type="h6" className="whatsapp-render-message-length">
|
|
411
411
|
{formatMessage(messages.templateMessageLength, {
|
|
412
412
|
currentLength: isEditFlow
|
|
413
|
-
? updatedSmsEditor?.join('')?.length + UNSUBSCRIBE_TEXT_LENGTH
|
|
414
|
-
: templateMessage?.length + UNSUBSCRIBE_TEXT_LENGTH
|
|
413
|
+
? updatedSmsEditor?.join('')?.length + UNSUBSCRIBE_TEXT_LENGTH - 1
|
|
414
|
+
: templateMessage?.length + UNSUBSCRIBE_TEXT_LENGTH,
|
|
415
415
|
maxLength: TEMPLATE_MESSAGE_MAX_LENGTH,
|
|
416
416
|
})}
|
|
417
417
|
</CapHeading>
|
|
@@ -438,18 +438,30 @@ export const Whatsapp = (props) => {
|
|
|
438
438
|
setTemplateCategory(value);
|
|
439
439
|
};
|
|
440
440
|
|
|
441
|
-
const onAddVar = () => {
|
|
442
|
-
|
|
443
|
-
|
|
441
|
+
const onAddVar = (isAutoComplete) => {
|
|
442
|
+
let tempMessage = templateMessage;
|
|
443
|
+
|
|
444
|
+
//if autocomplete feature, first remove the trailing bracket and then add variable
|
|
445
|
+
if (isAutoComplete) {
|
|
446
|
+
tempMessage = tempMessage.slice(0, templateMessage.length - 1);
|
|
447
|
+
}
|
|
448
|
+
const validVarArr = tempMessage.match(validVarRegex) || [];
|
|
449
|
+
const tempMsg = `${tempMessage}{{${validVarArr.length + 1}}}`;
|
|
444
450
|
const error = templateMessageErrorHandler(tempMsg);
|
|
445
451
|
setTemplateMessage(tempMsg);
|
|
446
452
|
setTemplateMessageError(error);
|
|
447
453
|
};
|
|
448
454
|
|
|
449
455
|
const onTemplateMessageChange = ({ target: { value } }) => {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
456
|
+
// autocomplete feature
|
|
457
|
+
if ( value.slice(-2) === '{{' ) {
|
|
458
|
+
onAddVar(true);
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
const error = templateMessageErrorHandler(value);
|
|
462
|
+
setTemplateMessage(value);
|
|
463
|
+
setTemplateMessageError(error);
|
|
464
|
+
}
|
|
453
465
|
};
|
|
454
466
|
|
|
455
467
|
const templateMessageErrorHandler = (value) => {
|
|
@@ -457,7 +469,7 @@ export const Whatsapp = (props) => {
|
|
|
457
469
|
if (value === '') {
|
|
458
470
|
errorMessage = formatMessage(messages.emptyTemplateMessageErrorMessage);
|
|
459
471
|
} else if (
|
|
460
|
-
UNSUBSCRIBE_TEXT_LENGTH + value?.length
|
|
472
|
+
UNSUBSCRIBE_TEXT_LENGTH + value?.length >
|
|
461
473
|
TEMPLATE_MESSAGE_MAX_LENGTH
|
|
462
474
|
) {
|
|
463
475
|
errorMessage = formatMessage(messages.templateMessageLengthError);
|
|
@@ -465,7 +477,7 @@ export const Whatsapp = (props) => {
|
|
|
465
477
|
const validVarArr = value.match(validVarRegex) || [];
|
|
466
478
|
const validVarSet = [...new Set(validVarArr)];
|
|
467
479
|
|
|
468
|
-
const invalidVarRegex = /{{(
|
|
480
|
+
const invalidVarRegex = /{{(.*?)}}/g;
|
|
469
481
|
const invalidVarArr = value.match(invalidVarRegex) || [];
|
|
470
482
|
const invalidVarSet = [...new Set(invalidVarArr)];
|
|
471
483
|
|
|
@@ -680,7 +692,7 @@ export const Whatsapp = (props) => {
|
|
|
680
692
|
type="flat"
|
|
681
693
|
isAddBtn
|
|
682
694
|
onClick={onAddVar}
|
|
683
|
-
disabled={addedVarCount >= 19 || templateMessageError}
|
|
695
|
+
disabled={(addedVarCount >= 19 || templateMessageError) && templateMessage}
|
|
684
696
|
>
|
|
685
697
|
{formatMessage(messages.addVar)}
|
|
686
698
|
</CapButton>
|
|
@@ -928,7 +940,7 @@ export const Whatsapp = (props) => {
|
|
|
928
940
|
channel={WHATSAPP}
|
|
929
941
|
content={{ templateMsg }}
|
|
930
942
|
whatsappContentLen={
|
|
931
|
-
isEditFlow ? updatedSmsEditor.join('').length : templateMessage.length
|
|
943
|
+
isEditFlow ? updatedSmsEditor.join('').length - 1 : templateMessage.length
|
|
932
944
|
}
|
|
933
945
|
whatsappAccountName={accountName}
|
|
934
946
|
/>
|