@capillarytech/creatives-library 7.17.208-alpha.0 → 7.17.208

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.208-alpha.0",
4
+ "version": "7.17.208",
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 (same as before)
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,4 +22,3 @@ 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';
@@ -32,7 +32,6 @@ import { CREATE, TRACK_CREATE_MPUSH } from '../../App/constants';
32
32
  import { MOBILE_PUSH } from '../../CreativesContainer/constants';
33
33
  import { getContent } from '../commonMethods';
34
34
  import { getCdnUrl } from '../../../utils/cdnTransformation';
35
- import { EXTERNAL_LINK_LOWERCASE } from './constants';
36
35
 
37
36
  const PrefixWrapper = styled.div`
38
37
  margin-right: 16px;
@@ -197,25 +196,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
197
196
  newFormData[0]["add-sec-cta-2"] = false;
198
197
  }
199
198
  }
200
- const compareValue =
201
- newFormData?.[this.state.currentTab - 1]?.[inputField?.id] || "";
202
- this.setState(
203
- {
204
- formData: newFormData,
205
- tabCount,
206
- isSchemaChanged:
207
- compareValue.toLowerCase() === EXTERNAL_LINK_LOWERCASE ||
208
- !this.state.isSchemaChanged,
209
- },
210
- () => {
211
- if (isFullMode && showTemplateName) {
212
- showTemplateName({
213
- formData: this.state.formData,
214
- onFormDataChange: this.onFormDataChange,
215
- });
216
- }
199
+ this.setState({formData: newFormData, tabCount, isSchemaChanged: !this.state.isSchemaChanged}, () => {
200
+ if (isFullMode && showTemplateName) {
201
+ showTemplateName({formData: this.state.formData, onFormDataChange: this.onFormDataChange});
217
202
  }
218
- );
203
+ });
219
204
  };
220
205
 
221
206
  onTagSelect = (data, currentTab, srcComp) => {