@capillarytech/creatives-library 8.0.9 → 8.0.11
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/config/app.js +2 -0
- package/containers/App/constants.js +1 -0
- package/initialState.js +3 -0
- package/package.json +1 -1
- package/services/api.js +20 -0
- package/services/tests/api.test.js +148 -0
- package/utils/common.js +7 -0
- package/utils/commonUtils.js +7 -1
- package/utils/tagValidations.js +99 -1
- package/utils/tests/commonUtil.test.js +37 -1
- package/utils/tests/tagValidations.test.js +392 -2
- package/v2Components/Ckeditor/index.js +12 -10
- package/v2Components/ErrorInfoNote/index.js +89 -0
- package/v2Components/ErrorInfoNote/messages.js +29 -0
- package/v2Components/ErrorInfoNote/style.scss +72 -0
- package/v2Components/FormBuilder/_formBuilder.scss +4 -1
- package/v2Components/FormBuilder/index.js +171 -70
- package/v2Components/FormBuilder/messages.js +8 -0
- package/v2Containers/Cap/actions.js +8 -0
- package/v2Containers/Cap/constants.js +4 -0
- package/v2Containers/Cap/mockData.js +74 -0
- package/v2Containers/Cap/reducer.js +12 -0
- package/v2Containers/Cap/sagas.js +28 -1
- package/v2Containers/Cap/selectors.js +5 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/Cap/tests/reducer.test.js +50 -0
- package/v2Containers/Cap/tests/saga.test.js +81 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +7 -0
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +40 -17
- package/v2Containers/CreativesContainer/constants.js +1 -0
- package/v2Containers/CreativesContainer/index.js +45 -4
- package/v2Containers/CreativesContainer/index.scss +13 -1
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +16 -0
- package/v2Containers/Email/_email.scss +3 -0
- package/v2Containers/Email/index.js +2 -0
- package/v2Containers/EmailWrapper/index.js +3 -0
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +3 -0
- package/v2Containers/Line/Container/sagas.js +1 -1
- package/v2Containers/MobilePush/Edit/constants.js +2 -0
- package/v2Containers/MobilePush/Edit/index.js +91 -24
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +93 -0
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +12 -0
- package/v2Containers/Viber/constants.js +1 -1
- package/v2Containers/Viber/index.js +19 -19
- package/v2Containers/Viber/messages.js +0 -4
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +12 -0
|
@@ -39,6 +39,9 @@ import injectReducer from '../../../utils/injectReducer';
|
|
|
39
39
|
import { v2MobilePushEditSagas } from './sagas';
|
|
40
40
|
import v2MobilePushEditReducer from './reducer';
|
|
41
41
|
import * as globalActions from '../../Cap/actions';
|
|
42
|
+
import { MAPP_SDK } from './constants';
|
|
43
|
+
import { isEmbeddedEditOrPreview } from '../../../utils/commonUtils';
|
|
44
|
+
|
|
42
45
|
const PrefixWrapper = styled.div`
|
|
43
46
|
margin-right: 16px;
|
|
44
47
|
`;
|
|
@@ -109,11 +112,25 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
109
112
|
} else if (nextProps.isGetFormData && this.props.isGetFormData !== nextProps.isGetFormData && this.props.isFullMode && !this.props.Create.createTemplateInProgress) {
|
|
110
113
|
this.startValidation();
|
|
111
114
|
}
|
|
112
|
-
|
|
113
|
-
(
|
|
115
|
+
let selectedWeChatAccount = {};
|
|
116
|
+
const queryType = String(get(this.props, 'location.query.type', ''))?.toLowerCase();
|
|
117
|
+
const creativesMode = String(get(this.props, 'creativesMode', ''))?.toLowerCase();
|
|
118
|
+
if (isEmbeddedEditOrPreview(queryType, creativesMode)) {
|
|
119
|
+
selectedWeChatAccount = !_.isEmpty(this.props.Edit.selectedWeChatAccount)
|
|
120
|
+
? this.props.Edit.selectedWeChatAccount
|
|
121
|
+
: nextProps.Edit.selectedWeChatAccount;
|
|
122
|
+
} else if (!_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
|
|
123
|
+
selectedWeChatAccount = this.props.Templates.selectedWeChatAccount;
|
|
124
|
+
}
|
|
125
|
+
|
|
114
126
|
if (this.props.location.query.type === 'embedded' && !nextProps.Edit.fetchingWeCrmAccounts && !_.isEqual(this.props.Edit.weCrmAccounts, nextProps.Edit.weCrmAccounts) && (!selectedWeChatAccount || _.isEmpty(selectedWeChatAccount))) {
|
|
115
127
|
this.setMobilePushAccountOptions(nextProps.Edit.weCrmAccounts, get(this.props, "templateData.definition.accountId"));
|
|
116
128
|
}
|
|
129
|
+
// 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.
|
|
130
|
+
// If all conditions are met, set the mobile push account options using the provided weCrmAccounts and the account ID from templateData.
|
|
131
|
+
if (isEmbeddedEditOrPreview(queryType, creativesMode) && !_.isEqual(this.props.Edit.selectedWeChatAccount?.id, this.props.Edit.templateDetails?.definition?.accountId)) {
|
|
132
|
+
this.setMobilePushAccountOptions(nextProps.Edit.weCrmAccounts, get(this.props, "templateData.definition.accountId"));
|
|
133
|
+
}
|
|
117
134
|
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") {
|
|
118
135
|
const params = {
|
|
119
136
|
name: '',
|
|
@@ -217,8 +234,26 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
217
234
|
}
|
|
218
235
|
};
|
|
219
236
|
|
|
237
|
+
getWeChatAccount = () => {
|
|
238
|
+
const { location, creativesMode, Edit: EditProps, Templates } = this.props || {};
|
|
239
|
+
const { query } = location || {};
|
|
240
|
+
const { selectedWeChatAccount: editSelectedWeChatAccount } = EditProps || {};
|
|
241
|
+
const { selectedWeChatAccount: templateSelectedWeChatAccount } = Templates || {};
|
|
242
|
+
const queryType = String(get(query, 'type', '')).toLowerCase();
|
|
243
|
+
const mode = String(creativesMode).toLowerCase();
|
|
244
|
+
let selectedWeChatAccount = {};
|
|
245
|
+
if (isEmbeddedEditOrPreview(queryType, mode)) {
|
|
246
|
+
selectedWeChatAccount = !_.isEmpty(editSelectedWeChatAccount)
|
|
247
|
+
? editSelectedWeChatAccount
|
|
248
|
+
: templateSelectedWeChatAccount;
|
|
249
|
+
} else if (!_.isEmpty(templateSelectedWeChatAccount)) {
|
|
250
|
+
selectedWeChatAccount = templateSelectedWeChatAccount;
|
|
251
|
+
}
|
|
252
|
+
return selectedWeChatAccount;
|
|
253
|
+
};
|
|
254
|
+
|
|
220
255
|
onLinkTypeChange = (eventTriggered, formData, field, currentTab, inputSchema) => {
|
|
221
|
-
const selectedWeChatAccount =
|
|
256
|
+
const selectedWeChatAccount = this.getWeChatAccount();
|
|
222
257
|
const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
|
|
223
258
|
const tabIndex = currentTab || this.state.currentTab;
|
|
224
259
|
const inputFields = get(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`);
|
|
@@ -334,27 +369,41 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
334
369
|
this.setState({formData, accountsOptions: accounts.map((acc) => ({key: acc.id, label: acc.name, value: acc.id}))});
|
|
335
370
|
};
|
|
336
371
|
|
|
372
|
+
createDefinition = (account) => ({
|
|
373
|
+
accountId: account?.id,
|
|
374
|
+
licenseCode: account?.sourceAccountIdentifier,
|
|
375
|
+
gatewayId: account?.configs?.gatewayId,
|
|
376
|
+
gatewayAccountId: account?.configs?.gatewayAccountId,
|
|
377
|
+
sourceType: account?.sourceTypeName,
|
|
378
|
+
});
|
|
379
|
+
|
|
337
380
|
getTransformedData = (formData) => {
|
|
338
|
-
const selectedWeChatAccount =
|
|
381
|
+
const selectedWeChatAccount = this.getWeChatAccount();
|
|
339
382
|
const obj = _.cloneDeep(this.state.editData);
|
|
340
383
|
obj.versions = {
|
|
341
384
|
base: {},
|
|
342
385
|
};
|
|
343
386
|
obj.type = 'MOBILEPUSH';
|
|
344
387
|
obj.name = formData['template-name'];
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
388
|
+
const queryType = String(get(this.props, 'location.query.type', ''))?.toLowerCase();
|
|
389
|
+
const creativesMode = String(get(this.props, 'creativesMode', ''))?.toLowerCase();
|
|
390
|
+
if (isEmbeddedEditOrPreview(queryType, creativesMode)) {
|
|
391
|
+
if (get(this.props, 'Edit.selectedWeChatAccount.sourceTypeName') === MAPP_SDK) {
|
|
392
|
+
obj.definition = this.createDefinition(selectedWeChatAccount);
|
|
393
|
+
} else {
|
|
394
|
+
obj.definition = {
|
|
395
|
+
accountId: selectedWeChatAccount?.id,
|
|
396
|
+
licenseCode: selectedWeChatAccount?.sourceAccountIdentifier,
|
|
397
|
+
sourceType: selectedWeChatAccount?.sourceTypeName,
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
} else if (get(this.props, 'Templates.selectedWeChatAccount.sourceTypeName') === MAPP_SDK) {
|
|
401
|
+
obj.definition = this.createDefinition(selectedWeChatAccount);
|
|
353
402
|
} else {
|
|
354
403
|
obj.definition = {
|
|
355
404
|
accountId: selectedWeChatAccount?.id,
|
|
356
|
-
licenseCode: selectedWeChatAccount
|
|
357
|
-
sourceType: selectedWeChatAccount
|
|
405
|
+
licenseCode: selectedWeChatAccount?.sourceAccountIdentifier,
|
|
406
|
+
sourceType: selectedWeChatAccount?.sourceTypeName,
|
|
358
407
|
};
|
|
359
408
|
}
|
|
360
409
|
if (this.props.location.query && this.props.location.query.module !== 'dvs') {
|
|
@@ -565,7 +614,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
565
614
|
};
|
|
566
615
|
|
|
567
616
|
getLinkName = (link) => {
|
|
568
|
-
const selectedWeChatAccount =
|
|
617
|
+
const selectedWeChatAccount = this.getWeChatAccount();
|
|
569
618
|
const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
|
|
570
619
|
const deepLinkOptions = _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (l) => l.link === link);
|
|
571
620
|
if (deepLinkOptions[0]) {
|
|
@@ -964,7 +1013,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
964
1013
|
showSelectedIosCta = (inputSchema, field, tab, selectedConfig) => {
|
|
965
1014
|
const currentTab = tab || this.state.currentTab;
|
|
966
1015
|
const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
|
|
967
|
-
const selectedWeChatAccount =
|
|
1016
|
+
const selectedWeChatAccount = this.getWeChatAccount();
|
|
968
1017
|
const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
|
|
969
1018
|
const deepLinkOptions = _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) );
|
|
970
1019
|
|
|
@@ -1092,7 +1141,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1092
1141
|
};
|
|
1093
1142
|
|
|
1094
1143
|
deletePrimaryCTA = (event) => {
|
|
1095
|
-
const selectedWeChatAccount =
|
|
1144
|
+
const selectedWeChatAccount = this.getWeChatAccount();
|
|
1096
1145
|
const id = event.currentTarget.id;
|
|
1097
1146
|
const schema = _.cloneDeep(this.state.schema);
|
|
1098
1147
|
// const eventsMap = _.cloneDeep(this.state.eventsMap);
|
|
@@ -1192,7 +1241,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1192
1241
|
};
|
|
1193
1242
|
|
|
1194
1243
|
deleteSecondaryCTA = (event) => {
|
|
1195
|
-
const selectedWeChatAccount =
|
|
1244
|
+
const selectedWeChatAccount = this.getWeChatAccount();
|
|
1196
1245
|
const id = event.currentTarget.id;
|
|
1197
1246
|
if (id === "secondary-cta-0-delete") {
|
|
1198
1247
|
const secCta2 = document.getElementById("secondary-cta-1-delete");
|
|
@@ -1479,8 +1528,18 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1479
1528
|
if (this.props.location.query.type === 'embedded' && temp.id === "mobilepush-accounts" ) {
|
|
1480
1529
|
temp.options = this.state.templateOptions ? this.state.accountsOptions : [];
|
|
1481
1530
|
}
|
|
1482
|
-
if (temp.id === "mobile-push-preview"
|
|
1483
|
-
|
|
1531
|
+
if (temp.id === "mobile-push-preview") {
|
|
1532
|
+
const { location, creativesMode, Edit: EditProps, Templates } = this.props || {};
|
|
1533
|
+
const { query } = location || {};
|
|
1534
|
+
const { selectedWeChatAccount: editSelectedWeChatAccount } = EditProps || {};
|
|
1535
|
+
const { selectedWeChatAccount: templateSelectedWeChatAccount } = Templates || {};
|
|
1536
|
+
const queryType = String(get(query, 'type', ''))?.toLowerCase();
|
|
1537
|
+
const mode = String(creativesMode).toLowerCase();
|
|
1538
|
+
if (isEmbeddedEditOrPreview(queryType, mode) && !_.isEmpty(editSelectedWeChatAccount)) {
|
|
1539
|
+
temp.content.appName = editSelectedWeChatAccount?.name;
|
|
1540
|
+
} else if (!_.isEmpty(templateSelectedWeChatAccount)) {
|
|
1541
|
+
temp.content.appName = templateSelectedWeChatAccount?.name;
|
|
1542
|
+
}
|
|
1484
1543
|
}
|
|
1485
1544
|
_.forEach(col.supportedEvents, (event) => {
|
|
1486
1545
|
temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
|
|
@@ -1565,7 +1624,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1565
1624
|
};
|
|
1566
1625
|
|
|
1567
1626
|
showCtaKeys = (eventTriggered, formData, field, tabIndex, schemaInput) => {
|
|
1568
|
-
const selectedWeChatAccount =
|
|
1627
|
+
const selectedWeChatAccount = this.getWeChatAccount();
|
|
1569
1628
|
const currentTab = tabIndex || this.state.currentTab;
|
|
1570
1629
|
const schema = _.cloneDeep(schemaInput || this.state.schema);
|
|
1571
1630
|
const eventsMap = _.cloneDeep(this.state.eventsMap);
|
|
@@ -1620,7 +1679,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1620
1679
|
return schema;
|
|
1621
1680
|
};
|
|
1622
1681
|
addPrimaryCta = (flag, formData, field, inputSchema, currentTab) => {
|
|
1623
|
-
const selectedWeChatAccount =
|
|
1682
|
+
const selectedWeChatAccount = this.getWeChatAccount();
|
|
1624
1683
|
const id = field.id;
|
|
1625
1684
|
const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
|
|
1626
1685
|
const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
|
|
@@ -1653,7 +1712,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1653
1712
|
const tabIndex = currentTab || this.state.currentTab;
|
|
1654
1713
|
const formDataCopy = cloneDeep(formData);
|
|
1655
1714
|
const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
|
|
1656
|
-
const selectedWeChatAccount =
|
|
1715
|
+
const selectedWeChatAccount = this.getWeChatAccount();
|
|
1657
1716
|
const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
|
|
1658
1717
|
const deepLinkOptions = selectedWeChatAccount ? _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
|
|
1659
1718
|
const inputFields = get(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`);
|
|
@@ -1702,7 +1761,14 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1702
1761
|
if (!_.isEmpty(actionText)) {
|
|
1703
1762
|
this.deleteSecondaryCtaIos();
|
|
1704
1763
|
}
|
|
1705
|
-
|
|
1764
|
+
const queryType = String(get(this.props, 'location.query.type', ''))?.toLowerCase();
|
|
1765
|
+
const creativesMode = String(get(this.props, 'creativesMode', ''))?.toLowerCase();
|
|
1766
|
+
if (isEmbeddedEditOrPreview(queryType, creativesMode)) {
|
|
1767
|
+
this.props.actions.getIosCtas(this.props.Edit.selectedWeChatAccount.sourceAccountIdentifier);
|
|
1768
|
+
} else {
|
|
1769
|
+
this.props.actions.getIosCtas(this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier);
|
|
1770
|
+
}
|
|
1771
|
+
//TODO: need to get license code of accoutn and send as arg
|
|
1706
1772
|
} else {
|
|
1707
1773
|
this.deleteSecondaryCtaIos(() => { // oncick of change
|
|
1708
1774
|
this.setState({showIosCtaTable: true});
|
|
@@ -1957,6 +2023,7 @@ Edit.propTypes = {
|
|
|
1957
2023
|
onValidationFail: PropTypes.bool,
|
|
1958
2024
|
onPreviewContentClicked: PropTypes.func,
|
|
1959
2025
|
onTestContentClicked: PropTypes.func,
|
|
2026
|
+
creativesMode: PropTypes.string,
|
|
1960
2027
|
};
|
|
1961
2028
|
|
|
1962
2029
|
const mapStateToProps = createStructuredSelector({
|