@capillarytech/creatives-library 7.17.20 → 7.17.21-alpha.0

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.20",
4
+ "version": "7.17.21-alpha.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/utils/common.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  CARD_RELATED_TAGS,
7
7
  CARD_BASED_SCOPE,
8
8
  } from '../containers/App/constants';
9
+ import { apiMessageFormatHandler } from './commonUtils';
9
10
 
10
11
  export function getUserNameById(userId, allUserList) {
11
12
  let userName = "";
@@ -262,3 +263,61 @@ export const isTraiDLTEnable = (isFullMode, smsRegister) => {
262
263
  const isTraiDltFeature = isTraiDltFeatureForOrg && isTraiEnableforLib;
263
264
  return isTraiDltFeature;
264
265
  };
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,6 @@
1
+ import React from 'react';
2
+ import { FormattedMessage } from 'react-intl';
3
+
4
+ export const apiMessageFormatHandler = (id, fallback) => (
5
+ <FormattedMessage id={id} defaultMessage={fallback} />
6
+ );
@@ -43,6 +43,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
43
43
  dynamicDateValue: '',
44
44
  showModal: false,
45
45
  translationLang: '',
46
+ tagsList: []
46
47
  };
47
48
  this.renderTags = this.renderTags.bind(this);
48
49
  this.getSearchedExpandedKeys = this.getSearchedExpandedKeys.bind(this);
@@ -63,6 +64,15 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
63
64
  });
64
65
  }
65
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
+
66
76
  onChange = (e) => {
67
77
  const value = e.target.value;
68
78
  let expandedKeys = this.getSearchedExpandedKeys(this.props.tags, value);
@@ -254,7 +264,8 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
254
264
  autoExpandParent={autoExpandParent}
255
265
  onExpand={this.onExpand}
256
266
  >
257
- {this.renderTags(tg, searchValue)}
267
+ {/* {this.renderTags(tg, searchValue)} */}
268
+ {this.state.tagsList}
258
269
  </CapTree>
259
270
  {translationLang === "ja-JP" &&
260
271
  <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';
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';
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';
21
21
  export const CLEAR_META_ENTITIES = 'cap/CLEAR_META_ENTITIES';
22
22
  export const HIDE_TAGS = 'cap/HIDE_TAGS';
23
23
 
@@ -17,7 +17,9 @@ 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.set('localeLoading', true);
20
+ return state
21
+ .set('localeLoading', true)
22
+ .set('locale', action.locale);
21
23
  case types.GET_LOCIZ_MESSAGE_SUCCESS:
22
24
  return state
23
25
  .set('localeLoading', false)
@@ -3,6 +3,7 @@ import { fromJS } from 'immutable';
3
3
  import languageProviderReducer from '../reducer';
4
4
  import {
5
5
  CHANGE_LOCALE,
6
+ GET_LOCIZ_MESSAGE_REQUEST,
6
7
  } from '../constants';
7
8
 
8
9
  describe('languageProviderReducer', () => {
@@ -21,4 +22,12 @@ describe('languageProviderReducer', () => {
21
22
  messages: {},
22
23
  });
23
24
  });
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
+ });
24
33
  });
@@ -23058,7 +23058,7 @@ new message content.",
23058
23058
  </div>
23059
23059
  </ComponentWithLabelHOC__CapComponentStyled>
23060
23060
  </_class>
23061
- <Connect(UserIsAuthenticated(Connect(TagList)))
23061
+ <Connect(UserIsAuthenticated(Connect(InjectIntl(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(TagList))
23082
+ <UserIsAuthenticated(Connect(InjectIntl(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(TagList)))>
23128
+ </Connect(UserIsAuthenticated(Connect(InjectIntl(TagList))))>
23129
23129
  <CapDrawer
23130
23130
  content={
23131
23131
  <React.Fragment>