@capillarytech/creatives-library 8.0.331 → 8.0.333

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.
Files changed (33) hide show
  1. package/package.json +2 -2
  2. package/services/api.js +17 -0
  3. package/services/tests/api.test.js +72 -0
  4. package/utils/commonUtils.js +10 -0
  5. package/utils/tests/commonUtil.test.js +169 -0
  6. package/v2Components/CommonTestAndPreview/AddTestCustomer.js +42 -0
  7. package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +155 -0
  8. package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +94 -0
  9. package/v2Components/CommonTestAndPreview/SendTestMessage.js +78 -49
  10. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +134 -34
  11. package/v2Components/CommonTestAndPreview/actions.js +10 -0
  12. package/v2Components/CommonTestAndPreview/constants.js +17 -1
  13. package/v2Components/CommonTestAndPreview/index.js +356 -22
  14. package/v2Components/CommonTestAndPreview/messages.js +106 -0
  15. package/v2Components/CommonTestAndPreview/reducer.js +12 -0
  16. package/v2Components/CommonTestAndPreview/sagas.js +2 -1
  17. package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +66 -0
  18. package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +648 -0
  19. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +23 -5
  20. package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +174 -0
  21. package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +114 -0
  22. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +39 -19
  23. package/v2Components/CommonTestAndPreview/tests/constants.test.js +31 -1
  24. package/v2Components/CommonTestAndPreview/tests/index.test.js +36 -0
  25. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +71 -0
  26. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +17 -0
  27. package/v2Containers/CreativesContainer/index.js +6 -7
  28. package/v2Containers/Rcs/index.js +0 -7
  29. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +1408 -1276
  30. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +321 -288
  31. package/v2Containers/TagList/index.js +11 -15
  32. package/v2Containers/WebPush/Create/index.js +1 -1
  33. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +5246 -4872
@@ -22,7 +22,7 @@ import messages, { scope } from './messages';
22
22
  // import styled from styled-components;
23
23
  import CapTagList from '../../v2Components/CapTagList';
24
24
  import './_tagList.scss';
25
- import { selectCurrentOrgDetails, makeSelectFetchingSchemaError } from '../Cap/selectors';
25
+ import { selectCurrentOrgDetails, makeSelectFetchingSchemaError, makeSelectFetchingSchema } from '../Cap/selectors';
26
26
  import {
27
27
  handleInjectedData, hasGiftVoucherFeature, hasPromoFeature, hasBadgesFeature, transformBadgeTags,
28
28
  } from '../../utils/common';
@@ -35,12 +35,14 @@ const {TreeNode} = Tree;
35
35
  export class TagList extends React.Component { // eslint-disable-line react/prefer-stateless-function
36
36
  constructor(props) {
37
37
  super(props);
38
+ const { tags, injectedTags } = props;
39
+ const hasInitialData = (tags && tags.length > 0) || !_.isEmpty(injectedTags);
38
40
  this.state = {
39
41
  loading: false,
40
42
  tags: [],
41
43
  tagsError: false,
42
44
  currentContext: null, // Track current context to detect changes
43
- hasTriggeredInitialApiCall: false, // Track if we've triggered API call when popover opens
45
+ hasTriggeredInitialApiCall: hasInitialData, // Seed from initial props to avoid duplicate fetch on popover open
44
46
  };
45
47
  this.renderTags = this.renderTags.bind(this);
46
48
  this.populateTags = this.populateTags.bind(this);
@@ -52,14 +54,8 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
52
54
 
53
55
  componentDidMount() {
54
56
  this.generateTags(this.props);
55
- // Trigger initial API call if tags are empty (similar to Email/SMS behavior)
56
- const { tags, injectedTags, onContextChange } = this.props;
57
- const hasNoTags = (!tags || tags.length === 0) && _.isEmpty(injectedTags);
58
- if (hasNoTags && onContextChange) {
59
- // Trigger API call with default 'Outbound' context to match CapTagList default
60
- // This ensures tags are loaded when component mounts
61
- this.getTagsforContext('Outbound');
62
- }
57
+ // Initial schema fetch is the parent's responsibility (useTagManagement hook handles it)
58
+ // This avoids duplicate requests when both parent and child try to fetch on mount
63
59
  }
64
60
 
65
61
  componentWillReceiveProps(nextProps) {
@@ -85,9 +81,10 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
85
81
  if (!_.isEqual(nextTags, currentTags)) {
86
82
  this.setState({loading: false});
87
83
  this.clearLoadingTimeout();
88
- // Reset the flag when tags are received, so we can trigger API call again if needed
84
+ // Tags received (from prefetch or button-click API call) mark as triggered
85
+ // so handlePopoverVisibilityChange won't fire a duplicate call on popover open
89
86
  if (nextTags && nextTags.length > 0) {
90
- this.setState({ hasTriggeredInitialApiCall: false });
87
+ this.setState({ hasTriggeredInitialApiCall: true });
91
88
  }
92
89
  }
93
90
  if (fetchingSchemaError) {
@@ -155,9 +152,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
155
152
  if ((hasNoTags || hasNoStateTags || hasNotTriggeredApiCall)) {
156
153
  // Mark that we've triggered the API call
157
154
  this.setState({ hasTriggeredInitialApiCall: true });
158
- // Trigger API call with default 'Outbound' context to match CapTagList default
159
- // This will call onContextChange which triggers handleOnTagsContextChange in InApp
160
- this.getTagsforContext('Outbound');
155
+ this.getTagsforContext('Outbound'); // Default to Outbound context
161
156
  }
162
157
  }
163
158
  };
@@ -471,6 +466,7 @@ const mapStateToProps = createStructuredSelector({
471
466
  TagList: makeSelectTagList(),
472
467
  currentOrgDetails: selectCurrentOrgDetails(),
473
468
  fetchingSchemaError: makeSelectFetchingSchemaError(),
469
+ fetchingSchema: makeSelectFetchingSchema(),
474
470
  });
475
471
 
476
472
  function mapDispatchToProps(dispatch) {
@@ -1149,7 +1149,7 @@ const withWebPushSaga = injectSaga({
1149
1149
  });
1150
1150
 
1151
1151
  const withTemplateSaga = injectSaga({
1152
- key: 'webPushTemplates',
1152
+ key: 'templates',
1153
1153
  saga: v2TemplateSaga,
1154
1154
  mode: DAEMON,
1155
1155
  });