@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.
@@ -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
- STATUS_OPTIONS,
8
- CATEGORY_OPTIONS,
9
- WHATSAPP_STATUSES,
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
- const {
15
- versions: {
16
- base: {
17
- content: {
18
- [WHATSAPP.toLowerCase()]: {
19
- languages = [{}],
20
- buttonType = 'NONE',
21
- buttons : ctaData = [],
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
- } = template;
27
- //removing $'' which was added for twilio enter handling
28
- let text = languages[0]?.content || '';
29
- const validVarRegex = /{{([1-9]|1[0-9])}}/g;
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
- //removing Click {{unsubscribe}} to unsubscribe
32
+ //replacing Click {{5}} to unsubscribe with Click {{unsubscribe}} to unsubscribe,
33
+ //for listing preview and cards listing
32
34
  text = text.replace(
33
- `${validVarArr[validVarArr.length - 1]}`,
34
- '{{unsubscribe}}',
35
+ `${validVarArr[validVarArr.length - 1]}`,
36
+ '{{unsubscribe}}',
35
37
  );
36
- return {
37
- templateMsg: (
38
- <>
39
- <CapLabel type={ isPreview ? "label5" : "label9" }>
40
- {text.slice(0, text.length - UNSUBSCRIBE_TEXT_LENGTH)}
41
- </CapLabel>
42
- <CapLabel type={ isPreview ? "label5" : "label9" }>
43
- {text.slice(-UNSUBSCRIBE_TEXT_LENGTH)}
44
- </CapLabel>
45
- </>
46
- ),
47
- charCount: text?.length - 1,
48
- ...(buttonType === 'CTA' && {
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
- return CATEGORY_OPTIONS.find((obj) => obj.value === category);
86
- }
82
+ export const getWhatsappCategory = (category) =>
83
+ CATEGORY_OPTIONS.find((obj) => obj.value === category);
87
84
 
88
85
  export const getWhatsappStatus = (status) => {
89
- if ([WHATSAPP_STATUSES.pending, WHATSAPP_STATUSES.unsubmitted].includes(status)) {
90
- status = WHATSAPP_STATUSES.awaitingApproval;
91
- }
92
- return STATUS_OPTIONS.find((obj) => obj.value === status);
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
+ };