@capillarytech/creatives-library 8.0.111-alpha.0 → 8.0.111
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
CHANGED
|
@@ -20,7 +20,7 @@ import globalMessages from '../../v2Containers/Cap/messages';
|
|
|
20
20
|
import whatsappMsg from '../../v2Containers/Whatsapp/messages';
|
|
21
21
|
import messages from './messages';
|
|
22
22
|
import './index.scss';
|
|
23
|
-
import { isUrl,
|
|
23
|
+
import { isUrl,isValidText } from '../../v2Containers/Line/Container/Wrapper/utils';
|
|
24
24
|
import TagList from '../../v2Containers/TagList';
|
|
25
25
|
import {
|
|
26
26
|
CTA_OPTIONS,
|
|
@@ -33,7 +33,6 @@ import {
|
|
|
33
33
|
WEBSITE,
|
|
34
34
|
DYNAMIC_URL,
|
|
35
35
|
STATIC_URL,
|
|
36
|
-
DYNAMIC_URL_SUFFIX,
|
|
37
36
|
} from './constants';
|
|
38
37
|
import {
|
|
39
38
|
INITIAL_CTA_DATA,
|
|
@@ -51,7 +50,6 @@ export const CapWhatsappCTA = (props) => {
|
|
|
51
50
|
tags = [],
|
|
52
51
|
injectedTags = {},
|
|
53
52
|
selectedOfferDetails = [],
|
|
54
|
-
eventContextTags = [],
|
|
55
53
|
} = props;
|
|
56
54
|
const { formatMessage } = intl;
|
|
57
55
|
const invalidVarRegex = /{{(.*?)}}/g;
|
|
@@ -122,8 +120,8 @@ export const CapWhatsappCTA = (props) => {
|
|
|
122
120
|
|
|
123
121
|
const ctaOptions = CTA_OPTIONS.map((option) => {
|
|
124
122
|
const { value, label, tooltipLabel } = option;
|
|
125
|
-
//
|
|
126
|
-
const isDisabled = ctaData.length === 2 && ctaData[0].ctaType ===
|
|
123
|
+
//if button 1 is of type-> PHONE_NUMBER, it is disabled in second button
|
|
124
|
+
const isDisabled = ctaData.length === 2 && ctaData[0].ctaType === value;
|
|
127
125
|
return {
|
|
128
126
|
value,
|
|
129
127
|
label: renderCtaOptions(label, tooltipLabel, isDisabled),
|
|
@@ -136,7 +134,8 @@ export const CapWhatsappCTA = (props) => {
|
|
|
136
134
|
clonedCta.push(cloneDeep(INITIAL_CTA_DATA[0]));
|
|
137
135
|
if (clonedCta.length === 2) {
|
|
138
136
|
clonedCta[1].index = 1;
|
|
139
|
-
clonedCta[1].ctaType =
|
|
137
|
+
clonedCta[1].ctaType =
|
|
138
|
+
clonedCta[0].ctaType === PHONE_NUMBER ? WEBSITE : PHONE_NUMBER;
|
|
140
139
|
}
|
|
141
140
|
updateHandler(clonedCta, null, true);
|
|
142
141
|
};
|
|
@@ -163,13 +162,14 @@ export const CapWhatsappCTA = (props) => {
|
|
|
163
162
|
let { value, id } = target;
|
|
164
163
|
if (urlType === DYNAMIC_URL) {
|
|
165
164
|
value = value.replace(invalidVarRegex, '');
|
|
165
|
+
value = `${value}{{1}}`;
|
|
166
166
|
}
|
|
167
167
|
let errorMessage = false;
|
|
168
168
|
if (!isUrl(value)) {
|
|
169
169
|
errorMessage = formatMessage(messages.ctaWebsiteUrlErrorMessage);
|
|
170
170
|
} else if (
|
|
171
|
-
urlType === STATIC_URL
|
|
172
|
-
|
|
171
|
+
urlType === STATIC_URL &&
|
|
172
|
+
value.match(invalidVarRegex)?.length > 0
|
|
173
173
|
) {
|
|
174
174
|
errorMessage = formatMessage(messages.staticUrlWithVarErrorMessage);
|
|
175
175
|
}
|
|
@@ -178,28 +178,18 @@ export const CapWhatsappCTA = (props) => {
|
|
|
178
178
|
};
|
|
179
179
|
|
|
180
180
|
const ctaSaveDisabled = (index) => {
|
|
181
|
-
const {
|
|
182
|
-
ctaType, text, phone_number, url,
|
|
183
|
-
} = ctaData[index] || {};
|
|
181
|
+
const { ctaType, text, phone_number, url } = ctaData[index] || {};
|
|
184
182
|
if (text === '' || buttonError) {
|
|
185
183
|
return true;
|
|
186
|
-
} if (ctaType === PHONE_NUMBER && phone_number.length < 5) {
|
|
184
|
+
} else if (ctaType === PHONE_NUMBER && phone_number.length < 5) {
|
|
187
185
|
return true;
|
|
188
|
-
} if (ctaType === WEBSITE && (url === '' || urlError)) {
|
|
186
|
+
} else if (ctaType === WEBSITE && (url === '' || urlError)) {
|
|
189
187
|
return true;
|
|
190
188
|
}
|
|
191
189
|
return false;
|
|
192
190
|
};
|
|
193
191
|
|
|
194
192
|
const saveCta = (index) => {
|
|
195
|
-
const clonedIndexCta = cloneDeep(ctaData[index]);
|
|
196
|
-
// If this is a website CTA with dynamic URL type, ensure {{1}} is added at the end
|
|
197
|
-
if (clonedIndexCta?.ctaType === WEBSITE && clonedIndexCta?.urlType === DYNAMIC_URL) {
|
|
198
|
-
if (!clonedIndexCta?.url?.includes(DYNAMIC_URL_SUFFIX)) {
|
|
199
|
-
clonedIndexCta.url += DYNAMIC_URL_SUFFIX;
|
|
200
|
-
ctaData[index] = clonedIndexCta;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
193
|
updateHelper('isSaved', true, index);
|
|
204
194
|
};
|
|
205
195
|
const editCta = (index) => {
|
|
@@ -210,9 +200,8 @@ export const CapWhatsappCTA = (props) => {
|
|
|
210
200
|
const renderArray = [];
|
|
211
201
|
const addBtnDisabled = ctaData.length === 1 && !ctaData[0].isSaved;
|
|
212
202
|
ctaData.forEach((cta) => {
|
|
213
|
-
const {
|
|
214
|
-
|
|
215
|
-
} = cta || {};
|
|
203
|
+
const { index, ctaType, text, phone_number, urlType, url, isSaved } =
|
|
204
|
+
cta || {};
|
|
216
205
|
//this is to display buttons after they are saved, in both create and edit mode.
|
|
217
206
|
if (isSaved) {
|
|
218
207
|
const ctaIsPhone = ctaType === PHONE_NUMBER;
|
|
@@ -240,10 +229,7 @@ export const CapWhatsappCTA = (props) => {
|
|
|
240
229
|
</CapColumn>
|
|
241
230
|
{ctaIsPhone && (
|
|
242
231
|
<CapColumn span={10} align="left">
|
|
243
|
-
<CapLabel className="phone">
|
|
244
|
-
+
|
|
245
|
-
{phone_number}
|
|
246
|
-
</CapLabel>
|
|
232
|
+
<CapLabel className="phone">+{phone_number}</CapLabel>
|
|
247
233
|
</CapColumn>
|
|
248
234
|
)}
|
|
249
235
|
{!ctaIsPhone && (
|
|
@@ -255,7 +241,7 @@ export const CapWhatsappCTA = (props) => {
|
|
|
255
241
|
: formatMessage(messages.ctaWebsiteTypeDynamic)}
|
|
256
242
|
</CapLabel>
|
|
257
243
|
</CapColumn>
|
|
258
|
-
<CapTooltip title={url} placement=
|
|
244
|
+
<CapTooltip title={url} placement={'top'}>
|
|
259
245
|
<CapColumn span={7} style={{ marginRight: '0px' }}>
|
|
260
246
|
<CapLabel className="url">{url}</CapLabel>
|
|
261
247
|
</CapColumn>
|
|
@@ -285,7 +271,6 @@ export const CapWhatsappCTA = (props) => {
|
|
|
285
271
|
tags={tags}
|
|
286
272
|
injectedTags={injectedTags}
|
|
287
273
|
selectedOfferDetails={selectedOfferDetails}
|
|
288
|
-
eventContextTags={eventContextTags}
|
|
289
274
|
/>
|
|
290
275
|
</CapColumn>
|
|
291
276
|
)}
|
|
@@ -297,7 +282,7 @@ export const CapWhatsappCTA = (props) => {
|
|
|
297
282
|
>
|
|
298
283
|
<CapTooltip
|
|
299
284
|
title={formatMessage(messages.whatsappCtaTagListRevert)}
|
|
300
|
-
placement=
|
|
285
|
+
placement={'top'}
|
|
301
286
|
>
|
|
302
287
|
<CapIcon size="s" type="return" />
|
|
303
288
|
</CapTooltip>
|
|
@@ -406,7 +391,6 @@ export const CapWhatsappCTA = (props) => {
|
|
|
406
391
|
</CapHeading>
|
|
407
392
|
<CapInput
|
|
408
393
|
id={index}
|
|
409
|
-
addonAfter={urlType === DYNAMIC_URL && !url.includes(DYNAMIC_URL_SUFFIX) && DYNAMIC_URL_SUFFIX}
|
|
410
394
|
className="whatsapp-cta-url"
|
|
411
395
|
onChange={(event) => onUrlChange(event, urlType)}
|
|
412
396
|
placeholder={
|
|
@@ -430,7 +414,7 @@ export const CapWhatsappCTA = (props) => {
|
|
|
430
414
|
? formatMessage(messages.ctaSaveDisabled)
|
|
431
415
|
: ''
|
|
432
416
|
}
|
|
433
|
-
placement=
|
|
417
|
+
placement={'bottom'}
|
|
434
418
|
>
|
|
435
419
|
<div className="button-disabled-tooltip-wrapper">
|
|
436
420
|
<CapButton
|
|
@@ -458,15 +442,15 @@ export const CapWhatsappCTA = (props) => {
|
|
|
458
442
|
{
|
|
459
443
|
// when first button is not saved, add button is disabled with tooltip
|
|
460
444
|
// eslint-disable-next-line no-unused-expressions
|
|
461
|
-
ctaData.length < 2
|
|
462
|
-
|
|
463
|
-
|
|
445
|
+
ctaData.length < 2 &&
|
|
446
|
+
!isEditFlow &&
|
|
447
|
+
renderArray.push(
|
|
464
448
|
<CapRow>
|
|
465
449
|
<CapTooltip
|
|
466
450
|
title={
|
|
467
451
|
addBtnDisabled ? formatMessage(messages.ctaAddDisabled) : ''
|
|
468
452
|
}
|
|
469
|
-
placement=
|
|
453
|
+
placement={'right'}
|
|
470
454
|
>
|
|
471
455
|
<div className="button-disabled-tooltip-wrapper">
|
|
472
456
|
<CapButton
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
|
-
import { injectIntl } from 'react-intl';
|
|
11
10
|
import { connect } from 'react-redux';
|
|
12
11
|
import { Tree } from 'antd';
|
|
13
12
|
import _ from 'lodash';
|
|
@@ -17,20 +16,17 @@ import makeSelectTagList from './selectors';
|
|
|
17
16
|
import { UserIsAuthenticated } from '../../utils/authWrapper';
|
|
18
17
|
import * as actions from './actions';
|
|
19
18
|
import * as globalActions from '../Cap/actions';
|
|
20
|
-
import messages, { scope } from './messages';
|
|
21
|
-
|
|
22
19
|
// import styled from styled-components;
|
|
23
20
|
import CapTagList from '../../v2Components/CapTagList';
|
|
24
21
|
import './_tagList.scss';
|
|
25
22
|
import { selectCurrentOrgDetails, makeSelectFetchingSchemaError } from '../Cap/selectors';
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
} from '../../containers/App/constants';
|
|
23
|
+
import { injectIntl } from 'react-intl';
|
|
24
|
+
import { scope } from './messages';
|
|
25
|
+
import messages from './messages';
|
|
26
|
+
import { handleInjectedData, hasGiftVoucherFeature, hasPromoFeature, hasBadgesFeature, transformBadgeTags } from '../../utils/common';
|
|
27
|
+
import { GIFT_VOUCHER_RELATED_TAGS, PROMO_ENGINE_RELATED_TAGS, BADGES_RELATED_TAGS, BADGES_ENROLL, BADGES_ISSUE } from '../../containers/App/constants';
|
|
32
28
|
|
|
33
|
-
const
|
|
29
|
+
const TreeNode = Tree.TreeNode;
|
|
34
30
|
|
|
35
31
|
export class TagList extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
36
32
|
constructor(props) {
|
|
@@ -56,35 +52,35 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
56
52
|
this.setState({loading: true});
|
|
57
53
|
}
|
|
58
54
|
if (!_.isEqual(nextProps.injectedTags, this.props.injectedTags)) {
|
|
55
|
+
|
|
59
56
|
this.setState({loading: false});
|
|
60
57
|
}
|
|
61
58
|
if (!_.isEqual(nextProps.tags, this.props.tags)) {
|
|
59
|
+
|
|
62
60
|
this.setState({loading: false});
|
|
63
61
|
}
|
|
64
62
|
if (nextProps?.fetchingSchemaError) {
|
|
65
63
|
this.setState({tagsError: nextProps?.fetchingSchemaError});
|
|
66
64
|
}
|
|
67
|
-
}
|
|
68
65
|
|
|
66
|
+
}
|
|
69
67
|
componentDidUpdate(prevProps) {
|
|
70
68
|
if (this.props.tags !== prevProps.tags || this.props.injectedTags !== prevProps.injectedTags || this.props.selectedOfferDetails !== prevProps.selectedOfferDetails) {
|
|
71
69
|
this.generateTags(this.props);
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
|
-
|
|
75
72
|
onSelect = (selectedKeys) => {
|
|
76
73
|
this.props.onTagSelect(selectedKeys[0]);
|
|
77
74
|
};
|
|
78
75
|
|
|
79
|
-
|
|
76
|
+
onClick = (e, data) => {
|
|
80
77
|
|
|
81
|
-
|
|
78
|
+
};
|
|
82
79
|
|
|
83
80
|
getTagsforContext = (data) => {
|
|
84
81
|
//this.setState({loading: true});
|
|
85
82
|
this.props.onContextChange(data);
|
|
86
83
|
}
|
|
87
|
-
|
|
88
84
|
generateTags = (props) => {
|
|
89
85
|
let tags = {};
|
|
90
86
|
let injectedTags = {};
|
|
@@ -112,26 +108,24 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
112
108
|
if (eventContextTags?.length) {
|
|
113
109
|
const TAG_HEADER_MSG_LABEL = this.props.intl.formatMessage(messages.entryEvent);
|
|
114
110
|
eventContextTagsObj.eventContextTags = {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
name: TAG_HEADER_MSG_LABEL,
|
|
112
|
+
desc: TAG_HEADER_MSG_LABEL,
|
|
113
|
+
resolved: true,
|
|
118
114
|
'tag-header': true,
|
|
119
|
-
|
|
115
|
+
subtags: {},
|
|
120
116
|
};
|
|
121
117
|
|
|
122
118
|
eventContextTags.forEach((tag) => {
|
|
123
|
-
const {
|
|
124
|
-
tagName, label, profileId, profileName,
|
|
125
|
-
} = tag || {};
|
|
119
|
+
const { tagName, label, profileId, profileName } = tag || {};
|
|
126
120
|
if (!profileId || !tagName || !label || !profileName) return;
|
|
127
121
|
// Initializing the tags profile if it doesn't exist
|
|
128
122
|
if (!eventContextTagsObj?.eventContextTags?.subtags?.[profileId]) {
|
|
129
123
|
eventContextTagsObj.eventContextTags.subtags[profileId] = {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
124
|
+
name: profileName,
|
|
125
|
+
desc: profileName,
|
|
126
|
+
resolved: true,
|
|
133
127
|
"tag-header": true,
|
|
134
|
-
|
|
128
|
+
subtags: {},
|
|
135
129
|
};
|
|
136
130
|
}
|
|
137
131
|
// Adding the current tag to the profile group
|
|
@@ -144,7 +138,6 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
144
138
|
}
|
|
145
139
|
this.setState({tags: _.merge( {}, tags, injectedTags, eventContextTagsObj )});
|
|
146
140
|
}
|
|
147
|
-
|
|
148
141
|
populateTags(tagsList) {
|
|
149
142
|
const mainTags = {};
|
|
150
143
|
const excludedTags = [];
|
|
@@ -171,8 +164,8 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
171
164
|
}
|
|
172
165
|
if (!tag['tag-header']) {
|
|
173
166
|
mainTags[tag.value] = {
|
|
174
|
-
name: tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
175
|
-
desc: tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
167
|
+
"name": tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
168
|
+
"desc": tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
176
169
|
};
|
|
177
170
|
} else if (tag['tag-header'] && mainTags[tag.value]) {
|
|
178
171
|
mainTags[tag.value].subtags = _.concat(mainTags[tag.value].subtags, tag.subtags);
|
|
@@ -252,9 +245,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
252
245
|
};
|
|
253
246
|
};
|
|
254
247
|
offerDetails.forEach((offer) => {
|
|
255
|
-
const {
|
|
256
|
-
id, couponName, description, couponSeriesId,
|
|
257
|
-
} = offer;
|
|
248
|
+
const { id, couponName, description, couponSeriesId } = offer;
|
|
258
249
|
const couponId = id || couponSeriesId;
|
|
259
250
|
const couponSubTags = {};
|
|
260
251
|
couponTagsKeys.forEach((couponTagKey) => {
|
|
@@ -882,10 +882,6 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
882
882
|
deleteHandler={deleteHandler}
|
|
883
883
|
isEditFlow={isEditFlow}
|
|
884
884
|
hostName={host}
|
|
885
|
-
tags={tags || []}
|
|
886
|
-
injectedTags={injectedTags || {}}
|
|
887
|
-
selectedOfferDetails={selectedOfferDetails}
|
|
888
|
-
eventContextTags={eventContextTags}
|
|
889
885
|
/>
|
|
890
886
|
)}
|
|
891
887
|
</>
|
|
@@ -2701,7 +2697,6 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
2701
2697
|
tags={tags || []}
|
|
2702
2698
|
injectedTags={injectedTags || {}}
|
|
2703
2699
|
selectedOfferDetails={selectedOfferDetails}
|
|
2704
|
-
eventContextTags={eventContextTags}
|
|
2705
2700
|
/>
|
|
2706
2701
|
)}
|
|
2707
2702
|
{isBtnTypeQuickReply && (
|