@capillarytech/creatives-library 7.17.14-alpha.0 → 7.17.14

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.
@@ -17,14 +17,3 @@ export const GET_TRANSLATION_MAPPED = {
17
17
  'en-US': 'en-US',
18
18
  'ja-JP': 'ja-JP',
19
19
  };
20
-
21
- export const JAPANESE_HIDE_DATE_TAGS = [
22
- "mm/dd/yyyy",
23
- "dd/mm/yyyy",
24
- "mm/dd/yy",
25
- "dd Mon yyyy",
26
- "Day, Mon dd, yy",
27
- "dd.mm.yy",
28
- "dd Mon",
29
- "dd/m/yyyy",
30
- ];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.17.14-alpha.0",
4
+ "version": "7.17.14",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/utils/common.js CHANGED
@@ -6,7 +6,6 @@ import {
6
6
  CARD_RELATED_TAGS,
7
7
  CARD_BASED_SCOPE,
8
8
  } from '../containers/App/constants';
9
- import { apiMessageFormatHandler } from './commonUtils';
10
9
 
11
10
  export function getUserNameById(userId, allUserList) {
12
11
  let userName = "";
@@ -265,59 +264,9 @@ export const isTraiDLTEnable = (isFullMode, smsRegister) => {
265
264
  };
266
265
 
267
266
  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
- }
267
+ if (value && value.typeOf === "string") {
268
+ const key = value.replace(/[^a-zA-Z0-9_]/g, "");
269
+ return key;
321
270
  }
322
- return data;
323
- };
271
+ return value;
272
+ }
@@ -19,14 +19,7 @@ import { CARD_RELATED_TAGS } from '../../containers/App/constants';
19
19
  import { hasCardBasedScope } from '../../utils/common';
20
20
  import moment from 'moment';
21
21
  import { FONT_COLOR_05 } from '@capillarytech/cap-ui-library/styled/variables';
22
- import {
23
- GET_TRANSLATION_MAPPED,
24
- JAPANESE_HELP_TEXT,
25
- TAG_TRANSLATION_DOC,
26
- } from "../../containers/TagList/constants";
27
- import { HIDE_ENGAGEMENT_CHANNELS } from '../../v2Containers/App/constants';
28
- import { hidingDateTagsForJpLocale } from '../../v2Containers/TagList/utils';
29
-
22
+ import { GET_TRANSLATION_MAPPED, JAPANESE_HELP_TEXT, TAG_TRANSLATION_DOC } from '../../containers/TagList/constants';
30
23
 
31
24
  const {Search} = CapInput;
32
25
  const {CapTreeNode} = CapTree;
@@ -162,9 +155,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
162
155
  };
163
156
 
164
157
  renderTags(tags, searchString = '') {
165
- const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags } = this?.props?.disableTagsDetails;
166
- const { accessibleFeatures = [] } = this?.props?.currentOrgDetails || {};
167
- const hideDateTagsForJpLocale = accessibleFeatures.includes(HIDE_ENGAGEMENT_CHANNELS);
158
+ const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags} = this.props.disableTagsDetails;
168
159
  const list = [];
169
160
  const loyaltyAttrDisableText = <FormattedMessage {...messages.loyaltyAttributeDisable} />;
170
161
  let clonedTags = _.cloneDeep(tags);
@@ -180,7 +171,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
180
171
  if (_.has(val, 'subtags')) {
181
172
  const disabled = disableRelatedTags ? parentTagstoDisable.includes(key) : false;
182
173
  const temp = this.renderTags(val.subtags, '', disabled);
183
- const tagValue = (
174
+ list.push((
184
175
  <CapTreeNode
185
176
  title={disabled ? <CapTooltip title={loyaltyAttrDisableText}>{val.name}</CapTooltip> : val.name}
186
177
  tag={val}
@@ -189,8 +180,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
189
180
  >
190
181
  {temp}
191
182
  </CapTreeNode>
192
- );
193
- hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tagValue);
183
+ ));
194
184
  } else if (searchString === '' || !searchString || ((val.name || '').toLowerCase().indexOf(searchString.toLowerCase()) !== -1)) {
195
185
  const childDisabled = disableRelatedTags ? childTagsToDisable.includes(key) : false;
196
186
  const tempNode = (
@@ -202,7 +192,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
202
192
  disabled={childDisabled}
203
193
  >
204
194
  </CapTreeNode>);
205
- hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tempNode);
195
+ list.push(tempNode);
206
196
  }
