@capillarytech/creatives-library 8.0.330 → 8.0.331-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 +1 -1
- package/services/api.js +17 -0
- package/services/tests/api.test.js +72 -0
- package/utils/commonUtils.js +10 -0
- package/utils/tests/commonUtil.test.js +169 -0
- package/v2Components/CommonTestAndPreview/AddTestCustomer.js +42 -0
- package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +155 -0
- package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +94 -0
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +78 -49
- package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +134 -34
- package/v2Components/CommonTestAndPreview/actions.js +10 -0
- package/v2Components/CommonTestAndPreview/constants.js +17 -1
- package/v2Components/CommonTestAndPreview/index.js +356 -22
- package/v2Components/CommonTestAndPreview/messages.js +106 -0
- package/v2Components/CommonTestAndPreview/reducer.js +12 -0
- package/v2Components/CommonTestAndPreview/sagas.js +2 -1
- package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +66 -0
- package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +648 -0
- package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +23 -5
- package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +174 -0
- package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +114 -0
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +39 -19
- package/v2Components/CommonTestAndPreview/tests/constants.test.js +31 -1
- package/v2Components/CommonTestAndPreview/tests/index.test.js +36 -0
- package/v2Components/CommonTestAndPreview/tests/reducer.test.js +71 -0
- package/v2Components/CommonTestAndPreview/tests/selectors.test.js +17 -0
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +1408 -1276
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +321 -288
- package/v2Containers/TagList/index.js +11 -15
- package/v2Containers/WebPush/Create/index.js +1 -1
- 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:
|
|
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
|
-
//
|
|
56
|
-
|
|
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
|
-
//
|
|
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:
|
|
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
|
-
|
|
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) {
|