@capillarytech/creatives-library 7.17.21-alpha.0 → 7.17.21-alpha.1

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": "7.17.21-alpha.0",
4
+ "version": "7.17.21-alpha.1",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -30,6 +30,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
30
30
  super(props);
31
31
  this.state = {
32
32
  loading: false,
33
+ tags: []
33
34
  };
34
35
  this.renderTags = this.renderTags.bind(this);
35
36
  this.populateTags = this.populateTags.bind(this);
@@ -42,6 +43,34 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
42
43
 
43
44
  }
44
45
 
46
+ componentDidUpdate(prevProps) {
47
+ if (this.props.tags !== prevProps.tags || this.props.injectedTags !== prevProps.injectedTags || this.props.selectedOfferDetails !== prevProps.selectedOfferDetails) {
48
+ this.setState({
49
+ tags: this.calculateTags(this.props),
50
+ });
51
+ }
52
+ }
53
+
54
+ calculateTags(props) {
55
+ let tags = {};
56
+ let injectedTags = {};
57
+ if (props.injectedTags && !_.isEmpty(props.injectedTags)) {
58
+ const formattedInjectedTags = handleInjectedData(
59
+ props.injectedTags,
60
+ scope
61
+ );
62
+ injectedTags = this.transformInjectedTags(formattedInjectedTags);
63
+ }
64
+ if (props.tags && props.tags.length > 0) {
65
+ tags = this.populateTags(props.tags);
66
+ console.log('populating tags', Object.keys(tags || {}).length);
67
+ }
68
+ if (props.selectedOfferDetails && !_.isEmpty(props.selectedOfferDetails) && (tags && tags.coupon)) {
69
+ this.transformCouponTags(props.selectedOfferDetails, tags);
70
+ }
71
+ return _.merge( {}, tags, injectedTags);
72
+ }
73
+
45
74
  componentWillReceiveProps(nextProps) {
46
75
  if (_.isEmpty(this.props.injectedTags) && _.isEmpty(this.props.tags)) {
47
76
  this.setState({loading: true});
@@ -54,6 +83,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
54
83
 
55
84
  this.setState({loading: false});
56
85
  }
86
+
57
87
  }
58
88
 
59
89
  onSelect = (selectedKeys) => {
@@ -225,29 +255,29 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
225
255
  }
226
256
 
227
257
  render() {
228
- let tags = {};
229
- let injectedTags = {};
230
- if (this.props.injectedTags && !_.isEmpty(this.props.injectedTags)) {
231
- const formattedInjectedTags = handleInjectedData(
232
- this.props.injectedTags,
233
- scope
234
- );
235
- injectedTags = this.transformInjectedTags(formattedInjectedTags);
236
- }
237
- if (this.props.tags && this.props.tags.length > 0) {
238
- tags = this.populateTags(this.props.tags);
239
- console.log('populating tags', Object.keys(tags || {}).length);
240
- }
241
- if (this.props.selectedOfferDetails && !_.isEmpty(this.props.selectedOfferDetails) && (tags && tags.coupon)) {
242
- this.transformCouponTags(this.props.selectedOfferDetails, tags);
243
- }
244
- tags = _.merge( {}, tags, injectedTags);
245
- console.log('merged tags', Object.keys(tags || {}).length);
258
+ // let tags = {};
259
+ // let injectedTags = {};
260
+ // if (this.props.injectedTags && !_.isEmpty(this.props.injectedTags)) {
261
+ // const formattedInjectedTags = handleInjectedData(
262
+ // this.props.injectedTags,
263
+ // scope
264
+ // );
265
+ // injectedTags = this.transformInjectedTags(formattedInjectedTags);
266
+ // }
267
+ // if (this.props.tags && this.props.tags.length > 0) {
268
+ // tags = this.populateTags(this.props.tags);
269
+ // console.log('populating tags', Object.keys(tags || {}).length);
270
+ // }
271
+ // if (this.props.selectedOfferDetails && !_.isEmpty(this.props.selectedOfferDetails) && (tags && tags.coupon)) {
272
+ // this.transformCouponTags(this.props.selectedOfferDetails, tags);
273
+ // }
274
+ // tags = _.merge( {}, tags, injectedTags);
275
+ // console.log('merged tags', Object.keys(tags || {}).length);
246
276
  return (
247
277
  <div className={this.props.className ? this.props.className : ''}>
248
278
  <CapTagList
249
279
  loading={this.state.loading}
250
- tags={tags}
280
+ tags={this.state.tags}
251
281
  onSelect={this.onSelect}
252
282
  label={this.props.label}
253
283
  visibleTaglist={this.props.visibleTaglist}