207
197
  });
208
198
  return list;
@@ -253,7 +243,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
253
243
  expandedKeys={expandedKeys}
254
244
  autoExpandParent={autoExpandParent}
255
245
  onExpand={this.onExpand}
256
- >
246
+ >
257
247
  {this.renderTags(tg, searchValue)}
258
248
  </CapTree>
259
249
  {translationLang === "ja-JP" &&
@@ -261,7 +251,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
261
251
  <CapIcon
262
252
  type="help"
263
253
  size="s"
264
- />
254
+ />
265
255
  <CapLink>
266
256
  <CapButton id="translationtagfooter" type="flat" onClick={this.openTranslationLink} >
267
257
  <div className="tag-list-footer-icon">
@@ -274,8 +264,8 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
274
264
  </div>
275
265
  </CapButton>
276
266
  </CapLink>
277
- </div>
278
- }
267
+ </div>
268
+ }
279
269
 
280
270
  </CapSpin>
281
271
  </div>);
@@ -285,7 +275,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
285
275
  visible={this.props.visibleTaglist}
286
276
  footer={[]}
287
277
  {...modalProps}
288
- >
278
+ >
289
279
  {contentSection}
290
280
  </CapModal> :
291
281
  <CapPopover
@@ -330,7 +320,6 @@ CapTagList.propTypes = {
330
320
  hidePopover: PropTypes.bool,
331
321
  modalProps: PropTypes.any,
332
322
  disableTagsDetails: PropTypes.object,
333
- currentOrgDetails: PropTypes.object,
334
323
  };
335
324
 
