@capillarytech/creatives-library 7.12.38 → 7.12.40
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/CapWhatsappCTA/messages.js +1 -1
- package/v2Components/TemplatePreview/_templatePreview.scss +1 -0
- package/v2Components/TemplatePreview/index.js +5 -6
- package/v2Components/TemplatePreview/messages.js +0 -8
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +3 -12
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +1 -6
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +40 -240
- package/v2Containers/Whatsapp/index.js +86 -41
- package/v2Containers/Whatsapp/index.scss +17 -3
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +19589 -19483
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +2 -12
- package/v2Containers/Whatsapp/utils.js +46 -47
|
@@ -8,12 +8,7 @@ Object {
|
|
|
8
8
|
type="label9"
|
|
9
9
|
>
|
|
10
10
|
1234567890
|
|
11
|
-
|
|
12
|
-
</CapLabel>
|
|
13
|
-
<CapLabel
|
|
14
|
-
type="label9"
|
|
15
|
-
>
|
|
16
|
-
Click {{unsubscribe}} to unsubscribe
|
|
11
|
+
Click {{unsubscribe}} to unsubscribe
|
|
17
12
|
</CapLabel>
|
|
18
13
|
</React.Fragment>,
|
|
19
14
|
}
|
|
@@ -27,12 +22,7 @@ Object {
|
|
|
27
22
|
type="label5"
|
|
28
23
|
>
|
|
29
24
|
1234567890
|
|
30
|
-
|
|
31
|
-
</CapLabel>
|
|
32
|
-
<CapLabel
|
|
33
|
-
type="label5"
|
|
34
|
-
>
|
|
35
|
-
Click {{unsubscribe}} to unsubscribe
|
|
25
|
+
Click {{unsubscribe}} to unsubscribe
|
|
36
26
|
</CapLabel>
|
|
37
27
|
</React.Fragment>,
|
|
38
28
|
}
|
|
@@ -4,52 +4,50 @@ import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
|
|
|
4
4
|
import { get } from 'lodash';
|
|
5
5
|
import { WHATSAPP } from '../CreativesContainer/constants';
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
UNSUBSCRIBE_TEXT_LENGTH
|
|
7
|
+
STATUS_OPTIONS,
|
|
8
|
+
CATEGORY_OPTIONS,
|
|
9
|
+
WHATSAPP_STATUSES,
|
|
11
10
|
} from '../Whatsapp/constants';
|
|
12
11
|
|
|
13
12
|
export const getWhatsappContent = (template, isPreview) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} = {},
|
|
24
|
-
} = {},
|
|
13
|
+
const {
|
|
14
|
+
versions: {
|
|
15
|
+
base: {
|
|
16
|
+
content: {
|
|
17
|
+
[WHATSAPP.toLowerCase()]: {
|
|
18
|
+
languages = [{}],
|
|
19
|
+
buttonType = 'NONE',
|
|
20
|
+
buttons: ctaData = [],
|
|
21
|
+
} = {},
|
|
25
22
|
} = {},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
} = {},
|
|
24
|
+
} = {},
|
|
25
|
+
} = template;
|
|
26
|
+
//removing $'' which was added for twilio enter handling
|
|
27
|
+
let text = languages[0]?.content || '';
|
|
28
|
+
const validVarRegex = /{{([1-9]|1[0-9])}}/g;
|
|
29
|
+
const unsubscribePresent = /Click {{([1-9]|1[0-9])}} to unsubscribe/g;
|
|
30
|
+
if (text.match(unsubscribePresent)?.length > 0) {
|
|
30
31
|
const validVarArr = text.match(validVarRegex) || [];
|
|
31
|
-
//
|
|
32
|
+
//replacing Click {{5}} to unsubscribe with Click {{unsubscribe}} to unsubscribe,
|
|
33
|
+
//for listing preview and cards listing
|
|
32
34
|
text = text.replace(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
`${validVarArr[validVarArr.length - 1]}`,
|
|
36
|
+
'{{unsubscribe}}',
|
|
35
37
|
);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
ctaData,
|
|
50
|
-
}),
|
|
51
|
-
};
|
|
52
|
-
}
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
templateMsg: (
|
|
41
|
+
<>
|
|
42
|
+
<CapLabel type={isPreview ? 'label5' : 'label9'}>{text}</CapLabel>
|
|
43
|
+
</>
|
|
44
|
+
),
|
|
45
|
+
charCount: text?.length - 1,
|
|
46
|
+
...(buttonType === 'CTA' && {
|
|
47
|
+
ctaData,
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
};
|
|
53
51
|
|
|
54
52
|
export const getWhatsappCta = (template) => {
|
|
55
53
|
const { buttonType = 'NONE', buttons = [] } = get(
|
|
@@ -81,13 +79,14 @@ export const getWhatsappCta = (template) => {
|
|
|
81
79
|
return renderArray;
|
|
82
80
|
};
|
|
83
81
|
|
|
84
|
-
export const getWhatsappCategory = (category) =>
|
|
85
|
-
|
|
86
|
-
}
|
|
82
|
+
export const getWhatsappCategory = (category) =>
|
|
83
|
+
CATEGORY_OPTIONS.find((obj) => obj.value === category);
|
|
87
84
|
|
|
88
85
|
export const getWhatsappStatus = (status) => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
86
|
+
if (
|
|
87
|
+
[WHATSAPP_STATUSES.pending, WHATSAPP_STATUSES.unsubmitted].includes(status)
|
|
88
|
+
) {
|
|
89
|
+
status = WHATSAPP_STATUSES.awaitingApproval;
|
|
90
|
+
}
|
|
91
|
+
return STATUS_OPTIONS.find((obj) => obj.value === status);
|
|
92
|
+
};
|