@capillarytech/creatives-library 7.17.195 → 7.17.196

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 (40) hide show
  1. package/config/app.js +2 -0
  2. package/containers/App/constants.js +1 -0
  3. package/initialState.js +3 -0
  4. package/package.json +1 -1
  5. package/services/api.js +20 -0
  6. package/services/tests/api.test.js +148 -0
  7. package/utils/common.js +7 -0
  8. package/utils/tagValidations.js +99 -1
  9. package/utils/tests/tagValidations.test.js +392 -2
  10. package/v2Components/Ckeditor/index.js +1 -1
  11. package/v2Components/ErrorInfoNote/index.js +89 -0
  12. package/v2Components/ErrorInfoNote/messages.js +29 -0
  13. package/v2Components/ErrorInfoNote/style.scss +72 -0
  14. package/v2Components/FormBuilder/_formBuilder.scss +4 -1
  15. package/v2Components/FormBuilder/index.js +170 -69
  16. package/v2Components/FormBuilder/messages.js +8 -0
  17. package/v2Containers/Cap/actions.js +8 -0
  18. package/v2Containers/Cap/constants.js +4 -0
  19. package/v2Containers/Cap/mockData.js +74 -0
  20. package/v2Containers/Cap/reducer.js +12 -0
  21. package/v2Containers/Cap/sagas.js +28 -1
  22. package/v2Containers/Cap/selectors.js +5 -0
  23. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
  24. package/v2Containers/Cap/tests/reducer.test.js +50 -0
  25. package/v2Containers/Cap/tests/saga.test.js +81 -1
  26. package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -3
  27. package/v2Containers/CreativesContainer/SlideBoxFooter.js +40 -17
  28. package/v2Containers/CreativesContainer/constants.js +1 -0
  29. package/v2Containers/CreativesContainer/index.js +45 -6
  30. package/v2Containers/CreativesContainer/index.scss +13 -1
  31. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +16 -0
  32. package/v2Containers/Email/_email.scss +3 -0
  33. package/v2Containers/Email/index.js +2 -0
  34. package/v2Containers/EmailWrapper/index.js +3 -0
  35. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +3 -0
  36. package/v2Containers/MobilePush/Edit/constants.js +0 -5
  37. package/v2Containers/MobilePush/Edit/index.js +15 -73
  38. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +93 -0
  39. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +12 -0
  40. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +12 -0
@@ -34,7 +34,6 @@ import { GA } from '@capillarytech/cap-ui-utils';
34
34
  import { EDIT, TRACK_EDIT_MPUSH } from '../../App/constants';
35
35
  import { MOBILE_PUSH } from '../../CreativesContainer/constants';
36
36
  import { getCdnUrl } from '../../../utils/cdnTransformation';
37
- import { EMBEDDED, MAPP_SDK, PREVIEW } from './constants';
38
37
 
39
38
  const PrefixWrapper = styled.div`
40
39
  margin-right: 16px;
@@ -106,25 +105,11 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
106
105
  } else if (nextProps.isGetFormData && this.props.isGetFormData !== nextProps.isGetFormData && this.props.isFullMode && !this.props.Create.createTemplateInProgress) {
107
106
  this.startValidation();
108
107
  }
109
- let selectedWeChatAccount = {};
110
- if (this.props.location.query.type === EMBEDDED.toLowerCase() && (this.props.creativesMode === EDIT.toLowerCase() || this.props.creativesMode === PREVIEW.toLowerCase())) {
111
- if (!_.isEmpty(this.props.Edit.selectedWeChatAccount)) {
112
- selectedWeChatAccount = this.props.Edit.selectedWeChatAccount;
113
- } else {
114
- selectedWeChatAccount = nextProps.Edit.selectedWeChatAccount;
115
- }
116
- } else if (!_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
117
- selectedWeChatAccount = this.props.Templates.selectedWeChatAccount;
118
- }
119
-
108
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount :
109
+ (!_.isEmpty(this.props.Edit.selectedWeChatAccount) ? this.props.Edit.selectedWeChatAccount : nextProps.Edit.selectedWeChatAccount));
120
110
  if (this.props.location.query.type === 'embedded' && !nextProps.Edit.fetchingWeCrmAccounts && !_.isEqual(this.props.Edit.weCrmAccounts, nextProps.Edit.weCrmAccounts) && (!selectedWeChatAccount || _.isEmpty(selectedWeChatAccount))) {
121
111
  this.setMobilePushAccountOptions(nextProps.Edit.weCrmAccounts, get(this.props, "templateData.definition.accountId"));
122
112
  }
123
- // 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.
124
- // If all conditions are met, set the mobile push account options using the provided weCrmAccounts and the account ID from templateData.
125
- if (this.props.location.query.type === EMBEDDED.toLowerCase() && (this.props.creativesMode === EDIT.toLowerCase() || this.props.creativesMode === PREVIEW.toLowerCase()) && !_.isEqual(this.props.Edit.selectedWeChatAccount?.id, this.props.Edit.templateDetails?.definition?.accountId)) {
126
- this.setMobilePushAccountOptions(nextProps.Edit.weCrmAccounts, get(this.props, "templateData.definition.accountId"));
127
- }
128
113
  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") {
129
114
  const params = {
130
115
  name: '',
@@ -228,25 +213,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
228
213
  }
229
214
  };
230
215
 
231
- getWeChatAccount = () => {
232
- let selectedWeChatAccount = {};
233
- const {type = ''} = this.props.location?.query;
234
- const {creativesMode = ''} = this.props;
235
-
236
- if (type === EMBEDDED.toLowerCase() && (creativesMode === EDIT.toLowerCase() || creativesMode === PREVIEW.toLowerCase())) {
237
- if (!_.isEmpty(this.props.Edit.selectedWeChatAccount)) {
238
- selectedWeChatAccount = this.props.Edit.selectedWeChatAccount;
239
- } else {
240
- selectedWeChatAccount = this.props.Templates.selectedWeChatAccount;
241
- }
242
- } else if (!_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
243
- selectedWeChatAccount = this.props.Templates.selectedWeChatAccount;
244
- }
245
- return selectedWeChatAccount;
246
- }
247
-
248
216
  onLinkTypeChange = (eventTriggered, formData, field, currentTab, inputSchema) => {
249
- const selectedWeChatAccount = this.getWeChatAccount();
217
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
250
218
  const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
251
219
  const tabIndex = currentTab || this.state.currentTab;
252
220
  const inputFields = get(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`);
@@ -363,30 +331,14 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
363
331
  };
364
332
 
365
333
  getTransformedData = (formData) => {
366
- const selectedWeChatAccount = this.getWeChatAccount();
334
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
367
335
  const obj = _.cloneDeep(this.state.editData);
368
336
  obj.versions = {
369
337
  base: {},
370
338
  };
371
339
  obj.type = 'MOBILEPUSH';
372
340
  obj.name = formData['template-name'];
373
- if (this.props.location.query.type === EMBEDDED.toLowerCase() && (this.props.creativesMode === EDIT.toLowerCase() || this.props.creativesMode === PREVIEW.toLowerCase())) {
374
- if (get(this.props, 'Edit.selectedWeChatAccount.sourceTypeName') === MAPP_SDK) {
375
- obj.definition = {
376
- accountId: selectedWeChatAccount.id,
377
- licenseCode: selectedWeChatAccount.sourceAccountIdentifier,
378
- gatewayId: selectedWeChatAccount.configs.gatewayId,
379
- gatewayAccountId: selectedWeChatAccount.configs.gatewayAccountId,
380
- sourceType: selectedWeChatAccount.sourceTypeName,
381
- };
382
- } else {
383
- obj.definition = {
384
- accountId: selectedWeChatAccount?.id,
385
- licenseCode: selectedWeChatAccount.sourceAccountIdentifier,
386
- sourceType: selectedWeChatAccount.sourceTypeName,
387
- };
388
- }
389
- } else if (get(this.props, 'Templates.selectedWeChatAccount.sourceTypeName') === MAPP_SDK) {
341
+ if(this.props?.Templates?.selectedWeChatAccount?.sourceTypeName === 'MAPP_SDK') {
390
342
  obj.definition = {
391
343
  accountId: selectedWeChatAccount.id,
392
344
  licenseCode: selectedWeChatAccount.sourceAccountIdentifier,
@@ -609,7 +561,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
609
561
  };
610
562
 
611
563
  getLinkName = (link) => {
612
- const selectedWeChatAccount = this.getWeChatAccount();
564
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
613
565
  const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
614
566
  const deepLinkOptions = _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (l) => l.link === link);
615
567
  if (deepLinkOptions[0]) {
@@ -1008,7 +960,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1008
960
  showSelectedIosCta = (inputSchema, field, tab, selectedConfig) => {
1009
961
  const currentTab = tab || this.state.currentTab;
1010
962
  const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
1011
- const selectedWeChatAccount = this.getWeChatAccount();
963
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1012
964
  const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1013
965
  const deepLinkOptions = _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) );
1014
966
 
@@ -1136,7 +1088,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1136
1088
  };
1137
1089
 
1138
1090
  deletePrimaryCTA = (event) => {
1139
- const selectedWeChatAccount = this.getWeChatAccount();
1091
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1140
1092
  const id = event.currentTarget.id;
1141
1093
  const schema = _.cloneDeep(this.state.schema);
1142
1094
  // const eventsMap = _.cloneDeep(this.state.eventsMap);
@@ -1236,7 +1188,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1236
1188
  };
1237
1189
 
1238
1190
  deleteSecondaryCTA = (event) => {
1239
- const selectedWeChatAccount = this.getWeChatAccount();
1191
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1240
1192
  const id = event.currentTarget.id;
1241
1193
  if (id === "secondary-cta-0-delete") {
1242
1194
  const secCta2 = document.getElementById("secondary-cta-1-delete");
@@ -1523,12 +1475,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1523
1475
  if (this.props.location.query.type === 'embedded' && temp.id === "mobilepush-accounts" ) {
1524
1476
  temp.options = this.state.templateOptions ? this.state.accountsOptions : [];
1525
1477
  }
1526
- if (temp.id === "mobile-push-preview") {
1527
- if (this.props.location.query.type === EMBEDDED.toLowerCase() && (this.props.creativesMode === EDIT.toLowerCase() || this.props.creativesMode === PREVIEW.toLowerCase()) && this.props.Edit.selectedWeChatAccount && !_.isEmpty(this.props.Edit.selectedWeChatAccount)) {
1528
- temp.content.appName = this.props.Edit.selectedWeChatAccount.name;
1529
- } else if (this.props.Templates.selectedWeChatAccount && !_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
1530
- temp.content.appName = this.props.Templates.selectedWeChatAccount.name;
1531
- }
1478
+ if (temp.id === "mobile-push-preview" && this.props.Templates.selectedWeChatAccount && !_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
1479
+ temp.content.appName = this.props.Templates.selectedWeChatAccount.name;
1532
1480
  }
1533
1481
  _.forEach(col.supportedEvents, (event) => {
1534
1482
  temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
@@ -1613,7 +1561,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1613
1561
  };
1614
1562
 
1615
1563
  showCtaKeys = (eventTriggered, formData, field, tabIndex, schemaInput) => {
1616
- const selectedWeChatAccount = this.getWeChatAccount();
1564
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1617
1565
  const currentTab = tabIndex || this.state.currentTab;
1618
1566
  const schema = _.cloneDeep(schemaInput || this.state.schema);
1619
1567
  const eventsMap = _.cloneDeep(this.state.eventsMap);
@@ -1668,7 +1616,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1668
1616
  return schema;
1669
1617
  };
1670
1618
  addPrimaryCta = (flag, formData, field, inputSchema, currentTab) => {
1671
- const selectedWeChatAccount = this.getWeChatAccount();
1619
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1672
1620
  const id = field.id;
1673
1621
  const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
1674
1622
  const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
@@ -1701,7 +1649,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1701
1649
  const tabIndex = currentTab || this.state.currentTab;
1702
1650
  const formDataCopy = cloneDeep(formData);
1703
1651
  const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
1704
- const selectedWeChatAccount = this.getWeChatAccount();
1652
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1705
1653
  const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1706
1654
  const deepLinkOptions = selectedWeChatAccount ? _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1707
1655
  const inputFields = get(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`);
@@ -1750,12 +1698,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1750
1698
  if (!_.isEmpty(actionText)) {
1751
1699
  this.deleteSecondaryCtaIos();
1752
1700
  }
1753
- if ((this.props.location.query.type === EMBEDDED.toLowerCase() && (this.props.creativesMode === EDIT.toLowerCase() || this.props.creativesMode === PREVIEW.toLowerCase()))) {
1754
- this.props.actions.getIosCtas(this.props.Edit.selectedWeChatAccount.sourceAccountIdentifier);
1755
- } else {
1756
- this.props.actions.getIosCtas(this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier);
1757
- }
1758
- //TODO: need to get license code of accoutn and send as arg
1701
+ this.props.actions.getIosCtas(this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier);//TODO: need to get license code of accoutn and send as arg
1759
1702
  } else {
1760
1703
  this.deleteSecondaryCtaIos(() => { // oncick of change
1761
1704
  this.setState({showIosCtaTable: true});
@@ -2010,7 +1953,6 @@ Edit.propTypes = {
2010
1953
  onValidationFail: PropTypes.bool,
2011
1954
  onPreviewContentClicked: PropTypes.func,
2012
1955
  onTestContentClicked: PropTypes.func,
2013
- creativesMode: PropTypes.string,
2014
1956
  };
2015
1957
 
2016
1958
  const mapStateToProps = createStructuredSelector({