@capillarytech/creatives-library 7.17.13 → 7.17.14-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.
@@ -18,7 +18,7 @@ export const GET_TRANSLATION_MAPPED = {
18
18
  'ja-JP': 'ja-JP',
19
19
  };
20
20
 
21
- export const JAPANESE_HIDE_DATE_ARRAY = [
21
+ export const JAPANESE_HIDE_DATE_TAGS = [
22
22
  "mm/dd/yyyy",
23
23
  "dd/mm/yyyy",
24
24
  "mm/dd/yy",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.17.13",
4
+ "version": "7.17.14-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
+ if (value && typeof value === "string")
269
+ return value.replace(/[^a-zA-Z0-9_]/g, "");
270
+ return value.props.defaultMessage.replace(/[^a-zA-Z0-9_]/g, "");
271
+ };
272
+
273
+ export const handleInjectedData = (data, scope) => {
274
+ let tagType;
275
+ for (const tagKey in data) {
276
+ if (data.hasOwnProperty(tagKey)) {
277
+ const tag = data[tagKey];
278
+
279
+ if (tag?.name === "Registration custom fields") {
280
+ tagType = "CustomTagMessage";
281
+ } else if (tag?.name === "Customer extended fields") {
282
+ tagType = "ExtendedTagMessage";
283
+ }
284
+
285
+ if (tag?.name) {
286
+ const name = tag?.name;
287
+ const key = intlKeyGenerator(name);
288
+ const id = tagType
289
+ ? `${scope}.${key}_name.${tagType}`
290
+ : `${scope}.${key}`;
291
+
292
+ tag["name"] = apiMessageFormatHandler(id, name);
293
+ }
294
+
295
+ if (tag["subtags"]) {
296
+ for (const subtagKey in tag["subtags"]) {
297
+ if (tag["subtags"].hasOwnProperty(subtagKey)) {
298
+ const subtag = tag["subtags"][subtagKey];
299
+ if (subtag?.name) {
300
+ const name = subtag?.name;
301
+ const key = intlKeyGenerator(name);
302
+ const id = tagType
303
+ ? `${scope}.${key}_name.${tagType}`
304
+ : `${scope}.${key}`;
305
+
306
+ subtag["name"] = apiMessageFormatHandler(id, name);
307
+ }
308
+ if (subtag?.desc) {
309
+ const desc = subtag?.desc;
310
+ const key = intlKeyGenerator(desc);
311
+ const id = tagType
312
+ ? `${scope}.${key}_desc.${tagType}`
313
+ : `${scope}.${key}`;
314
+
315
+ subtag["desc"] = apiMessageFormatHandler(id, desc);
316
+ }
317
+ }
318
+ }
319
+ }
320
+ }
321
+ }
322
+ return data;
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
+ );
@@ -25,7 +25,7 @@ import {
25
25
  TAG_TRANSLATION_DOC,
26
26
  } from "../../containers/TagList/constants";
27
27
  import { HIDE_ENGAGEMENT_CHANNELS } from '../../v2Containers/App/constants';
28
- import { hideDateLocale } from '../../v2Containers/TagList/utils';
28
+ import { hidingDateTagsForJpLocale } from '../../v2Containers/TagList/utils';
29
29
 
30
30
 
31
31
  const {Search} = CapInput;
@@ -190,7 +190,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
190
190
  {temp}
191
191
  </CapTreeNode>
192
192
  );
193
- hideDateLocale(hideDateTagsForJpLocale, val, list, tagValue);
193
+ hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tagValue);
194
194
  } else if (searchString === '' || !searchString || ((val.name || '').toLowerCase().indexOf(searchString.toLowerCase()) !== -1)) {
195
195
  const childDisabled = disableRelatedTags ? childTagsToDisable.includes(key) : false;
196
196
  const tempNode = (
@@ -202,7 +202,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
202
202
  disabled={childDisabled}
203
203
  >
204
204
  </CapTreeNode>);
205
- hideDateLocale(hideDateTagsForJpLocale, val, list, tempNode);
205
+ hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tempNode);
206
206
  }
207
207
  });
208
208
  return list;
@@ -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
  });
@@ -79,7 +79,7 @@ export const LineText = ({
79
79
  const user = localStorage.getItem("user");
80
80
  let locale = "en";
81
81
  if (user) {
82
- locale = JSON.parse(user).lang || locale;
82
+ locale = JSON.parse(user)?.lang || locale;
83
83
  }
84
84
  locale = GET_TRANSLATION_MAPPED?.[locale];
85
85
  moment.locale(locale);
@@ -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>