@capillarytech/creatives-library 8.0.17 → 8.0.19

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": "8.0.17",
4
+ "version": "8.0.19",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -265,4 +265,13 @@ export const preprocessHtml = (content) => {
265
265
 
266
266
  // Step 2: Perform the standard replacements on the entire content
267
267
  return contentWithStyleFixes?.replace(/'|"|&|<|>|"|\n/g, match => replacements[match]);
268
+ };
269
+
270
+ //this is used to get the subtags from custom or extended tags
271
+ export const getTagMapValue = (object = {}) => {
272
+ return Object.values(
273
+ object
274
+ ).reduce((acc, current) => {
275
+ return { ...acc?.subtags ?? {}, ...current?.subtags ?? {} };
276
+ }, {});
268
277
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import '@testing-library/jest-dom';
3
- import { checkSupport, extractNames, preprocessHtml, validateIfTagClosed,validateTags} from '../tagValidations';
3
+ import { checkSupport, extractNames, getTagMapValue, preprocessHtml, validateIfTagClosed,validateTags} from '../tagValidations';
4
4
 
5
5
  describe("check if curly brackets are balanced", () => {
6
6
  it("test for balanced curly brackets", () => {
@@ -421,4 +421,26 @@ describe('preprocessHtml', () => {
421
421
  expect(preprocessHtml(input)).toEqual(expectedOutput);
422
422
  });
423
423
 
424
+
425
+ });
426
+
427
+
428
+ describe("getTagMapValue", () => {
429
+ it("should return an empty object when no object is provided", () => {
430
+ const result = getTagMapValue();
431
+ expect(result).toEqual({});
432
+ });
433
+
434
+ it("should return the tag map value when an object is provided", () => {
435
+ const object = {
436
+ "key 1": {
437
+ name: "23",
438
+ subtags: {
439
+ name: "233",
440
+ },
441
+ },
442
+ };
443
+ const result = getTagMapValue(object);
444
+ expect(result).toEqual({ name: "233" });
445
+ });
424
446
  });
@@ -51,7 +51,7 @@ export const expectedStateGetLiquidTagsRequest = {
51
51
  messages: [],
52
52
  metaEntities: {
53
53
  layouts: undefined,
54
- tagLookupMap: { undefined: "32" },
54
+ tagLookupMap: { undefined: {definition: {}} },
55
55
  tags: { standard: { random: "32" } }
56
56
  },
57
57
  orgID: "",
@@ -7,6 +7,7 @@ import * as types from './constants';
7
7
  import initialState from '../../initialState';
8
8
  import { FAILURE } from '../App/constants';
9
9
  import { TAG } from '../Whatsapp/constants';
10
+ import { getTagMapValue } from '../../utils/tagValidations';
10
11
 
11
12
  function capReducer(state = fromJS(initialState.cap), action) {
12
13
  switch (action.type) {
@@ -96,14 +97,34 @@ function capReducer(state = fromJS(initialState.cap), action) {
96
97
  return state
97
98
  .set('fetchingLiquidTags', false)
98
99
  case types.GET_SCHEMA_FOR_ENTITY_SUCCESS: {
99
- const stateMeta = state.get('metaEntities');
100
- const standardTagMap = _.keyBy(action?.data?.metaEntities?.standard, item => item?.definition?.value);
100
+ //Process standard tags
101
+ const standardTagMapInitial = _.keyBy(
102
+ action?.data?.metaEntities?.standard,
103
+ item => item?.definition?.value
104
+ );
105
+ // Mapping only the `definition` object instead of the entire item, to reduce space used
106
+ const standardTagMap = _.mapValues(standardTagMapInitial, item => ({
107
+ definition: item?.definition ?? {},
108
+ }));
109
+
110
+ // Process custom tags
111
+ const customSubtags = getTagMapValue(action?.data?.metaEntities?.custom)
112
+ // Process extended tags
113
+ const extendedSubtags = getTagMapValue(action?.data?.metaEntities?.extended);
114
+
115
+ // Combine all maps
116
+ const combinedTagMap = {
117
+ ...standardTagMap,
118
+ ...customSubtags,
119
+ ...extendedSubtags
120
+ };
121
+ const stateMeta = state.get("metaEntities");
101
122
  return state
102
123
  .set('fetchingSchema', false)
103
124
  .set('metaEntities', {
104
125
  layouts: action.data && action.entityType === 'LAYOUT' ? action.data.metaEntities : stateMeta.layouts,
105
126
  tags: action.data && action.entityType === 'TAG' ? action.data.metaEntities : stateMeta.tags,
106
- tagLookupMap: action?.data && action?.entityType === TAG ? standardTagMap : stateMeta?.tagLookupMap,
127
+ tagLookupMap: action?.data && action?.entityType === TAG ? combinedTagMap : stateMeta?.tagLookupMap,
107
128
  })
108
129
  .set('fetchingSchemaError', false);
109
130
  }
@@ -22,7 +22,7 @@ import {
22
22
  CapTooltip,
23
23
  } from '@capillarytech/cap-ui-library';
24
24
  import { FONT_SIZE_L } from '@capillarytech/cap-ui-library/styled/variables';
25
- import { find, cloneDeep, findIndex, isEmpty, isEqual, filter, flattenDeep, replace } from 'lodash';
25
+ import _, { find, cloneDeep, findIndex, isEmpty, isEqual, filter, flattenDeep, replace } from 'lodash';
26
26
  import * as actions from './actions';
27
27
  import { makeSelectFTP, makeSelectMetaEntities } from './selectors';
28
28
  import { makeSelectLoyaltyPromotionDisplay, setInjectedTags } from '../Cap/selectors';
@@ -22,3 +22,4 @@ export const GET_IOS_CTAS = 'app/v2Containers/PushMessage/Create/GET_IOS_CTAS';
22
22
  export const GET_IOS_CTAS_SUCCESS = 'app/v2Containers/PushMessage/Create/GET_IOS_CTAS_SUCCESS';
23
23
  export const GET_IOS_CTAS_FAILURE = 'app/v2Containers/PushMessage/Create/GET_IOS_CTAS_FAILURE';
24
24
  export const RESET_STORE = 'app/v2Containers/PushMessage/Create/RESET_STORE';
25
+ export const EXTERNAL_LINK_LOWERCASE = 'external link';
@@ -36,6 +36,7 @@ import injectReducer from '../../../utils/injectReducer';
36
36
  import injectSaga from '../../../utils/injectSaga';
37
37
  import v2MobilePushCreateReducer from './reducer';
38
38
  import { v2MobilePushWatchDuplicateTemplateSaga } from './sagas';
39
+ import { EXTERNAL_LINK_LOWERCASE } from './constants';
39
40
 
40
41
  const PrefixWrapper = styled.div`
41
42
  margin-right: 16px;
@@ -200,11 +201,25 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
200
201
  newFormData[0]["add-sec-cta-2"] = false;
201
202
  }
202
203
  }
203
- this.setState({formData: newFormData, tabCount, isSchemaChanged: !this.state.isSchemaChanged}, () => {
204
- if (isFullMode && showTemplateName) {
205
- showTemplateName({formData: this.state.formData, onFormDataChange: this.onFormDataChange});
204
+ const compareValue =
205
+ newFormData?.[this.state?.currentTab - 1]?.[inputField?.id] || "";
206
+ this.setState(
207
+ {
208
+ formData: newFormData,
209
+ tabCount,
210
+ isSchemaChanged:
211
+ compareValue.toLowerCase() === EXTERNAL_LINK_LOWERCASE ||
212
+ !this.state?.isSchemaChanged,
213
+ },
214
+ () => {
215
+ if (isFullMode && showTemplateName) {
216
+ showTemplateName({
217
+ formData: this.state?.formData,
218
+ onFormDataChange: this.onFormDataChange,
219
+ });
220
+ }
206
221
  }
207
- });
222
+ );
208
223
  };
209
224
 
210
225
  onTagSelect = (data, currentTab, srcComp) => {