@capillarytech/creatives-library 7.17.21-alpha.1 → 7.17.21

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.
@@ -5,6 +5,7 @@ export const GET_SIDEBAR_FAILURE = 'app/App/GET_SIDEBAR_FAILURE';
5
5
  export const STORE2DOOR_PLUS_ENABLED = 'STORE2DOOR_PLUS_ENABLED';
6
6
  export const TRAI_DLT = 'TRAI_DLT';
7
7
  export const CARD_BASED_SCOPE = 'CARD_BASED_SCOPE';
8
+ export const HOSPITALITY_BASED_SCOPE = 'HOSPITALITY_BASED_SCOPE';
8
9
 
9
10
  export const CARD_RELATED_TAGS = [
10
11
  'card_series',
@@ -14,3 +15,25 @@ export const CARD_RELATED_TAGS = [
14
15
  'card_series_name',
15
16
  'card_name',
16
17
  ];
18
+
19
+ export const HOSPITALITY_RELATED_TAGS = [
20
+ "hospitality_series",
21
+ "tax_Code",
22
+ "roomTypeCode",
23
+ "bookingChannel",
24
+ "hotelReservationID_ResID_Type",
25
+ "lastModifyDateTime",
26
+ "guestCounts_IsPerRoom",
27
+ "ratePlan_RatePlanCode",
28
+ "resID_Value",
29
+ "numberOfUnits",
30
+ "rateTimeUnit",
31
+ "resStatus",
32
+ "timeSpan_End",
33
+ "roomStay_MarketCode",
34
+ "createDateTime",
35
+ "amount",
36
+ "timeSpan_Start",
37
+ "email",
38
+ "resID_Source",
39
+ ];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.17.21-alpha.1",
4
+ "version": "7.17.21",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/utils/common.js CHANGED
@@ -5,8 +5,9 @@ import {
5
5
  TRAI_DLT,
6
6
  CARD_RELATED_TAGS,
7
7
  CARD_BASED_SCOPE,
8
+ HOSPITALITY_RELATED_TAGS,
9
+ HOSPITALITY_BASED_SCOPE,
8
10
  } from '../containers/App/constants';
9
- import { apiMessageFormatHandler } from './commonUtils';
10
11
 
11
12
  export function getUserNameById(userId, allUserList) {
12
13
  let userName = "";
@@ -54,16 +55,28 @@ export const hasCardBasedScope = Auth.hasFeatureAccess.bind(
54
55
  CARD_BASED_SCOPE,
55
56
  );
56
57
 
58
+ export const hasHospitalityBasedScope = Auth.hasFeatureAccess.bind(
59
+ null,
60
+ HOSPITALITY_BASED_SCOPE,
61
+ );
62
+
63
+ //filtering tags based on scope
64
+ export const filterTags = (tagsToFilter, tagsList) => tagsList?.filter(
65
+ (tag) => !tagsToFilter?.includes(tag?.definition?.value)
66
+ );
67
+
57
68
  export function getTreeStructuredTags({tagsList, userLocale = 'en', offerDetails = [], disableTagsDetails = {}}) {
58
- console.log('populating tags', (tagsList || []).length);
59
69
  const mainTags = {};
60
70
  const { disableRelatedTags, childTagsToDisable, parentTagstoDisable} = disableTagsDetails;
61
71
 
62
72
  let clonedTags = tagsList;
63
73
  if (!hasCardBasedScope()) {
64
- clonedTags = _.filter(tagsList, (tag) =>
65
- !CARD_RELATED_TAGS.includes(tag?.definition?.value)
66
- );
74
+ //filtering CARD_RELATED_TAGS if org does not have CARD_BASED_SCOPE feature enabled
75
+ clonedTags = filterTags(CARD_RELATED_TAGS, tagsList);
76
+ }
77
+ if (!hasHospitalityBasedScope()) {
78
+ //filtering HOSPITALITY_RELATED_TAGS if org does not have HOSPITALITY_BASED_SCOPE feature enabled
79
+ clonedTags = filterTags(HOSPITALITY_RELATED_TAGS, tagsList);
67
80
  }
68
81
  _.forEach(clonedTags, (temp) => {
69
82
  const tag = temp.definition;
@@ -263,61 +276,3 @@ export const isTraiDLTEnable = (isFullMode, smsRegister) => {
263
276
  const isTraiDltFeature = isTraiDltFeatureForOrg && isTraiEnableforLib;
264
277
  return isTraiDltFeature;
265
278
  };
266
-
267
- export const intlKeyGenerator = (value = "") => {
268
- return value.replace(/[^a-zA-Z0-9_]/g, "");
269
- };
270
-
271
- export const handleInjectedData = (data, scope) => {
272
- let temp = _.cloneDeep(data);
273
- let tagType;
274
- for (const tagKey in temp) {
275
- if (temp.hasOwnProperty(tagKey)) {
276
- const tag = temp[tagKey];
277
-
278
- if (tag?.name === "Registration custom fields") {
279
- tagType = "CustomTagMessage";
280
- } else if (tag?.name === "Customer extended fields") {
281
- tagType = "ExtendedTagMessage";
282
- }
283
-
284
- if (tag?.name) {
285
- const name = tag?.name;
286
- const key = intlKeyGenerator(name);
287
- const id = tagType
288
- ? `${scope}.${key}_name.${tagType}`
289
- : `${scope}.${key}`;
290
-
291
- tag["name"] = apiMessageFormatHandler(id, name);
292
- }
293
-
294
- if (tag["subtags"]) {
295
- for (const subtagKey in tag["subtags"]) {
296
- if (tag["subtags"].hasOwnProperty(subtagKey)) {
297
- const subtag = tag["subtags"][subtagKey];
298
- if (subtag?.name) {
299
- const name = subtag?.name;
300
- const key = intlKeyGenerator(name);
301
- const id = tagType
302
- ? `${scope}.${key}_name.${tagType}`
303
- : `${scope}.${key}`;
304
-
305
- subtag["name"] = apiMessageFormatHandler(id, name);
306
- }
307
- if (subtag?.desc) {
308
- const desc = subtag?.desc;
309
- const key = intlKeyGenerator(desc);
310
- const id = tagType
311
- ? `${scope}.${key}_desc.${tagType}`
312
- : `${scope}.${key}`;
313
-
314
- subtag["desc"] = apiMessageFormatHandler(id, desc);
315
- }
316
- }
317
- }
318
- }
319
- tagType="";
320
- }
321
- }
322
- return temp;
323
- };
@@ -0,0 +1,125 @@
1
+ export const tagsList = [
2
+ {
3
+ _id: "6501b8b2ddd26e9da234b7c0",
4
+ type: "TAG",
5
+ definition: {
6
+ "resolutionDetails": {
7
+ resolver: "EI",
8
+ reference:
9
+ "select check_in_date.date as timeSpan_Start from read_api_2000014.behavioural_catalog_reservation a join read_api_2000014.date check_in_date on check_in_date.date_id=a.dim_timespan_start_id join read_api_2000014.date modified_date on modified_date.date_id=a.dim_latest_updated_date_id join read_api_2000014.date lastmodifydate on lastmodifydate.date_id=a.dim_lastmodifydatetime_id join read_api_2000014.date d ON a.dim_event_date_id = d.date_id join read_api_2000014.date booking_date ON a.dim_createdatetime_id = booking_date.date_id join read_api_2000014.date check_out_date ON a.dim_timespan_end_id = check_out_date.date_id join (select resid_value, max(date) as max_updated_date from read_api_2000014.behavioural_catalog_reservation a join read_api_2000014.date d on d.date_id=a.dim_latest_updated_date_id group by 1 ) b on a.resid_value=b.resid_value and b.max_updated_date=modified_date.date where resstatus='Reserved' and datediff(check_in_date.date, date(now()) )= 3",
10
+ type: "QUERY",
11
+ },
12
+ "subType": "EXTERNAL",
13
+ "label": {
14
+ "zh-cn": "",
15
+ "en": "Checkin date",
16
+ },
17
+ "value": "timeSpan_Start",
18
+ "subtags": [],
19
+ "tag-header": false,
20
+ "supportedModules": [
21
+ {
22
+ mandatory: false,
23
+ layout: "sms",
24
+ context: "default",
25
+ },
26
+ {
27
+ mandatory: false,
28
+ layout: "sms",
29
+ context: "outbound",
30
+ },
31
+ {
32
+ mandatory: false,
33
+ layout: "email",
34
+ context: "default",
35
+ },
36
+ {
37
+ mandatory: false,
38
+ layout: "email",
39
+ context: "outbound",
40
+ },
41
+ ],
42
+ },
43
+ scope: {
44
+ tag: "STANDARD",
45
+ orgId: -1,
46
+ verticals: [],
47
+ },
48
+ isActive: true,
49
+ createdBy: 50685535,
50
+ updatedBy: 50685535,
51
+ createdAt: "2023-09-13T13:27:14.653Z",
52
+ updatedAt: "2023-09-13T13:27:14.653Z",
53
+ },
54
+ {
55
+ _id: "5a291cdd85c3db29a2041e5a",
56
+ type: "TAG",
57
+ definition: {
58
+ "label": {
59
+ "en": "Optout",
60
+ "ja-JP": "撤回",
61
+ },
62
+ "value": "optout",
63
+ "subtags": [],
64
+ "tag-header": false,
65
+ "supportedModules": [
66
+ {
67
+ context: "journey",
68
+ layout: "sms",
69
+ mandatory: false,
70
+ },
71
+ {
72
+ context: "outbound",
73
+ layout: "sms",
74
+ mandatory: false,
75
+ },
76
+ {
77
+ context: "default",
78
+ layout: "sms",
79
+ mandatory: false,
80
+ },
81
+ {
82
+ context: "coupon_expiry",
83
+ layout: "sms",
84
+ mandatory: false,
85
+ },
86
+ {
87
+ context: "coupons",
88
+ layout: "sms",
89
+ mandatory: false,
90
+ },
91
+ ],
92
+ },
93
+ scope: {
94
+ tag: "STANDARD",
95
+ orgId: -1,
96
+ verticals: [],
97
+ },
98
+ isActive: true,
99
+ createdBy: 4,
100
+ updatedBy: 15000449,
101
+ createdAt: "2017-12-07T10:50:05.800Z",
102
+ updatedAt: "2018-01-22T11:43:05.611Z",
103
+ },
104
+ ];
105
+ export const tagsToFilter = ["timeSpan_Start"];
106
+
107
+ export const output1 = [
108
+ {
109
+ disabled: false,
110
+ title: "Optout",
111
+ value: "{{optout}}",
112
+ },
113
+ ];
114
+ export const output2 = [
115
+ {
116
+ disabled: false,
117
+ title: "Checkin date",
118
+ value: "{{timeSpan_Start}}",
119
+ },
120
+ {
121
+ disabled: false,
122
+ title: "Optout",
123
+ value: "{{optout}}",
124
+ },
125
+ ];
@@ -0,0 +1,18 @@
1
+ import "@testing-library/jest-dom";
2
+ import { filterTags, getTreeStructuredTags } from "../common";
3
+ import * as mockdata from "./common.mockdata";
4
+
5
+ describe("getTreeStructuredTags test", () => {
6
+ it("test for getTreeStructuredTags when tagsList is not empty", () => {
7
+ expect(getTreeStructuredTags({tagsList: mockdata.tagsList})).toEqual(mockdata.output1);
8
+ });
9
+ it("test for getTreeStructuredTags when tagsList is empty", () => {
10
+ expect(getTreeStructuredTags({tagsList: []})).toEqual([]);
11
+ });
12
+ it("test for filterTags", () => {
13
+ expect(filterTags(mockdata.tagsToFilter, mockdata.tagsList)).toEqual([mockdata.tagsList[1]]);
14
+ });
15
+ it("test for filterTags when tagsToFilter and tagsList is empty", () => {
16
+ expect(filterTags([], [])).toEqual([]);
17
+ });
18
+ });
@@ -0,0 +1,21 @@
1
+ import "@testing-library/jest-dom";
2
+ import { getTreeStructuredTags } from "../common";
3
+ import * as mockdata from "./common.mockdata";
4
+
5
+ jest.mock('@capillarytech/cap-ui-utils', () => ({
6
+ Auth: {
7
+ hasAccess: () => jest.fn(() => true),
8
+ hasFeatureAccess: () => jest.fn(() => true),
9
+ authHoc: jest.fn(),
10
+ initialize: jest.fn(),
11
+ },
12
+ }));
13
+
14
+ describe("common utils test", () => {
15
+ it("test for getTreeStructuredTags when tagsList is not empty", () => {
16
+ expect(getTreeStructuredTags({tagsList: mockdata.tagsList})).toEqual(mockdata.output2);
17
+ });
18
+ it("test for getTreeStructuredTags when tagsList is empty", () => {
19
+ expect(getTreeStructuredTags({tagsList: []})).toEqual([]);
20
+ });
21
+ });
@@ -7,6 +7,8 @@
7
7
  import PropTypes from 'prop-types';
8
8
  import React from 'react';
9
9
  import { connect } from 'react-redux';
10
+ import moment from 'moment';
11
+ import { FONT_COLOR_05 } from '@capillarytech/cap-ui-library/styled/variables';
10
12
  // import styled from 'styled-components';
11
13
  import { CapSpin, CapModal, CapButton, CapPopover, CapInput, CapTree, CapSelect, CapTooltip, CapLink, CapIcon } from '@capillarytech/cap-ui-library';
12
14
 
@@ -15,10 +17,9 @@ import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
15
17
  import { createStructuredSelector } from 'reselect';
16
18
  import messages from './messages';
17
19
  import { makeSelectLoyaltyPromotionDisplay } from '../../v2Containers/Cap/selectors';
18
- import { CARD_RELATED_TAGS } from '../../containers/App/constants';
19
- import { hasCardBasedScope } from '../../utils/common';
20
- import moment from 'moment';
21
- import { FONT_COLOR_05 } from '@capillarytech/cap-ui-library/styled/variables';
20
+ import { CARD_RELATED_TAGS, HOSPITALITY_RELATED_TAGS } from '../../containers/App/constants';
21
+ import { hasCardBasedScope, hasHospitalityBasedScope } from '../../utils/common';
22
+
22
23
  import {
23
24
  GET_TRANSLATION_MAPPED,
24
25
  JAPANESE_HELP_TEXT,
@@ -43,7 +44,6 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
43
44
  dynamicDateValue: '',
44
45
  showModal: false,
45
46
  translationLang: '',
46
- tagsList: []
47
47
  };
48
48
  this.renderTags = this.renderTags.bind(this);
49
49
  this.getSearchedExpandedKeys = this.getSearchedExpandedKeys.bind(this);
@@ -64,15 +64,6 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
64
64
  });
65
65
  }
66
66
 
67
- componentDidUpdate(prevProps, prevState){
68
- if (this.props.tags !== prevProps.tags || this.state.searchValue !== prevState.searchValue) {
69
- let temp = this.renderTags(this.props.tags, this.state.searchValue);
70
- this.setState({
71
- tagsList: temp
72
- });
73
- }
74
- }
75
-
76
67
  onChange = (e) => {
77
68
  const value = e.target.value;
78
69
  let expandedKeys = this.getSearchedExpandedKeys(this.props.tags, value);
@@ -181,6 +172,10 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
181
172
  if (!hasCardBasedScope()) {
182
173
  clonedTags = _.omit(clonedTags, CARD_RELATED_TAGS);
183
174
  }
175
+ if (!hasHospitalityBasedScope()) {
176
+ //filtering HOSPITALITY_RELATED_TAGS if org does not have HOSPITALITY_BASED_SCOPE feature enabled
177
+ clonedTags = _.omit(clonedTags, HOSPITALITY_RELATED_TAGS);
178
+ }
184
179
  _.forEach(clonedTags, (val = '', key) => {
185
180
  let supportedTagsString = '';
186
181
  _.forEach(val.supportedTags, (supportedTag) => {
@@ -264,8 +259,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
264
259
  autoExpandParent={autoExpandParent}
265
260
  onExpand={this.onExpand}
266
261
  >
267
- {/* {this.renderTags(tg, searchValue)} */}
268
- {this.state.tagsList}
262
+ {this.renderTags(tg, searchValue)}
269
263
  </CapTree>
270
264
  {translationLang === "ja-JP" &&
271
265
  <div className="tag-list-footer">
@@ -15,9 +15,9 @@ export const GET_USER_DATA_REQUEST = 'cap/GET_USER_DATA_REQUEST_V2';
15
15
  export const GET_USER_DATA_SUCCESS = 'cap/GET_USER_DATA_SUCCESS_V2';
16
16
  export const GET_USER_DATA_FAILURE = 'cap/GET_USER_DATA_FAILURE_V2';
17
17
 
18
- export const GET_SCHEMA_FOR_ENTITY_FAILURE = 'cap/GET_SCHEMA_FOR_ENTITY_FAILURE_V2';
19
- export const GET_SCHEMA_FOR_ENTITY_REQUEST = 'cap/GET_SCHEMA_FOR_ENTITY_REQUEST_V2';
20
- export const GET_SCHEMA_FOR_ENTITY_SUCCESS = 'cap/GET_SCHEMA_FOR_ENTITY_SUCCESS_V2';
18
+ export const GET_SCHEMA_FOR_ENTITY_FAILURE = 'cap/GET_SCHEMA_FOR_ENTITY_FAILURE';
19
+ export const GET_SCHEMA_FOR_ENTITY_REQUEST = 'cap/GET_SCHEMA_FOR_ENTITY_REQUEST';
20
+ export const GET_SCHEMA_FOR_ENTITY_SUCCESS = 'cap/GET_SCHEMA_FOR_ENTITY_SUCCESS';
21
21
  export const CLEAR_META_ENTITIES = 'cap/CLEAR_META_ENTITIES';
22
22
  export const HIDE_TAGS = 'cap/HIDE_TAGS';
23
23
 
@@ -17,9 +17,7 @@ const initialState = fromJS({
17
17
  function languageProviderReducer(state = initialState, action) {
18
18
  switch (action.type) {
19
19
  case types.GET_LOCIZ_MESSAGE_REQUEST:
20
- return state
21
- .set('localeLoading', true)
22
- .set('locale', action.locale);
20
+ return state.set('localeLoading', true);
23
21
  case types.GET_LOCIZ_MESSAGE_SUCCESS:
24
22
  return state
25
23
  .set('localeLoading', false)
@@ -3,7 +3,6 @@ import { fromJS } from 'immutable';
3
3
  import languageProviderReducer from '../reducer';
4
4
  import {
5
5
  CHANGE_LOCALE,
6
- GET_LOCIZ_MESSAGE_REQUEST,
7
6
  } from '../constants';
8
7
 
9
8
  describe('languageProviderReducer', () => {
@@ -22,12 +21,4 @@ describe('languageProviderReducer', () => {
22
21
  messages: {},
23
22
  });
24
23
  });
25
-
26
- it('make locize message request', () => {
27
- expect(languageProviderReducer(undefined, { type: GET_LOCIZ_MESSAGE_REQUEST, locale: 'de' }).toJS()).toEqual({
28
- locale: "de",
29
- localeLoading: true,
30
- messages: {},
31
- });
32
- });
33
24
  });
@@ -23058,7 +23058,7 @@ new message content.",
23058
23058
  </div>
23059
23059
  </ComponentWithLabelHOC__CapComponentStyled>
23060
23060
  </_class>
23061
- <Connect(UserIsAuthenticated(Connect(InjectIntl(TagList))))
23061
+ <Connect(UserIsAuthenticated(Connect(TagList)))
23062
23062
  id="undefined_tags"
23063
23063
  injectedTags={Object {}}
23064
23064
  key="undefined_tags"
@@ -23079,7 +23079,7 @@ new message content.",
23079
23079
  tags={Array []}
23080
23080
  userLocale="en-US"
23081
23081
  >
23082
- <UserIsAuthenticated(Connect(InjectIntl(TagList)))
23082
+ <UserIsAuthenticated(Connect(TagList))
23083
23083
  authData={
23084
23084
  Object {
23085
23085
  "app": Object {},
@@ -23125,7 +23125,7 @@ new message content.",
23125
23125
  tags={Array []}
23126
23126
  userLocale="en-US"
23127
23127
  />
23128
- </Connect(UserIsAuthenticated(Connect(InjectIntl(TagList))))>
23128
+ </Connect(UserIsAuthenticated(Connect(TagList)))>
23129
23129
  <CapDrawer
23130
23130
  content={
23131
23131
  <React.Fragment>