@capillarytech/creatives-library 8.0.112 → 8.0.113-alpha.0

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.112",
4
+ "version": "8.0.113-alpha.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -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,isValidText } from '../../v2Containers/Line/Container/Wrapper/utils';
23
+ import { isUrl, isValidText } from '../../v2Containers/Line/Container/Wrapper/utils';
24
24
  import TagList from '../../v2Containers/TagList';
25
25
  import {
26
26
  CTA_OPTIONS,
@@ -51,6 +51,7 @@ export const CapWhatsappCTA = (props) => {
51
51
  tags = [],
52
52
  injectedTags = {},
53
53
  selectedOfferDetails = [],
54
+ eventContextTags = [],
54
55
  } = props;
55
56
  const { formatMessage } = intl;
56
57
  const invalidVarRegex = /{{(.*?)}}/g;
@@ -135,8 +136,7 @@ export const CapWhatsappCTA = (props) => {
135
136
  clonedCta.push(cloneDeep(INITIAL_CTA_DATA[0]));
136
137
  if (clonedCta.length === 2) {
137
138
  clonedCta[1].index = 1;
138
- clonedCta[1].ctaType =
139
- clonedCta[0].ctaType === PHONE_NUMBER ? WEBSITE : PHONE_NUMBER;
139
+ clonedCta[1].ctaType = clonedCta[0].ctaType === PHONE_NUMBER ? WEBSITE : PHONE_NUMBER;
140
140
  }
141
141
  updateHandler(clonedCta, null, true);
142
142
  };
@@ -168,8 +168,8 @@ export const CapWhatsappCTA = (props) => {
168
168
  if (!isUrl(value)) {
169
169
  errorMessage = formatMessage(messages.ctaWebsiteUrlErrorMessage);
170
170
  } else if (
171
- urlType === STATIC_URL &&
172
- value.match(invalidVarRegex)?.length > 0
171
+ urlType === STATIC_URL
172
+ && value.match(invalidVarRegex)?.length > 0
173
173
  ) {
174
174
  errorMessage = formatMessage(messages.staticUrlWithVarErrorMessage);
175
175
  }
@@ -178,12 +178,14 @@ export const CapWhatsappCTA = (props) => {
178
178
  };
179
179
 
180
180
  const ctaSaveDisabled = (index) => {
181
- const { ctaType, text, phone_number, url } = ctaData[index] || {};
181
+ const {
182
+ ctaType, text, phone_number, url,
183
+ } = ctaData[index] || {};
182
184
  if (text === '' || buttonError) {
183
185
  return true;
184
- } else if (ctaType === PHONE_NUMBER && phone_number.length < 5) {
186
+ } if (ctaType === PHONE_NUMBER && phone_number.length < 5) {
185
187
  return true;
186
- } else if (ctaType === WEBSITE && (url === '' || urlError)) {
188
+ } if (ctaType === WEBSITE && (url === '' || urlError)) {
187
189
  return true;
188
190
  }
189
191
  return false;
@@ -208,8 +210,9 @@ export const CapWhatsappCTA = (props) => {
208
210
  const renderArray = [];
209
211
  const addBtnDisabled = ctaData.length === 1 && !ctaData[0].isSaved;
210
212
  ctaData.forEach((cta) => {
211
- const { index, ctaType, text, phone_number, urlType, url, isSaved } =
212
- cta || {};
213
+ const {
214
+ index, ctaType, text, phone_number, urlType, url, isSaved,
215
+ } = cta || {};
213
216
  //this is to display buttons after they are saved, in both create and edit mode.
214
217
  if (isSaved) {
215
218
  const ctaIsPhone = ctaType === PHONE_NUMBER;
@@ -237,7 +240,10 @@ export const CapWhatsappCTA = (props) => {
237
240
  </CapColumn>
238
241
  {ctaIsPhone && (
239
242
  <CapColumn span={10} align="left">
240
- <CapLabel className="phone">+{phone_number}</CapLabel>
243
+ <CapLabel className="phone">
244
+ +
245
+ {phone_number}
246
+ </CapLabel>
241
247
  </CapColumn>
242
248
  )}
243
249
  {!ctaIsPhone && (
@@ -249,7 +255,7 @@ export const CapWhatsappCTA = (props) => {
249
255
  : formatMessage(messages.ctaWebsiteTypeDynamic)}
250
256
  </CapLabel>
251
257
  </CapColumn>
252
- <CapTooltip title={url} placement={'top'}>
258
+ <CapTooltip title={url} placement="top">
253
259
  <CapColumn span={7} style={{ marginRight: '0px' }}>
254
260
  <CapLabel className="url">{url}</CapLabel>
255
261
  </CapColumn>
@@ -279,6 +285,7 @@ export const CapWhatsappCTA = (props) => {
279
285
  tags={tags}
280
286
  injectedTags={injectedTags}
281
287
  selectedOfferDetails={selectedOfferDetails}
288
+ eventContextTags={eventContextTags}
282
289
  />
283
290
  </CapColumn>
284
291
  )}
@@ -290,7 +297,7 @@ export const CapWhatsappCTA = (props) => {
290
297
  >
291
298
  <CapTooltip
292
299
  title={formatMessage(messages.whatsappCtaTagListRevert)}
293
- placement={'top'}
300
+ placement="top"
294
301
  >
295
302
  <CapIcon size="s" type="return" />
296
303
  </CapTooltip>
@@ -423,7 +430,7 @@ export const CapWhatsappCTA = (props) => {
423
430
  ? formatMessage(messages.ctaSaveDisabled)
424
431
  : ''
425
432
  }
426
- placement={'bottom'}
433
+ placement="bottom"
427
434
  >
428
435
  <div className="button-disabled-tooltip-wrapper">
429
436
  <CapButton
@@ -451,15 +458,15 @@ export const CapWhatsappCTA = (props) => {
451
458
  {
452
459
  // when first button is not saved, add button is disabled with tooltip
453
460
  // eslint-disable-next-line no-unused-expressions
454
- ctaData.length < 2 &&
455
- !isEditFlow &&
456
- renderArray.push(
461
+ ctaData.length < 2
462
+ && !isEditFlow
463
+ && renderArray.push(
457
464
  <CapRow>
458
465
  <CapTooltip
459
466
  title={
460
467
  addBtnDisabled ? formatMessage(messages.ctaAddDisabled) : ''
461
468
  }
462
- placement={'right'}
469
+ placement="right"
463
470
  >
464
471
  <div className="button-disabled-tooltip-wrapper">
465
472
  <CapButton
@@ -7,6 +7,7 @@
7
7
  import PropTypes from 'prop-types';
8
8
 
9
9
  import React from 'react';
10
+ import { injectIntl } from 'react-intl';
10
11
  import { connect } from 'react-redux';
11
12
  import { Tree } from 'antd';
12
13
  import _ from 'lodash';
@@ -16,17 +17,20 @@ import makeSelectTagList from './selectors';
16
17
  import { UserIsAuthenticated } from '../../utils/authWrapper';
17
18
  import * as actions from './actions';
18
19
  import * as globalActions from '../Cap/actions';
20
+ import messages, { scope } from './messages';
21
+
19
22
  // import styled from styled-components;
20
23
  import CapTagList from '../../v2Components/CapTagList';
21
24
  import './_tagList.scss';
22
25
  import { selectCurrentOrgDetails, makeSelectFetchingSchemaError } from '../Cap/selectors';
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';
26
+ import {
27
+ handleInjectedData, hasGiftVoucherFeature, hasPromoFeature, hasBadgesFeature, transformBadgeTags,
28
+ } from '../../utils/common';
29
+ import {
30
+ GIFT_VOUCHER_RELATED_TAGS, PROMO_ENGINE_RELATED_TAGS, BADGES_RELATED_TAGS, BADGES_ENROLL, BADGES_ISSUE,
31
+ } from '../../containers/App/constants';
28
32
 
29
- const TreeNode = Tree.TreeNode;
33
+ const {TreeNode} = Tree;
30
34
 
31
35
  export class TagList extends React.Component { // eslint-disable-line react/prefer-stateless-function
32
36
  constructor(props) {
@@ -52,35 +56,31 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
52
56
  this.setState({loading: true});
53
57
  }
54
58
  if (!_.isEqual(nextProps.injectedTags, this.props.injectedTags)) {
55
-
56
59
  this.setState({loading: false});
57
60
  }
58
61
  if (!_.isEqual(nextProps.tags, this.props.tags)) {
59
-
60
62
  this.setState({loading: false});
61
63
  }
62
64
  if (nextProps?.fetchingSchemaError) {
63
65
  this.setState({tagsError: nextProps?.fetchingSchemaError});
64
66
  }
65
-
66
67
  }
68
+
67
69
  componentDidUpdate(prevProps) {
68
70
  if (this.props.tags !== prevProps.tags || this.props.injectedTags !== prevProps.injectedTags || this.props.selectedOfferDetails !== prevProps.selectedOfferDetails) {
69
71
  this.generateTags(this.props);
70
72
  }
71
73
  }
74
+
72
75
  onSelect = (selectedKeys) => {
73
76
  this.props.onTagSelect(selectedKeys[0]);
74
77
  };
75
78
 
76
- onClick = (e, data) => {
77
-
78
- };
79
-
80
79
  getTagsforContext = (data) => {
81
80
  //this.setState({loading: true});
82
81
  this.props.onContextChange(data);
83
82
  }
83
+
84
84
  generateTags = (props) => {
85
85
  let tags = {};
86
86
  let injectedTags = {};
@@ -108,24 +108,26 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
108
108
  if (eventContextTags?.length) {
109
109
  const TAG_HEADER_MSG_LABEL = this.props.intl.formatMessage(messages.entryEvent);
110
110
  eventContextTagsObj.eventContextTags = {
111
- name: TAG_HEADER_MSG_LABEL,
112
- desc: TAG_HEADER_MSG_LABEL,
113
- resolved: true,
111
+ "name": TAG_HEADER_MSG_LABEL,
112
+ "desc": TAG_HEADER_MSG_LABEL,
113
+ "resolved": true,
114
114
  'tag-header': true,
115
- subtags: {},
115
+ "subtags": {},
116
116
  };
117
117
 
118
118
  eventContextTags.forEach((tag) => {
119
- const { tagName, label, profileId, profileName } = tag || {};
119
+ const {
120
+ tagName, label, profileId, profileName,
121
+ } = tag || {};
120
122
  if (!profileId || !tagName || !label || !profileName) return;
121
123
  // Initializing the tags profile if it doesn't exist
122
124
  if (!eventContextTagsObj?.eventContextTags?.subtags?.[profileId]) {
123
125
  eventContextTagsObj.eventContextTags.subtags[profileId] = {
124
- name: profileName,
125
- desc: profileName,
126
- resolved: true,
126
+ "name": profileName,
127
+ "desc": profileName,
128
+ "resolved": true,
127
129
  "tag-header": true,
128
- subtags: {},
130
+ "subtags": {},
129
131
  };
130
132
  }
131
133
  // Adding the current tag to the profile group
@@ -138,6 +140,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
138
140
  }
139
141
  this.setState({tags: _.merge( {}, tags, injectedTags, eventContextTagsObj )});
140
142
  }
143
+
141
144
  populateTags(tagsList) {
142
145
  const mainTags = {};
143
146
  const excludedTags = [];
@@ -164,8 +167,8 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
164
167
  }
165
168
  if (!tag['tag-header']) {
166
169
  mainTags[tag.value] = {
167
- "name": tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
168
- "desc": tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
170
+ name: tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
171
+ desc: tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
169
172
  };
170
173
  } else if (tag['tag-header'] && mainTags[tag.value]) {
171
174
  mainTags[tag.value].subtags = _.concat(mainTags[tag.value].subtags, tag.subtags);
@@ -245,7 +248,9 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
245
248
  };
246
249
  };
247
250
  offerDetails.forEach((offer) => {
248
- const { id, couponName, description, couponSeriesId } = offer;
251
+ const {
252
+ id, couponName, description, couponSeriesId,
253
+ } = offer;
249
254
  const couponId = id || couponSeriesId;
250
255
  const couponSubTags = {};
251
256
  couponTagsKeys.forEach((couponTagKey) => {
@@ -882,6 +882,10 @@ 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}
885
889
  />
886
890
  )}
887
891
  </>
@@ -2697,6 +2701,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2697
2701
  tags={tags || []}
2698
2702
  injectedTags={injectedTags || {}}
2699
2703
  selectedOfferDetails={selectedOfferDetails}
2704
+ eventContextTags={eventContextTags}
2700
2705
  />
2701
2706
  )}
2702
2707
  {isBtnTypeQuickReply && (