@capillarytech/creatives-library 7.17.30 → 7.17.32

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.30",
4
+ "version": "7.17.32",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/utils/common.js CHANGED
@@ -288,7 +288,8 @@ export const isTraiDLTEnable = (isFullMode, smsRegister) => {
288
288
  return isTraiDltFeature;
289
289
  };
290
290
 
291
- export const intlKeyGenerator = (value = "") => String(value).replace(/[^a-zA-Z0-9_]/g, "");
291
+
292
+ export const intlKeyGenerator = (value = "") => String(value).replace(/[^a-zA-Z0-9_]/g, "").toLowerCase();
292
293
 
293
294
  export const handleInjectedData = (data, scope) => {
294
295
  let tagType;
@@ -51,7 +51,7 @@ describe("handleInjectedData", () => {
51
51
  const result = handleInjectedData(data, "scope");
52
52
  const intlKey = intlKeyGenerator("scope");
53
53
  expect(intlKey).toEqual('scope');
54
- expect(result.tag1.name).toEqual(<FormattedMessage defaultMessage="Registration Fields" id="scope.RegistrationFields" values={{}} />);
54
+ expect(result.tag1.name).toEqual(<FormattedMessage defaultMessage="Registration Fields" id="scope.registrationfields" values={{}} />);
55
55
  });
56
56
 
57
57
  it("adds tagType for Registration custom fields", () => {
@@ -62,9 +62,10 @@ describe("handleInjectedData", () => {
62
62
  };
63
63
 
64
64
  const result = handleInjectedData(data, "scope");
65
-
65
+ const intlKey = intlKeyGenerator();
66
+ expect(intlKey).toEqual('');
66
67
  expect(result.tag1.name).toEqual(
67
- <FormattedMessage defaultMessage="Registration custom fields" id="scope.Registrationcustomfields_name.CustomTagMessage" values={{}} />
68
+ <FormattedMessage defaultMessage="Registration custom fields" id="scope.registrationcustomfields_name.CustomTagMessage" values={{}} />
68
69
  );
69
70
  });
70
71
 
@@ -78,7 +79,7 @@ describe("handleInjectedData", () => {
78
79
  const result = handleInjectedData(data, "scope");
79
80
 
80
81
  expect(result.tag1.name).toEqual(
81
- <FormattedMessage defaultMessage="Customer extended fields" id="scope.Customerextendedfields_name.ExtendedTagMessage" values={{}} />
82
+ <FormattedMessage defaultMessage="Customer extended fields" id="scope.customerextendedfields_name.ExtendedTagMessage" values={{}} />
82
83
  );
83
84
  });
84
85
  it("adds tagType for Customer extended fields fields", () => {
@@ -156,7 +157,7 @@ describe("handleInjectedData", () => {
156
157
  const result = handleInjectedData(data, "scope");
157
158
 
158
159
  expect(result.tag1.subtags.subtag1.desc).toEqual(
159
- <FormattedMessage defaultMessage="Enter your first name" id="scope.Enteryourfirstname" values={{}} />
160
+ <FormattedMessage defaultMessage="Enter your first name" id="scope.enteryourfirstname" values={{}} />
160
161
  );
161
162
  });
162
163
  it("replaces subtag name desc with intl key", () => {
@@ -174,7 +175,7 @@ describe("handleInjectedData", () => {
174
175
  const result = handleInjectedData(data, "scope");
175
176
 
176
177
  expect(result.tag1.subtags.subtag1.desc).toEqual(
177
- <FormattedMessage defaultMessage="Enter your first name" id="scope.Enteryourfirstname" values={{}} />
178
+ <FormattedMessage defaultMessage="Enter your first name" id="scope.enteryourfirstname" values={{}} />
178
179
  );
179
180
  });
180
181
  });
@@ -25,7 +25,7 @@ import {
25
25
  JAPANESE_HELP_TEXT,
26
26
  TAG_TRANSLATION_DOC,
27
27
  } from "../../containers/TagList/constants";
28
- import { HIDE_FOR_JP_LOCALE } from '../../v2Containers/App/constants';
28
+ import { JP_LOCALE_HIDE_FEATURE } from '../../v2Containers/App/constants';
29
29
  import { hidingDateTagsForJpLocale } from '../../v2Containers/TagList/utils';
30
30
 
31
31
 
@@ -175,7 +175,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
175
175
  renderTags(tags, searchString = '') {
176
176
  const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags } = this?.props?.disableTagsDetails;
177
177
  const { accessibleFeatures = [] } = this?.props?.currentOrgDetails || {};
178
- const hideDateTagsForJpLocale = accessibleFeatures.includes(HIDE_FOR_JP_LOCALE);
178
+ const hideDateTagsForJpLocale = accessibleFeatures.includes(JP_LOCALE_HIDE_FEATURE);
179
179
  const list = [];
180
180
  const loyaltyAttrDisableText = <FormattedMessage {...messages.loyaltyAttributeDisable} />;
181
181
  let clonedTags = _.cloneDeep(tags);
@@ -54,7 +54,7 @@ export const LINE = 'line';
54
54
  export const EMAIL = 'email';
55
55
  export const ASSETS = 'assets';
56
56
 
57
- export const HIDE_FOR_JP_LOCALE = 'HIDE_FOR_JP_LOCALE';
57
+ export const JP_LOCALE_HIDE_FEATURE = 'JP_LOCALE_HIDE_FEATURE';
58
58
 
59
59
  export const TRACK_EDIT_SMS = 'editSms';
60
60
  export const TRACK_EDIT_EMAIL = 'editEmail';
@@ -98,7 +98,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
98
98
  //Form tags object with tag headers
99
99
  _.forEach(tagsList, (temp) => {
100
100
  const tag = temp.definition;
101
- const { locale : userLocale } = this.props.intl;
101
+ const { locale : userLocale } = this.props?.intl || {};
102
102
  if (!tag['tag-header']) {
103
103
  mainTags[tag.value] = {
104
104
  "name": tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
@@ -29,7 +29,7 @@ import FTP from '../FTP';
29
29
  import Gallery from '../Assets/Gallery';
30
30
  import withStyles from '../../hoc/withStyles';
31
31
  import styles, { CapTabStyle } from './TemplatesV2.style';
32
- import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS, HIDE_FOR_JP_LOCALE } from '../App/constants';
32
+ import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS, JP_LOCALE_HIDE_FEATURE } from '../App/constants';
33
33
  import AccessForbidden from '../../v2Components/AccessForbidden';
34
34
  import { getObjFromQueryParams } from '../../utils/v2common';
35
35
  import { selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
@@ -119,8 +119,8 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
119
119
  const { accessibleFeatures = [] } = currentOrgDetails || {};
120
120
  // This data will be available when it will be accessed in library mode
121
121
  const { currentOrgDetails: { accessibleFeatures: libModeAccessibleFeatures = [] } = {} } = cap || {};
122
- const hideEngagementChannel = accessibleFeatures.includes(HIDE_FOR_JP_LOCALE) || libModeAccessibleFeatures.includes(HIDE_FOR_JP_LOCALE);
123
- // Show only line and email channel content with both channel tabs if the HIDE_FOR_JP_LOCALE feature is enabled;
122
+ const hideEngagementChannel = accessibleFeatures.includes(JP_LOCALE_HIDE_FEATURE) || libModeAccessibleFeatures.includes(JP_LOCALE_HIDE_FEATURE);
123
+ // Show only line and email channel content with both channel tabs if the JP_LOCALE_HIDE_FEATURE feature is enabled;
124
124
  filteredPanes = hideEngagementChannel ? filteredPanes?.filter((pane) => [EMAIL, LINE, ASSETS].includes(pane?.key) && pane) : filteredPanes;
125
125
  defaultChannel = hideEngagementChannel ? EMAIL : defaultChannel;
126
126
 
@@ -599,7 +599,7 @@ export const authData = {
599
599
  "ENABLE_PRODUCT_SUPPORT_VIDEOS",
600
600
  "ENABLE_RANDOM_COUPON_CODE",
601
601
  "HIDE_DEFAULT_EMAIL_TEMPLATES",
602
- "HIDE_FOR_JP_LOCALE",
602
+ "JP_LOCALE_HIDE_FEATURE",
603
603
  ],
604
604
  org_loyalty_v2_status: true,
605
605
  module_details: [
@@ -680,6 +680,6 @@ export const currentOrgDetails = {
680
680
  "JOURNEY_UI",
681
681
  "LOYALTY_PROMOTION_ENABLED",
682
682
  "HIDE_DEFAULT_EMAIL_TEMPLATES",
683
- "HIDE_FOR_JP_LOCALE",
683
+ "JP_LOCALE_HIDE_FEATURE",
684
684
  ],
685
685
  };
@@ -838,6 +838,8 @@ export const Whatsapp = (props) => {
838
838
  errorMessage = formatMessage(
839
839
  globalMessages.emptyTemplateNameErrorMessage,
840
840
  );
841
+ } else if (value.length < 3 && host === HOST_GUPSHUP) {
842
+ errorMessage = formatMessage(messages.templateNameMinCharacters);
841
843
  } else if (!templateNameRegex.test(value)) {
842
844
  errorMessage = formatMessage(messages.templateNameRegexErrorMessage);
843
845
  }
@@ -872,6 +874,7 @@ export const Whatsapp = (props) => {
872
874
 
873
875
  const templateMessageErrorHandler = (value) => {
874
876
  let errorMessage = false;
877
+ const percentSignRegex = /%/;
875
878
  if (value === '') {
876
879
  errorMessage = formatMessage(messages.emptyTemplateMessageErrorMessage);
877
880
  } else if (
@@ -879,6 +882,9 @@ export const Whatsapp = (props) => {
879
882
  TEMPLATE_MESSAGE_MAX_LENGTH
880
883
  ) {
881
884
  errorMessage = formatMessage(messages.templateMessageLengthError);
885
+ } else if ( host === HOST_GUPSHUP && percentSignRegex.test(value)
886
+ ) {
887
+ errorMessage = formatMessage(messages.noPercentSign);
882
888
  } else {
883
889
  const validVarArr = value.match(validVarRegex) || [];
884
890
  const validVarSet = [...new Set(validVarArr)];
@@ -15,6 +15,10 @@ export default defineMessages({
15
15
  defaultMessage:
16
16
  'Template name can only contain lowercase alphanumeric characters and underscores',
17
17
  },
18
+ templateNameMinCharacters: {
19
+ id: `${prefix}.templateNameMinCharacters`,
20
+ defaultMessage: 'Template name should contain atleast 3 characters',
21
+ },
18
22
  templateCategoryLabel: {
19
23
  id: `${prefix}.templateCategoryLabel`,
20
24
  defaultMessage: 'Template category',
@@ -189,6 +193,10 @@ export default defineMessages({
189
193
  id: `${prefix}.noContentBetweenVars`,
190
194
  defaultMessage: 'Add atleast 1 character between 2 variables',
191
195
  },
196
+ noPercentSign: {
197
+ id: `${prefix}.noPercentSign`,
198
+ defaultMessage: 'Please remove % sign from the message content',
199
+ },
192
200
  sequenceVars: {
193
201
  id: `${prefix}.sequenceVars`,
194
202
  defaultMessage: