@capillarytech/creatives-library 7.17.193-alpha.5 → 7.17.193

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 (36) 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 +13 -0
  6. package/services/tests/api.test.js +148 -0
  7. package/utils/common.js +7 -0
  8. package/utils/tagValidations.js +102 -1
  9. package/utils/tests/tagValidations.test.js +381 -2
  10. package/v2Components/ErrorInfoNote/index.js +94 -0
  11. package/v2Components/ErrorInfoNote/messages.js +34 -0
  12. package/v2Components/ErrorInfoNote/style.scss +73 -0
  13. package/v2Components/FormBuilder/_formBuilder.scss +4 -1
  14. package/v2Components/FormBuilder/index.js +166 -69
  15. package/v2Components/FormBuilder/messages.js +4 -0
  16. package/v2Containers/Cap/actions.js +8 -0
  17. package/v2Containers/Cap/constants.js +4 -0
  18. package/v2Containers/Cap/reducer.js +14 -0
  19. package/v2Containers/Cap/sagas.js +676 -2
  20. package/v2Containers/Cap/selectors.js +5 -0
  21. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
  22. package/v2Containers/Cap/tests/reducer.test.js +52 -0
  23. package/v2Containers/Cap/tests/saga.test.js +81 -1
  24. package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -3
  25. package/v2Containers/CreativesContainer/SlideBoxFooter.js +27 -16
  26. package/v2Containers/CreativesContainer/index.js +29 -6
  27. package/v2Containers/CreativesContainer/index.scss +15 -1
  28. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +16 -0
  29. package/v2Containers/Email/index.js +2 -0
  30. package/v2Containers/EmailWrapper/index.js +3 -0
  31. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +3 -0
  32. package/v2Containers/MobilePush/Edit/constants.js +0 -2
  33. package/v2Containers/MobilePush/Edit/index.js +15 -68
  34. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +93 -0
  35. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +12 -0
  36. 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 { MAPP_SDK } from './constants';
38
37
 
39
38
  const PrefixWrapper = styled.div`
40
39
  margin-right: 16px;
@@ -106,23 +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' && (this.props.creativesMode === 'edit' || this.props.creativesMode === 'preview')) {
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
- if (!_.isEqual(this.props.Edit.selectedWeChatAccount?.id, this.props.Edit.templateDetails?.definition?.accountId)) {
124
- this.setMobilePushAccountOptions(nextProps.Edit.weCrmAccounts, get(this.props, "templateData.definition.accountId"));
125
- }
126
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") {
127
114
  const params = {
128
115
  name: '',
@@ -226,22 +213,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
226
213
  }
227
214
  };
228
215
 
229
- getWeChatAccount = () => {
230
- let selectedWeChatAccount = {};
231
- if (this.props.location.query.type === 'embedded' && (this.props.creativesMode === 'edit' || this.props.creativesMode === 'preview')) {
232
- if (!_.isEmpty(this.props.Edit.selectedWeChatAccount)) {
233
- selectedWeChatAccount = this.props.Edit.selectedWeChatAccount;
234
- } else {
235
- selectedWeChatAccount = this.props.Templates.selectedWeChatAccount;
236
- }
237
- } else if (!_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
238
- selectedWeChatAccount = this.props.Templates.selectedWeChatAccount;
239
- }
240
- return selectedWeChatAccount;
241
- }
242
-
243
216
  onLinkTypeChange = (eventTriggered, formData, field, currentTab, inputSchema) => {
244
- const selectedWeChatAccount = this.getWeChatAccount();
217
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
245
218
  const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
246
219
  const tabIndex = currentTab || this.state.currentTab;
247
220
  const inputFields = get(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`);
@@ -358,30 +331,14 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
358
331
  };
359
332
 
360
333
  getTransformedData = (formData) => {
361
- const selectedWeChatAccount = this.getWeChatAccount();
334
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
362
335
  const obj = _.cloneDeep(this.state.editData);
363
336
  obj.versions = {
364
337
  base: {},
365
338
  };
366
339
  obj.type = 'MOBILEPUSH';
367
340
  obj.name = formData['template-name'];
368
- if (this.props.location.query.type === 'embedded' && (this.props.creativesMode === 'edit' || this.props.creativesMode === 'preview')) {
369
- if (this.props.Edit.selectedWeChatAccount?.sourceTypeName === MAPP_SDK) {
370
- obj.definition = {
371
- accountId: selectedWeChatAccount.id,
372
- licenseCode: selectedWeChatAccount.sourceAccountIdentifier,
373
- gatewayId: selectedWeChatAccount.configs.gatewayId,
374
- gatewayAccountId: selectedWeChatAccount.configs.gatewayAccountId,
375
- sourceType: selectedWeChatAccount.sourceTypeName,
376
- };
377
- } else {
378
- obj.definition = {
379
- accountId: selectedWeChatAccount?.id,
380
- licenseCode: selectedWeChatAccount.sourceAccountIdentifier,
381
- sourceType: selectedWeChatAccount.sourceTypeName,
382
- };
383
- }
384
- } else if (this.props.Templates.selectedWeChatAccount?.sourceTypeName === MAPP_SDK) {
341
+ if(this.props?.Templates?.selectedWeChatAccount?.sourceTypeName === 'MAPP_SDK') {
385
342
  obj.definition = {
386
343
  accountId: selectedWeChatAccount.id,
387
344
  licenseCode: selectedWeChatAccount.sourceAccountIdentifier,
@@ -604,7 +561,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
604
561
  };
605
562
 
606
563
  getLinkName = (link) => {
607
- const selectedWeChatAccount = this.getWeChatAccount();
564
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
608
565
  const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
609
566
  const deepLinkOptions = _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (l) => l.link === link);
610
567
  if (deepLinkOptions[0]) {
@@ -1003,7 +960,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1003
960
  showSelectedIosCta = (inputSchema, field, tab, selectedConfig) => {
1004
961
  const currentTab = tab || this.state.currentTab;
1005
962
  const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
1006
- const selectedWeChatAccount = this.getWeChatAccount();
963
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1007
964
  const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1008
965
  const deepLinkOptions = _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) );
1009
966
 
@@ -1131,7 +1088,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1131
1088
  };
1132
1089
 
1133
1090
  deletePrimaryCTA = (event) => {
1134
- const selectedWeChatAccount = this.getWeChatAccount();
1091
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1135
1092
  const id = event.currentTarget.id;
1136
1093
  const schema = _.cloneDeep(this.state.schema);
1137
1094
  // const eventsMap = _.cloneDeep(this.state.eventsMap);
@@ -1231,7 +1188,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1231
1188
  };
1232
1189
 
1233
1190
  deleteSecondaryCTA = (event) => {
1234
- const selectedWeChatAccount = this.getWeChatAccount();
1191
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1235
1192
  const id = event.currentTarget.id;
1236
1193
  if (id === "secondary-cta-0-delete") {
1237
1194
  const secCta2 = document.getElementById("secondary-cta-1-delete");
@@ -1518,12 +1475,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1518
1475
  if (this.props.location.query.type === 'embedded' && temp.id === "mobilepush-accounts" ) {
1519
1476
  temp.options = this.state.templateOptions ? this.state.accountsOptions : [];
1520
1477
  }
1521
- if (temp.id === "mobile-push-preview") {
1522
- if (this.props.location.query.type === 'embedded' && (this.props.creativesMode === 'edit' || this.props.creativesMode === 'preview') && this.props.Edit.selectedWeChatAccount && !_.isEmpty(this.props.Edit.selectedWeChatAccount)) {
1523
- temp.content.appName = this.props.Edit.selectedWeChatAccount.name;
1524
- } else if (this.props.Templates.selectedWeChatAccount && !_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
1525
- temp.content.appName = this.props.Templates.selectedWeChatAccount.name;
1526
- }
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;
1527
1480
  }
1528
1481
  _.forEach(col.supportedEvents, (event) => {
1529
1482
  temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
@@ -1608,7 +1561,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1608
1561
  };
1609
1562
 
1610
1563
  showCtaKeys = (eventTriggered, formData, field, tabIndex, schemaInput) => {
1611
- const selectedWeChatAccount = this.getWeChatAccount();
1564
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1612
1565
  const currentTab = tabIndex || this.state.currentTab;
1613
1566
  const schema = _.cloneDeep(schemaInput || this.state.schema);
1614
1567
  const eventsMap = _.cloneDeep(this.state.eventsMap);
@@ -1663,7 +1616,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1663
1616
  return schema;
1664
1617
  };
1665
1618
  addPrimaryCta = (flag, formData, field, inputSchema, currentTab) => {
1666
- const selectedWeChatAccount = this.getWeChatAccount();
1619
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1667
1620
  const id = field.id;
1668
1621
  const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
1669
1622
  const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
@@ -1696,7 +1649,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1696
1649
  const tabIndex = currentTab || this.state.currentTab;
1697
1650
  const formDataCopy = cloneDeep(formData);
1698
1651
  const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
1699
- const selectedWeChatAccount = this.getWeChatAccount();
1652
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1700
1653
  const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1701
1654
  const deepLinkOptions = selectedWeChatAccount ? _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1702
1655
  const inputFields = get(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`);
@@ -1745,12 +1698,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1745
1698
  if (!_.isEmpty(actionText)) {
1746
1699
  this.deleteSecondaryCtaIos();
1747
1700
  }
1748
- if ((this.props.location.query.type === 'embedded' && (this.props.creativesMode === 'edit' || this.props.creativesMode === 'preview'))) {
1749
- this.props.actions.getIosCtas(this.props.Edit.selectedWeChatAccount.sourceAccountIdentifier);
1750
- } else {
1751
- this.props.actions.getIosCtas(this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier);
1752
- }
1753
- //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
1754
1702
  } else {
1755
1703
  this.deleteSecondaryCtaIos(() => { // oncick of change
1756
1704
  this.setState({showIosCtaTable: true});
@@ -2005,7 +1953,6 @@ Edit.propTypes = {
2005
1953
  onValidationFail: PropTypes.bool,
2006
1954
  onPreviewContentClicked: PropTypes.func,
2007
1955
  onTestContentClicked: PropTypes.func,
2008
- creativesMode: PropTypes.string,
2009
1956
  };
2010
1957
 
2011
1958
  const mapStateToProps = createStructuredSelector({