336
325
  CapTagList.defaultValue = {
@@ -348,3 +337,4 @@ const mapStateToProps = createStructuredSelector({
348
337
 
349
338
 
350
339
  export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(CapTagList));
340
+
@@ -16,8 +16,6 @@ import style from './style';
16
16
  import withStyles from '../../../../hoc/withStyles';
17
17
  import globalMessages from '../../../Cap/messages';
18
18
  import { validateTags } from '../../../../utils/tagValidations';
19
- import moment from 'moment';
20
- import { GET_TRANSLATION_MAPPED } from '../../../../containers/TagList/constants';
21
19
 
22
20
  const { TextArea } = CapInput;
23
21
  const {CapCustomCardList} = CapCustomCard;
@@ -56,7 +54,6 @@ export const LineText = ({
56
54
  const [messageTitle, updateTextMessageTitle] = useState('');
57
55
  const [isDrawerRequired, updateDrawerRequirement] = useState(false);
58
56
  const [selectedTemplate, updateSelectedTemplate] = useState();
59
- const [translationLang, updateTranslationLang] = useState('en');
60
57
 
61
58
  useEffect(() => {
62
59
  const { messageTitle = '', messageContent = '', type, isInit } = content;
@@ -74,18 +71,6 @@ export const LineText = ({
74
71
  }
75
72
  }, [content]);
76
73
 
77
- //To Find from which locale user is loggedin
78
- useEffect(() => {
79
- const user = localStorage.getItem("user");
80
- let locale = "en";
81
- if (user) {
82
- locale = JSON.parse(user)?.lang || locale;
83
- }
84
- locale = GET_TRANSLATION_MAPPED?.[locale];
85
- moment.locale(locale);
86
- updateTranslationLang(locale);
87
- }, []);
88
-
89
74
  useEffect(() => {
90
75
  if (messageContent && (isFullMode ? messageTitle : true)) {
91
76
  updateMessageState({
@@ -275,7 +260,7 @@ export const LineText = ({
275
260
  injectedTags={injectedTags || {}}
276
261
  // className={val.className ? val.className : ''}
277
262
  id={`${id}_tags`}
278
- userLocale={translationLang}
263
+ userLocale={localStorage.getItem('jlocale') || 'en'}
279
264
  selectedOfferDetails={selectedOfferDetails}
280
265
  />
281
266
  </>
@@ -23077,7 +23077,7 @@ new message content.",
23077
23077
  onContextChange={[Function]}
23078
23078
  onTagSelect={[Function]}
23079
23079
  tags={Array []}
23080
- userLocale="en-US"
23080
+ userLocale="en"
23081
23081
  >
23082
23082
  <UserIsAuthenticated(Connect(InjectIntl(TagList)))
23083
23083
  authData={
@@ -23123,7 +23123,7 @@ new message content.",
23123
23123
  onTagSelect={[Function]}
23124
23124
  redirect={[Function]}
23125
23125
  tags={Array []}
23126
- userLocale="en-US"
23126
+ userLocale="en"
23127
23127
  />
23128
23128
  </Connect(UserIsAuthenticated(Connect(InjectIntl(TagList))))>
23129
23129
  <CapDrawer
@@ -19,11 +19,11 @@ import * as globalActions from '../Cap/actions';
19
19
  // import styled from styled-components;
20
20
  import CapTagList from '../../v2Components/CapTagList';
21
21
  import './_tagList.scss';
22
- import { selectCurrentOrgDetails } from '../Cap/selectors';
23
22
  const TreeNode = Tree.TreeNode;
24
23
  import { injectIntl } from 'react-intl';
24
+ import { apiMessageFormatHandler } from '../../utils/commonUtils';
25
25
  import { scope } from './messages';
26
- import { handleInjectedData } from '../../utils/common';
26
+ import { intlKeyGenerator } from '../../utils/common';
27
27
 
28
28
  export class TagList extends React.Component { // eslint-disable-line react/prefer-stateless-function
29
29
  constructor(props) {
@@ -184,14 +184,38 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
184
184
  allTags.coupon.subtags = couponTags;
185
185
  }
186
186
 
187
- transformInjectedTags(tags) {
187
+ transformInjectedTags(tags, tagType = "") {
188
188
  _.forEach(tags, (tag) => {
189
189
  const temp = tag;
190
190
  let subKey = '';
191
+ if (tag?.name === 'Registration custom fields') {
192
+ tagType = 'CustomTagMessage';
193
+ }
194
+ else if (tag?.name === 'Customer extended fields') {
195
+ tagType = 'ExtendedTagMessage';
196
+ }
191
197
  Object.keys(tag).map( (k) => {
192
198
  if (k.indexOf("subtags") !== -1) {
193
199
  subKey = k;
194
200
  }
201
+ if (k.indexOf("name") !== -1) {
202
+ const name = tag?.name;
203
+ const key = intlKeyGenerator(temp?.name);
204
+ const id = tagType.length > 0
205
+ ? `${scope}.${key}_name.${tagType}`
206
+ : `${scope}.${key}`;
207
+
208
+ temp["name"]=apiMessageFormatHandler(id, name);
209
+ }
210
+ if (k.indexOf("desc") !== -1) {
211
+ const desc = tag?.desc;
212
+ const key = intlKeyGenerator(temp?.desc);
213
+ const id = tagType.length > 0
214
+ ? `${scope}.${key}_desc.${tagType}`
215
+ : `${scope}.${key}`;
216
+
217
+ temp["desc"]=apiMessageFormatHandler(id, desc);
218
+ }
195
219
  return true;
196
220
  });
197
221
  if (subKey !== '') {
@@ -200,7 +224,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
200
224
  temp.subtags = _.cloneDeep(temp[subKey]);
201
225
  delete temp[subKey];
202
226
  }
203
- temp.subtags = this.transformInjectedTags(temp.subtags);
227
+ temp.subtags = this.transformInjectedTags(temp.subtags, tagType);
204
228
  }
205
229
  });
206
230
  return tags;
@@ -228,11 +252,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
228
252
  let tags = {};
229
253
  let injectedTags = {};
230
254
  if (this.props.injectedTags && !_.isEmpty(this.props.injectedTags)) {
231
- const formattedInjectedTags = handleInjectedData(
232
- this.props.injectedTags,
233
- scope
234
- );
235
- injectedTags = this.transformInjectedTags(formattedInjectedTags);
255
+ injectedTags = this.transformInjectedTags(this.props.injectedTags);
236
256
  }
237
257
  if (this.props.tags && this.props.tags.length > 0) {
238
258
  tags = this.populateTags(this.props.tags);
@@ -255,7 +275,6 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
255
275
  onContextChange={this.getTagsforContext}
256
276
  moduleFilterEnabled={this.props.moduleFilterEnabled}
257
277
  modalProps={this.props.modalProps}
258
- currentOrgDetails={this.props.currentOrgDetails}
259
278
  />
260
279
  </div>
261
280
  );
@@ -280,12 +299,10 @@ TagList.propTypes = {
280
299
  visibleTaglist: PropTypes.bool,
281
300
  hidePopover: PropTypes.bool,
282
301
  modalProps: PropTypes.any,
283
- currentOrgDetails: PropTypes.object,
284
302
  };
285
303
 
286
304
  const mapStateToProps = createStructuredSelector({
287
305
  TagList: makeSelectTagList(),
288
- currentOrgDetails: selectCurrentOrgDetails(),
289
306
  });
290
307
 
291
308
  function mapDispatchToProps(dispatch) {
@@ -88,16 +88,6 @@ export const TagListData = {
88
88
  },
89
89
  ],
90
90
  injectedTags : {
91
- "dummys": {
92
- "name": "dummys",
93
- "subtags": {
94
- "custom_field.age_group": {
95
- "name": "age_group",
96
- "desc": "age_group"
97
- },
98
- },
99
- "tag-header": true
100
- },
101
91
  "Registration custom fields": {
102
92
  "name": "Registration custom fields",
103
93
  "subtags": {
@@ -117,11 +107,7 @@ export const TagListData = {
117
107
  },
118
108
  "extended_field.marital_status": {
119
109
  "name": "marital_status",
120
- "desc": {
121
- props: {
122
- defaultMessage : "Marital Status",
123
- },
124
- },
110
+ "desc": "Marital Status"
125
111
  },
126
112
  },
127
113
  "tag-header": true
@@ -1,17 +0,0 @@
1
- import "@testing-library/jest-dom";
2
- import { hidingDateTagsForJpLocale } from "../utils";
3
-
4
- describe("Test utils", () => {
5
- it("it should test when hideDateTagsForJpLocale is available", () => {
6
- const result = hidingDateTagsForJpLocale(true, { name: "店舗名" }, [], { name: "店舗名" });
7
- expect(result).toEqual([{name: "店舗名"}]);
8
- });
9
- it("it should test date format which we dont want to show", () => {
10
- const result = hidingDateTagsForJpLocale(true, { name: "mm/dd/yyyy" }, [], { name: "mm/dd/yyyy" });
11
- expect(result).toEqual([]);
12
- });
13
- it("it should test when val name is not available", () => {
14
- const result = hidingDateTagsForJpLocale(false, { name: "店舗名" }, [], { name: "店舗名" });
15
- expect(result).toEqual([{name: "店舗名"}]);
16
- });
17
- });
@@ -1,15 +0,0 @@
1
- import { JAPANESE_HIDE_DATE_TAGS } from "../../containers/TagList/constants";
2
-
3
-
4
- export const hidingDateTagsForJpLocale = (hideDateTagsForJpLocale, val, list, value) => {
5
-
6
- if (hideDateTagsForJpLocale) {
7
- // hidden date tags from the japanese locale
8
- if (!JAPANESE_HIDE_DATE_TAGS?.includes(val?.name)) {
9
- list.push(value);
10
- }
11
- } else {
12
- list.push(value);
13
- }
14
- return list;
15
- };