@capillarytech/creatives-library 7.17.202 → 7.17.203-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.202",
4
+ "version": "7.17.203-alpha.1",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -36,6 +36,7 @@ import { MOBILE_PUSH } from '../../CreativesContainer/constants';
36
36
  import { getCdnUrl } from '../../../utils/cdnTransformation';
37
37
  import { MAPP_SDK } from './constants';
38
38
  import { isEmbeddedEditOrPreview } from '../../../utils/commonUtils';
39
+ import { EMBEDDED } from '../../Whatsapp/constants';
39
40
 
40
41
  const PrefixWrapper = styled.div`
41
42
  margin-right: 16px;
@@ -110,27 +111,35 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
110
111
  let selectedWeChatAccount = {};
111
112
  const queryType = String(get(this.props, 'location.query.type', ''))?.toLowerCase();
112
113
  const creativesMode = String(get(this.props, 'creativesMode', ''))?.toLowerCase();
114
+ const { Edit: EditProps, Templates } = this.props || {};
115
+ const { selectedWeChatAccount: editSelectedWeChatAccount, templateDetails } = EditProps || {};
116
+ const { id: selectedWeChatAccountId } = editSelectedWeChatAccount || {};
117
+ const { definition } = templateDetails || {};
118
+ const { accountId: templateAccountId } = definition || {};
119
+ const { Edit: nextEdit } = nextProps || {};
113
120
  if (isEmbeddedEditOrPreview(queryType, creativesMode)) {
114
- selectedWeChatAccount = !_.isEmpty(this.props.Edit.selectedWeChatAccount)
115
- ? this.props.Edit.selectedWeChatAccount
116
- : nextProps.Edit.selectedWeChatAccount;
117
- } else if (!_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
118
- selectedWeChatAccount = this.props.Templates.selectedWeChatAccount;
121
+ selectedWeChatAccount = !_.isEmpty(editSelectedWeChatAccount)
122
+ ? editSelectedWeChatAccount
123
+ : nextEdit?.selectedWeChatAccount;
124
+ } else if (!_.isEmpty(Templates?.selectedWeChatAccount)) {
125
+ selectedWeChatAccount = Templates?.selectedWeChatAccount;
119
126
  }
120
127
 
121
- if (this.props.location.query.type === 'embedded' && !nextProps.Edit.fetchingWeCrmAccounts && !_.isEqual(this.props.Edit.weCrmAccounts, nextProps.Edit.weCrmAccounts) && (!selectedWeChatAccount || _.isEmpty(selectedWeChatAccount))) {
122
- this.setMobilePushAccountOptions(nextProps.Edit.weCrmAccounts, get(this.props, "templateData.definition.accountId"));
128
+ if (queryType === EMBEDDED && !nextEdit?.fetchingWeCrmAccounts && !_.isEqual(EditProps?.weCrmAccounts, nextEdit?.weCrmAccounts) && (!selectedWeChatAccount || _.isEmpty(selectedWeChatAccount))) {
129
+ this.setMobilePushAccountOptions(nextEdit?.weCrmAccounts, get(this.props, "templateData.definition.accountId"));
123
130
  }
124
- // Check if the query type is 'embedded' and the creatives mode is either 'edit' or 'preview'. Also, ensure that the selected WeChat account ID is not equal to the account ID in the template details.
125
- // If all conditions are met, set the mobile push account options using the provided weCrmAccounts and the account ID from templateData.
126
- if (isEmbeddedEditOrPreview(queryType, creativesMode) && !_.isEqual(this.props.Edit.selectedWeChatAccount?.id, this.props.Edit.templateDetails?.definition?.accountId)) {
127
- this.setMobilePushAccountOptions(nextProps.Edit.weCrmAccounts, get(this.props, "templateData.definition.accountId"));
131
+ // Check if the current mode is either embedded edit or preview, and if the selected WeChat account ID,
132
+ // template account ID, and the next props' weCrmAccounts are available, and if fetchingWeCrmAccounts is false,
133
+ // and if the selected WeChat account ID is not equal to the template account ID.
134
+ // If all conditions are met, set the mobile push account options using the next props' weCrmAccounts and the template account ID.
135
+ if (isEmbeddedEditOrPreview(queryType, creativesMode) && nextEdit?.weCrmAccounts && !_.isEqual(selectedWeChatAccountId, templateAccountId)) {
136
+ this.setMobilePushAccountOptions(nextEdit?.weCrmAccounts, get(this.props, "templateData.definition.accountId"));
128
137
  }
129
- if (!_.isEmpty(nextProps.Edit.selectedWeChatAccount) && !_.isEqual(this.props.Edit.selectedWeChatAccount, nextProps.Edit.selectedWeChatAccount) && (this.props.location.query.type === 'embedded') && this.props.location.query.module === "loyalty") {
138
+ if (!_.isEmpty(nextEdit?.selectedWeChatAccount) && !_.isEqual(editSelectedWeChatAccount, nextEdit?.selectedWeChatAccount) && (queryType === EMBEDDED) && this.props.location.query.module === "loyalty") {
130
139
  const params = {
131
140
  name: '',
132
141
  sortBy: 'Most Recent',
133
- accountId: nextProps.Edit.selectedWeChatAccount.id,
142
+ accountId: nextEdit?.selectedWeChatAccount?.id,
134
143
  };
135
144
  this.props.actions.getMobilepushTemplatesList('mobilepush', params);
136
145
  }
@@ -159,7 +168,6 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
159
168
  this.setTemplateOptions(nextProps.Edit.mobilepushTemplates);
160
169
  }
161
170
  }
162
-
163
171
  this.handleEditSchemaOnPropsChange(nextProps, selectedWeChatAccount);
164
172
  if (nextProps.Edit.uploadedAssetData) {
165
173
  const formData = _.cloneDeep(this.state.formData);