@capillarytech/creatives-library 8.0.68-alpha.2 → 8.0.68-alpha.3

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.68-alpha.2",
4
+ "version": "8.0.68-alpha.3",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -1,92 +1,90 @@
1
1
  export const expectedStateGetLiquidTagsRequest = {
2
- fetchingLiquidTags: true,
3
- fetchingSchema: true,
4
- fetchingSchemaError: "",
5
- liquidTags: [],
6
- messages: [],
7
- metaEntities: {
8
- layouts: [],
9
- tagLookupMap: {},
10
- tags: [],
11
- },
12
- orgID: "",
13
- token: "",
14
- };
15
-
16
- export const expectedStateGetLiquidTagsFailure = {
17
- fetchingLiquidTags: false,
18
- fetchingSchema: true,
19
- fetchingSchemaError: "",
20
- liquidTags: [],
21
- messages: [],
22
- metaEntities: {
23
- layouts: [],
24
- tagLookupMap: {},
25
- tags: [],
26
- },
27
- orgID: "",
28
- token: "",
29
- };
30
-
31
- export const expectedStateGetLiquidTagsSuccess = {
32
- fetchingLiquidTags: false,
33
- fetchingSchema: true,
34
- fetchingSchemaError: "",
35
- liquidTags: [],
36
- messages: [],
37
- metaEntities: {
38
- layouts: [],
39
- tagLookupMap: {},
40
- tags: [],
41
- },
42
- orgID: "",
43
- token: "",
44
- };
45
-
46
- export const expectedStateGetSchemaForEntitySuccessTAG = {
47
- fetchingLiquidTags: false,
48
- fetchingSchema: false,
49
- fetchingSchemaError: false,
50
- liquidTags: [],
51
- messages: [],
52
- metaEntities: {
53
- layouts: undefined,
54
- tagLookupMap: { undefined: { definition: {} } },
55
- tags: { standard: { random: "32" } },
56
- },
57
- orgID: "",
58
- token: "",
59
- };
60
-
61
- export const expectedStateGetSchemaForEntitySuccess = {
62
- fetchingLiquidTags: false,
63
- fetchingSchema: false,
64
- fetchingSchemaError: false,
65
- liquidTags: [],
66
- messages: [],
67
- metaEntities: {
68
- layouts: undefined,
69
- tagLookupMap: undefined,
70
- tags: undefined,
71
- },
72
- orgID: "",
73
- token: "",
74
- };
75
-
76
- export const expectedForwardedTags = {
77
- fetchingLiquidTags: false,
78
- fetchingSchema: false,
79
- fetchingSchemaError: '',
80
- injectedTags: undefined,
81
- liquidTags: [],
82
- messages: [],
83
- metaEntities: {
84
- layouts: [],
85
- tagLookupMap: {
2
+ fetchingLiquidTags: true,
3
+ fetchingSchema: true,
4
+ fetchingSchemaError: "",
5
+ liquidTags: [],
6
+ messages: [],
7
+ metaEntities: {
8
+ layouts: [],
9
+ tagLookupMap: {},
10
+ tags: []
11
+ },
12
+ orgID: "",
13
+ token: ""
14
+ };
15
+
16
+ export const expectedStateGetLiquidTagsFailure = {
17
+ fetchingLiquidTags: false,
18
+ fetchingSchema: true,
19
+ fetchingSchemaError: "",
20
+ liquidTags: [],
21
+ messages: [],
22
+ metaEntities: {
23
+ layouts: [],
24
+ tagLookupMap: {},
25
+ tags: []
26
+ },
27
+ orgID: "",
28
+ token: ""
29
+ };
30
+
31
+ export const expectedStateGetLiquidTagsSuccess = {
32
+ fetchingLiquidTags: false,
33
+ fetchingSchema: true,
34
+ fetchingSchemaError: "",
35
+ liquidTags: [],
36
+ messages: [],
37
+ metaEntities: {
38
+ layouts: [],
39
+ tagLookupMap: {},
40
+ tags: []
41
+ },
42
+ orgID: "",
43
+ token: ""
44
+ };
45
+
46
+ export const expectedStateGetSchemaForEntitySuccessTAG = {
47
+ fetchingLiquidTags: false,
48
+ fetchingSchema: false,
49
+ fetchingSchemaError: false,
50
+ liquidTags: [],
51
+ messages: [],
52
+ metaEntities: {
53
+ layouts: undefined,
54
+ tagLookupMap: { undefined: {definition: {}} },
55
+ tags: { standard: { random: "32" } }
56
+ },
57
+ orgID: "",
58
+ token: ""
59
+ };
60
+
61
+ export const expectedStateGetSchemaForEntitySuccess = {
62
+ fetchingLiquidTags: false,
63
+ fetchingSchema: false,
64
+ fetchingSchemaError: false,
65
+ liquidTags: [],
66
+ messages: [],
67
+ metaEntities: {
68
+ layouts: undefined,
69
+ tagLookupMap: undefined,
70
+ tags: undefined
71
+ },
72
+ orgID: "",
73
+ token: ""
74
+ };
86
75
 
76
+ export const expectedForwardedTags = {
77
+ fetchingLiquidTags: false,
78
+ fetchingSchema: true,
79
+ fetchingSchemaError: '',
80
+ injectedTags: undefined,
81
+ liquidTags: [],
82
+ messages: [],
83
+ metaEntities: {
84
+ layouts: [],
85
+ tagLookupMap: {},
86
+ tags: []
87
87
  },
88
- tags: [],
89
- },
90
- orgID: "",
91
- token: "",
92
- };
88
+ orgID: "",
89
+ token: ""
90
+ };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Created by vivek on 22/5/17.
3
3
  */
