@capillarytech/creatives-library 7.17.19 → 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.19",
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);
@@ -53,16 +54,25 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
53
54
  componentDidMount() {
54
55
  const user = localStorage.getItem('user');
55
56
  let locale = 'en';
57
+ moment.locale(locale);
56
58
  if (user) {
57
59
  locale = JSON.parse(user).lang || locale;
58
60
  }
59
61
  locale = this.getTranslationMappedLocale(locale);
60
- moment.locale(locale);
61
62
  this.setState({
62
63
  translationLang: locale,
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">
@@ -3064,7 +3064,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3064
3064
  injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
3065
3065
  className={val.className ? val.className : ''}
3066
3066
  id={val.id}
3067
- userLocale={this.props.userLocale}
3067
+ userLocale={this.state.translationLang}
3068
3068
  selectedOfferDetails={this.props.selectedOfferDetails}
3069
3069
  channel={channel}
3070
3070
  />
@@ -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
 
@@ -36,7 +36,6 @@ import { FONT_COLOR_05 } from '@capillarytech/cap-ui-library/styled/variables';
36
36
  import { gtmPush } from '../../utils/gtmTrackers';
37
37
  const {CapCustomCardList} = CapCustomCard;
38
38
  import {transformEmailTemplates, storeS3FileSizeDetails, CREATIVES_S3_ASSET_FILESIZES} from '../../utils/cdnTransformation';
39
- import { GET_TRANSLATION_MAPPED } from '../../containers/TagList/constants';
40
39
 
41
40
  export class Email extends React.Component { // eslint-disable-line react/prefer-stateless-function
42
41
  constructor(props) {
@@ -81,7 +80,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
81
80
  addLanguageType: '',
82
81
  startValidation: false,
83
82
  saveForm: false,
84
- translationLang: 'en',
85
83
  };
86
84
 
87
85
  this.isTagLoaded = false;
@@ -206,10 +204,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
206
204
  // this.startTemplateCreation();
207
205
  // }, 15000);
208
206
  }
209
-
210
- getTranslationMappedLocale(locale) {
211
- return GET_TRANSLATION_MAPPED?.[locale];
212
- }
207
+
213
208
  componentDidMount() {
214
209
  const query = {
215
210
  layout: 'EMAIL',
@@ -221,16 +216,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
221
216
  if (this.props.location.query.type === 'embedded') {
222
217
  this.showNext();
223
218
  }
224
- const user = localStorage.getItem('user');
225
- let locale = 'en';
226
- if (user) {
227
- locale = JSON.parse(user)?.lang || locale;
228
- }
229
- locale = this.getTranslationMappedLocale(locale);
230
- moment.locale(locale);
231
- this.setState({
232
- translationLang: locale,
233
- });
234
219
  }
235
220
 
236
221
  checkBeeEditorAllowedForLibrary = () => {
@@ -2729,7 +2714,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2729
2714
  uuid={CmsSettings.uuid}
2730
2715
  type={CmsSettings.type}
2731
2716
  isEmailLoading={isLoading}
2732
- userLocale={this.state.translationLang}
2733
2717
  /> : ''}
2734
2718
  </Col>
2735
2719
  </Row>
@@ -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>