4
- import { fromJS, Map as ImmutableMap } from 'immutable';
4
+ import { fromJS } from 'immutable';
5
5
  import _ from 'lodash';
6
6
  import * as types from './constants';
7
7
  import initialState from '../../initialState';
@@ -113,28 +113,20 @@ function capReducer(state = fromJS(initialState.cap), action) {
113
113
  // Process extended tags
114
114
  const extendedSubtags = getTagMapValue(action?.data?.metaEntities?.extended);
115
115
 
116
- const getExistingTagLookupMap = (state) => {
117
- if (!state || !state.get) return {};
118
- const tagLookupMap = state.getIn(['metaEntities', 'tagLookupMap']);
119
- return state.get('metaEntities') && ImmutableMap.isMap(tagLookupMap)
120
- ? tagLookupMap.toJS()
121
- : {};
122
- };
123
-
124
116
  // Combine all maps
125
117
  const combinedTagMap = {
126
118
  ...standardTagMap,
127
119
  ...customSubtags,
128
120
  ...extendedSubtags,
129
- ...getExistingTagLookupMap(state),
121
+ ...state.getIn(['metaEntities', 'tagLookupMap'])?.toJS(),
130
122
  };
131
123
  const stateMeta = state.get("metaEntities");
132
124
  return state
133
125
  .set('fetchingSchema', false)
134
126
  .set('fetchingLiquidTags', false)
135
127
  .set('metaEntities', {
136
- layouts: action.data && action.entityType === 'LAYOUT' ? action.data.metaEntities : stateMeta?.layouts,
137
- tags: action.data && action.entityType === 'TAG' ? action.data.metaEntities : stateMeta?.tags,
128
+ layouts: action.data && action.entityType === 'LAYOUT' ? action.data.metaEntities : stateMeta.layouts,
129
+ tags: action.data && action.entityType === 'TAG' ? action.data.metaEntities : stateMeta.tags,
138
130
  tagLookupMap: action?.data && action?.entityType === TAG ? combinedTagMap : stateMeta?.tagLookupMap,
139
131
  })
140
132
  .set('fetchingSchemaError', false);
@@ -1,16 +1,16 @@
1
- import { fromJS, Map as ImmutableMap } from 'immutable';
1
+ import { fromJS } from 'immutable';
2
2
  import {
3
- GET_SUPPORT_VIDEOS_CONFIG_REQUEST,
4
- GET_SUPPORT_VIDEOS_CONFIG_SUCCESS,
5
- GET_SUPPORT_VIDEOS_CONFIG_FAILURE,
6
- REQUEST,
7
- SUCCESS,
8
- FAILURE,
9
- GET_LIQUID_TAGS_SUCCESS,
10
- GET_LIQUID_TAGS_FAILURE,
11
- GET_LIQUID_TAGS_REQUEST,
12
- GET_SCHEMA_FOR_ENTITY_SUCCESS,
13
- SET_INJECTED_TAGS,
3
+ GET_SUPPORT_VIDEOS_CONFIG_REQUEST,
4
+ GET_SUPPORT_VIDEOS_CONFIG_SUCCESS,
5
+ GET_SUPPORT_VIDEOS_CONFIG_FAILURE,
6
+ REQUEST,
7
+ SUCCESS,
8
+ FAILURE,
9
+ GET_LIQUID_TAGS_SUCCESS,
10
+ GET_LIQUID_TAGS_FAILURE,
11
+ GET_LIQUID_TAGS_REQUEST,
12
+ GET_SCHEMA_FOR_ENTITY_SUCCESS,
13
+ SET_INJECTED_TAGS,
14
14
  } from '../constants';
15
15
  import reducer from '../reducer';
16
16
  import initialState from '../../../initialState';
@@ -20,13 +20,12 @@ import {
20
20
  expectedStateGetLiquidTagsSuccess,
21
21
  expectedStateGetSchemaForEntitySuccessTAG,
22
22
  expectedStateGetSchemaForEntitySuccess,
23
+ expectedForwardedTags
23
24
  } from '../mockData';
24
- import { TAG } from '../../Whatsapp/constants';
25
- import { loadItem } from '../../../services/localStorageApi';
26
25
 
26
+ const mockedInitialState = fromJS(initialState.cap);
27
27
 
28
28
  describe('should handle GET_SUPPORT_VIDEOS_CONFIG', () => {
29
- const mockedInitialState = fromJS(initialState.cap);
30
29
  it('should handle GET_SUPPORT_VIDEOS_CONFIG_REQUEST', () => {
31
30
  const action = {
32
31
  type: GET_SUPPORT_VIDEOS_CONFIG_REQUEST,
@@ -43,7 +42,7 @@ describe('should handle GET_SUPPORT_VIDEOS_CONFIG', () => {
43
42
  is_active: true,
44
43
  _id: "12345",
45
44
  json_config: [
46
- { data: 'Test data' },
45
+ { data: 'Test data' },
47
46
  ],
48
47
  };
49
48
  const action = {
@@ -94,8 +93,8 @@ describe('should handle GET_SUPPORT_VIDEOS_CONFIG', () => {
94
93
  it('handles the GET_SCHEMA_FOR_ENTITY_SUCCESS action with action type as TAG', () => {
95
94
  const action = {
96
95
  type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
97
- data: { metaEntities: { standard: { random: "32" } } },
98
- entityType: "TAG",
96
+ data: {metaEntities:{standard:{"random": "32"}}},
97
+ entityType: "TAG"
99
98
  };
100
99
 
101
100
  expect(reducer(mockedInitialState, action).toJS()).toEqual(expectedStateGetSchemaForEntitySuccessTAG);
@@ -104,7 +103,7 @@ describe('should handle GET_SUPPORT_VIDEOS_CONFIG', () => {
104
103
  it('handles the GET_SCHEMA_FOR_ENTITY_SUCCESS action', () => {
105
104
  const action = {
106
105
  type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
107
- data: { metaEntities: { standard: { random: "32" } } },
106
+ data: {metaEntities:{standard:{"random": "32"}}},
108
107
  };
109
108
 
110
109
  expect(reducer(mockedInitialState, action).toJS()).toEqual(expectedStateGetSchemaForEntitySuccess);
@@ -114,108 +113,7 @@ describe('should handle GET_SUPPORT_VIDEOS_CONFIG', () => {
114
113
  type: SET_INJECTED_TAGS,
115
114
  data: {},
116
115
  };
117
-
116
+
118
117
  expect(reducer(mockedInitialState, action).toJS())?.fetchingSchema?.toEqual(true);
119
118
  });
120
119
  });
121
-
122
- describe('GET_SCHEMA_FOR_ENTITY_SUCCESS handler', () => {
123
- it('should handle existing tagLookupMap correctly when metaEntities and tagLookupMap exist', () => {
124
- const initialStateTest = fromJS({
125
- token: loadItem('token') || '',
126
- orgID: loadItem('orgID') || '',
127
- messages: [],
128
- metaEntities: {
129
- tags: [{ id: 1, name: 'tag1' }],
130
- layouts: ['layout1', 'layout2'],
131
- tagLookupMap: {
132
- existingTag: { definition: { value: 'existing' } },
133
- anotherTag: { definition: { value: 'another' } },
134
- },
135
- standard: [],
136
- },
137
- liquidTags: [],
138
- fetchingLiquidTags: false,
139
- fetchingSchema: false,
140
- fetchingSchemaError: '',
141
- });
142
-
143
- let action = {
144
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
145
- entityType: TAG,
146
- data: {
147
- metaEntities: {
148
- standard: [],
149
- custom: [],
150
- extended: [],
151
- },
152
- },
153
- };
154
-
155
- let newState = reducer(initialStateTest, action);
156
- let metaEntities = newState.get('metaEntities');
157
-
158
- expect(metaEntities).toEqual(expect.objectContaining({
159
- tagLookupMap: expect.objectContaining({
160
- existingTag: expect.objectContaining({
161
- definition: expect.objectContaining({
162
- value: 'existing',
163
- }),
164
- }),
165
- }),
166
- }));
167
-
168
- action = {
169
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
170
- entityType: 'LAYOUT',
171
- data: {
172
- metaEntities: {
173
- layouts: ['layout1', 'layout2'],
174
- standard: [],
175
- },
176
- },
177
- };
178
- newState = reducer(initialStateTest, action);
179
- metaEntities = newState.get('metaEntities');
180
- expect(metaEntities).toEqual(expect.objectContaining({
181
- layouts: expect.objectContaining({
182
- layouts: expect.arrayContaining(['layout1', 'layout2']),
183
- }),
184
- }));
185
- });
186
-
187
- it('should handle non-existent tagLookupMap by returning empty object', () => {
188
- const initialStateTest = fromJS({
189
- token: loadItem('token') || '',
190
- orgID: loadItem('orgID') || '',
191
- messages: [],
192
- metaEntities: {
193
- tagLookupMap: {},
194
- },
195
- liquidTags: [],
196
- fetchingLiquidTags: false,
197
- fetchingSchema: false,
198
- fetchingSchemaError: '',
199
- });
200
-
201
- const action = {
202
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
203
- entityType: TAG,
204
- data: {
205
- metaEntities: {
206
- standard: [],
207
- custom: [],
208
- extended: [],
209
- },
210
- },
211
- };
212
-
213
- const newState = reducer(initialStateTest, action);
214
- const metaEntities = newState.get('metaEntities');
215
-
216
- // Updated assertions to handle plain object
217
- expect(metaEntities).toBeDefined();
218
- expect(metaEntities.tagLookupMap).toBeDefined();
219
- expect(metaEntities.tagLookupMap).toEqual({});
220
- });
221
- });
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import Bugsnag from "@bugsnag/js";
3
4
  import {
4
5
  CapSlideBox,
5
6
  CapHeader,
@@ -139,21 +140,13 @@ export class Creatives extends React.Component {
139
140
  templateData.updatedByName = commonUtil.getUserNameById(userId, usersList);
140
141
  this.setState({ slidBoxContent: constants.PREVIEW, templateData });
141
142
  } else {
142
- const {
143
- name = "",
144
- sourceAccountIdentifier = "",
145
- configs: { token = "" } = {},
146
- } = get(this.props, "Templates.selectedZaloAccount", {});
147
- const { hostName = '' } = get(this.props, "Templates.senderDetails", {});
148
- this.props.zaloActions.getTemplateInfoById({
149
- username: name,
150
- oa_id: sourceAccountIdentifier,
151
- token,
152
- host: hostName,
153
- id: template?._id,
154
- preview: true,
155
- actionCallback: this.actionCallback,
156
- });
143
+ if (template?.versions?.base?.content?.zalo?.previewUrl) {
144
+ commonUtil.handlePreviewInNewTab(
145
+ template.versions.base.content.zalo.previewUrl
146
+ );
147
+ } else {
148
+ Bugsnag.leaveBreadcrumb("Zalo preview url not found");
149
+ }
157
150
  }
158
151
  };
159
152
 
@@ -12,6 +12,7 @@ import styled from 'styled-components';
12
12
  import {injectIntl, intlShape, FormattedMessage } from 'react-intl';
13
13
  import { createStructuredSelector } from 'reselect';
14
14
  import moment from "moment";
15
+ import Bugsnag from "@bugsnag/js";
15
16
  import get from 'lodash/get';
16
17
  import isEmpty from 'lodash/isEmpty';
17
18
  import isEqual from 'lodash/isEqual';
@@ -533,8 +534,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
533
534
  params.accountId = Number(query.account_id);
534
535
  this.getAllTemplates({params});
535
536
  }
536
- }
537
-
537
+ }
538
+
538
539
 
539
540
  if (selectedChannel === "ebill" && nextProps.CreateEbill && nextProps.CreateEbill.createResponse && nextProps.CreateEbill.createResponse.templateId && nextProps.CreateEbill.createResponse.templateId !== '') {
540
541
  const message = `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`;
@@ -920,7 +921,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
920
921
  }
921
922
  if (
922
923
  this.state.channel.toLowerCase() === ZALO_LOWERCASE &&
923
- !isEmpty(this.props.Templates?.selectedZaloAccount) &&
924
+ !isEmpty(this.props.Templates?.selectedZaloAccount) &&
924
925
  !params?.isAccountSelection && !isEmpty(this.props.Templates?.selectedZaloAccount?.hostName)
925
926
  ) {
926
927
  const {
@@ -982,7 +983,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
982
983
  default:
983
984
  return selectedWhatsappCategory === category;
984
985
  }
985
- }
986
+ }
986
987
  return true;
987
988
  }
988
989
  filterWhatsappTemplates = (templates) => {
@@ -1220,7 +1221,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1220
1221
  break;
1221
1222
  }
1222
1223
  case MOBILE_PUSH:
1223
- case INAPP:
1224
+ case INAPP:
1224
1225
  templateData.content = template;
1225
1226
  break;
1226
1227
  case WECHAT:
@@ -2189,21 +2190,13 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2189
2190
  this.setState({ previewTemplate: templateInfo });
2190
2191
  }
2191
2192
  } else {
2192
- const {
2193
- name = "",
2194
- sourceAccountIdentifier = "",
2195
- configs: { token = "" } = {},
2196
- hostName = "",
2197
- } = get(this.props, "Templates.selectedZaloAccount", {});
2198
- this.props.zaloActions.getTemplateInfoById({
2199
- username: name,
2200
- oa_id: sourceAccountIdentifier,
2201
- token: token,
2202
- host: hostName || this.state.hostName || this.props.Templates?.senderDetails?.hostName,
2203
- id: template?._id,
2204
- preview: true,
2205
- actionCallback: this.actionCallback,
2206
- });
2193
+ if (template?.versions?.base?.content?.zalo?.previewUrl) {
2194
+ handlePreviewInNewTab(
2195
+ template.versions.base.content.zalo.previewUrl
2196
+ );
2197
+ } else {
2198
+ Bugsnag.leaveBreadcrumb("Zalo preview url not found");
2199
+ }
2207
2200
  }
2208
2201
  }
2209
2202