@capillarytech/creatives-library 7.17.31 → 7.17.33-alpha.1

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.
@@ -13,7 +13,7 @@ import React from 'react';
13
13
  import _ from 'lodash';
14
14
  // import messages from './messages';
15
15
  const loadScript = require('load-script');
16
- const defaultScriptUrl = "https://storage.crm.n.content-cdn.io/ckeditor_full/ckeditor/ckeditor.js";
16
+ const defaultScriptUrl = `${window.location.origin}/arya/ui/library/ckeditor/ckeditor.js`;
17
17
  const user = localStorage.getItem('user');
18
18
  let locale = 'en';
19
19
  if (user && JSON.parse(user).lang) {
@@ -42,3 +42,5 @@ export const HOSPITALITY_RELATED_TAGS = [
42
42
  "email",
43
43
  "resID_Source",
44
44
  ];
45
+
46
+ const CUSTOMER_BARCODE_TAG = "customer_barcode";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.17.31",
4
+ "version": "7.17.33-alpha.1",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -17,7 +17,7 @@ import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
17
17
  import { createStructuredSelector } from 'reselect';
18
18
  import messages from './messages';
19
19
  import { makeSelectLoyaltyPromotionDisplay } from '../../v2Containers/Cap/selectors';
20
- import { CARD_RELATED_TAGS, HOSPITALITY_RELATED_TAGS } from '../../containers/App/constants';
20
+ import { CARD_RELATED_TAGS, HOSPITALITY_RELATED_TAGS, CUSTOMER_BARCODE_TAG } from '../../containers/App/constants';
21
21
  import { hasCardBasedScope, hasHospitalityBasedScope } from '../../utils/common';
22
22
 
23
23
  import {
@@ -25,7 +25,7 @@ import {
25
25
  JAPANESE_HELP_TEXT,
26
26
  TAG_TRANSLATION_DOC,
27
27
  } from "../../containers/TagList/constants";
28
- import { JP_LOCALE_HIDE_FEATURE } from '../../v2Containers/App/constants';
28
+ import { ENABLE_CUSTOMER_BARCODE_TAG, JP_LOCALE_HIDE_FEATURE } from '../../v2Containers/App/constants';
29
29
  import { hidingDateTagsForJpLocale } from '../../v2Containers/TagList/utils';
30
30
 
31
31
 
@@ -176,12 +176,18 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
176
176
  const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags } = this?.props?.disableTagsDetails;
177
177
  const { accessibleFeatures = [] } = this?.props?.currentOrgDetails || {};
178
178
  const hideDateTagsForJpLocale = accessibleFeatures.includes(JP_LOCALE_HIDE_FEATURE);
179
+ const enabledCustomerBarcode = accessibleFeatures.includes(ENABLE_CUSTOMER_BARCODE_TAG);
179
180
  const list = [];
180
181
  const loyaltyAttrDisableText = <FormattedMessage {...messages.loyaltyAttributeDisable} />;
182
+ const customerBarcodeDisableText = <FormattedMessage {...messages.customerBarcodeDisable} />;
181
183
  let clonedTags = _.cloneDeep(tags);
182
184
  if (!hasCardBasedScope()) {
183
185
  clonedTags = _.omit(clonedTags, CARD_RELATED_TAGS);
184
186
  }
187
+ //code to remove until barcode tag is not supported by BE
188
+ // if (!hasCardBasedScope()) {
189
+ // clonedTags = _.omit(clonedTags, CUSTOMER_BARCODE_TAG );
190
+ // }
185
191
  if (!hasHospitalityBasedScope()) {
186
192
  //filtering HOSPITALITY_RELATED_TAGS if org does not have HOSPITALITY_BASED_SCOPE feature enabled
187
193
  clonedTags = _.omit(clonedTags, HOSPITALITY_RELATED_TAGS);
@@ -207,10 +213,14 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
207
213
  );
208
214
  hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tagValue);
209
215
  } else if (searchString === '' || !searchString || ((val.name || '').toLowerCase().indexOf(searchString.toLowerCase()) !== -1)) {
210
- const childDisabled = disableRelatedTags ? childTagsToDisable.includes(key) : false;
216
+ let childDisabled = true;
217
+ if (key === "customer_barcode" && !enabledCustomerBarcode) {
218
+ childDisabled = true;
219
+ }
220
+ else childDisabled = disableRelatedTags ? childTagsToDisable.includes(key) : false;
211
221
  const tempNode = (
212
222
  <CapTreeNode
213
- title={childDisabled ? <CapTooltip title={loyaltyAttrDisableText}>{val.desc || val.name}</CapTooltip> : (val.desc || val.name)}
223
+ title={childDisabled ? <CapTooltip title={key === "customer_barcode" ? customerBarcodeDisableText : loyaltyAttrDisableText}>{val.desc || val.name}</CapTooltip> : (val.desc || val.name)} //need to add key name to get tooltip
214
224
  tag={val}
215
225
  isLeaf
216
226
  key={val.couponSeriesId ? `${key}(${val.couponSeriesId})` : `${key}`}
@@ -46,4 +46,8 @@ export default defineMessages({
46
46
  id: `creatives.componentsV2.CapTagList.loyaltyAttributeDisable`,
47
47
  defaultMessage: 'You won’t be able to add loyalty related attributes since the loyalty program/ card series is None.',
48
48
  },
49
+ "customerBarcodeDisable": {
50
+ id: `creatives.componentsV2.CapTagList.customerBarcodeDisable`,
51
+ defaultMessage: 'This label is not enabled for your organization. Please connect with your Capillary POC',
52
+ },
49
53
  });
@@ -13,7 +13,8 @@ import React from 'react';
13
13
  import _ from 'lodash';
14
14
  // import messages from './messages';
15
15
  const loadScript = require('load-script');
16
- const defaultScriptUrl = "https://storage.crm.n.content-cdn.io/ckeditor_full/ckeditor/ckeditor.js";
16
+ const defaultScriptUrl = `${window.location.origin}/arya/ui/library/ckeditor/ckeditor.js`;
17
+ //const defaultScriptUrl = '{hostName}/arya/ui/library/ckeditor/ckeditor.js'; uncomment for local testing
17
18
  const user = localStorage.getItem('user');
18
19
  let locale = 'en';
19
20
  if (user && JSON.parse(user).lang) {
@@ -118,3 +118,4 @@ export const LOYALTY = 'loyalty';
118
118
  export const FAILURE = 'FAILURE';
119
119
  export const DATE_DISPLAY_FORMAT = 'D MMM YYYY';
120
120
  export const TIME_DISPLAY_FORMAT = 'hh:mm A';
121
+ export const ENABLE_CUSTOMER_BARCODE_TAG = 'ENABLE_CUSTOMER_BARCODE_TAG';
@@ -643,7 +643,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
643
643
  } else if (data === "unsubscribe" && this.state.editorInstanse) {
644
644
  const anchor = `<a href='{{${data}}}'>${data}</a>`;
645
645
  this.state.editorInstanse.insertHtml(`${anchor}`);
646
- } else if (this.state.editorInstanse) {
646
+ } else if (data === "customer_barcode" && this.state.editorInstanse) {
647
+ this.state.editorInstanse.insertHtml(`<img src="https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/8ebc8301-e262-45a6-bdab-ff0de91a.png?code={{${data}}}" />`);
648
+ } else if (this.state.editorInstanse){
647
649
  this.state.editorInstanse.insertHtml(`{{${data}}}`);
648
650
  }
649
651
  //this.resetCkEditorInstance(currentTab, formData, true, data);
@@ -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:
@@ -1,20 +0,0 @@
1
- /*
2
- *
3
- * ChannelTemplates actions
4
- *
5
- */
6
-
7
- import * as types from './constants';
8
-
9
- export function defaultAction() {
10
- return {
11
- type: types.DEFAULT_ACTION,
12
- };
13
- }
14
-
15
- export function getTemplates(channel) {
16
- return {
17
- type: types.GET_TEMPLATES_REQUEST,
18
- channel,
19
- };
20
- }
@@ -1,8 +0,0 @@
1
- /*
2
- *
3
- * ChannelTemplates constants
4
- *
5
- */
6
-
7
- export const DEFAULT_ACTION = 'app/ChannelTemplates/DEFAULT_ACTION';
8
-
@@ -1,47 +0,0 @@
1
- /*
2
- *
3
- * ChannelTemplates
4
- *
5
- */
6
-
7
- import PropTypes from 'prop-types';
8
-
9
- import React from 'react';
10
- import { connect } from 'react-redux';
11
- import { FormattedMessage } from 'react-intl';
12
- import { bindActionCreators } from 'redux';
13
- import { createStructuredSelector } from 'reselect';
14
- import makeSelectChannelTemplates from './selectors';
15
- import * as actions from './actions';
16
- import messages from './messages';
17
-
18
-
19
- export class ChannelTemplates extends React.Component { // eslint-disable-line react/prefer-stateless-function
20
- componentDidMount() {
21
- this.props.actions.getTemplates(this.props.channel);
22
- }
23
- render() {
24
- return (
25
- <CardGrid
26
- cardDataList={[]}
27
- />
28
- );
29
- }
30
- }
31
-
32
- ChannelTemplates.propTypes = {
33
- actions: PropTypes.object.isRequired,
34
- channel: PropTypes.string,
35
- };
36
-
37
- const mapStateToProps = createStructuredSelector({
38
- ChannelTemplates: makeSelectChannelTemplates(),
39
- });
40
-
41
- function mapDispatchToProps(dispatch) {
42
- return {
43
- actions: bindActionCreators(actions, dispatch),
44
- };
45
- }
46
-
47
- export default connect(mapStateToProps, mapDispatchToProps)(ChannelTemplates);
@@ -1,13 +0,0 @@
1
- /*
2
- * ChannelTemplates Messages
3
- *
4
- * This contains all the text for the ChannelTemplates component.
5
- */
6
- import { defineMessages } from 'react-intl';
7
-
8
- export default defineMessages({
9
- header: {
10
- id: 'creatives.containersV2.ChannelTemplates.header',
11
- defaultMessage: 'This is ChannelTemplates container !',
12
- },
13
- });
@@ -1,34 +0,0 @@
1
- /*
2
- *
3
- * ChannelTemplates reducer
4
- *
5
- */
6
-
7
- import { fromJS } from 'immutable';
8
- import * as types from './constants';
9
-
10
- const initialState = fromJS({
11
- loadingTemplates: true,
12
- smsTemplates: [],
13
- emailTemplates: [],
14
- wechatTemplates: [],
15
- mobilepushTemplates: [],
16
- });
17
-
18
- function channelTemplatesReducer(state = initialState, action) {
19
- const channelTemplates = `${action.channel}Templates`;
20
- switch (action.type) {
21
- case types.DEFAULT_ACTION:
22
- return state;
23
- case types.GET_TEMPLATES_REQUEST:
24
- return state.set('loadingTemplates', true);
25
- case types.GET_TEMPLATES_SUCESS:
26
- return state.set('loadingTemplates', false).set(channelTemplates, action.templates);
27
- case types.GET_TEMPLATES_FAILURE:
28
- return state.set('loadingTemplates', false).set('error', action.error);
29
- default:
30
- return state;
31
- }
32
- }
33
-
34
- export default channelTemplatesReducer;
@@ -1,32 +0,0 @@
1
- import { take, takeLatest, call, put, cancel } from 'redux-saga/effects';
2
- import { LOCATION_CHANGE } from 'react-router-redux';
3
- import * as Api from '../../services/api';
4
-
5
-
6
- import * as types from './constants';
7
- // Individual exports for testing
8
- export function* defaultSaga() {
9
- // See example in v2Containers/HomePage/sagas.js
10
- }
11
- function* getTemplates(action) {
12
- try {
13
- const req = {
14
- channel: action.channel,
15
- queryParams: action.query,
16
- };
17
- const res = call(Api.getAllTemplates, req);
18
- put({type: types.GET_TEMPLATES_SUCESS, templates: res.response, channel: action.channel});
19
- } catch (error) {
20
- put({type: types.GET_TEMPLATES_FAILURE, error});
21
- }
22
- }
23
- function* getTemplatesWatcher() {
24
- const watcher = yield takeLatest(types.GET_TEMPLATES_REQUEST, getTemplates);
25
- yield take(LOCATION_CHANGE);
26
- yield cancel(watcher);
27
- }
28
- // All sagas to be loaded
29
- export default [
30
- defaultSaga,
31
- getTemplatesWatcher,
32
- ];
@@ -1,25 +0,0 @@
1
- import { createSelector } from 'reselect';
2
-
3
- /**
4
- * Direct selector to the channelTemplates state domain
5
- */
6
- const selectChannelTemplatesDomain = () => (state) => state.get('templates');
7
-
8
- /**
9
- * Other specific selectors
10
- */
11
-
12
-
13
- /**
14
- * Default selector used by ChannelTemplates
15
- */
16
-
17
- const makeSelectChannelTemplates = () => createSelector(
18
- selectChannelTemplatesDomain(),
19
- (substate) => substate.toJS()
20
- );
21
-
22
- export default makeSelectChannelTemplates;
23
- export {
24
- selectChannelTemplatesDomain,
25
- };
@@ -1,82 +0,0 @@
1
- import { expectSaga } from "redux-saga-test-plan";
2
- import { take, cancel, takeLatest } from "redux-saga/effects";
3
- import * as matchers from "redux-saga-test-plan/matchers";
4
- import { LOCATION_CHANGE } from "react-router-redux";
5
- import { throwError } from "redux-saga-test-plan/providers";
6
- import { createMockTask } from "redux-saga/utils";
7
- import * as types from "../constants";
8
- import { watchAiSuggestions, getAiSuggestions } from "../sagas";
9
- import * as Api from "../../../../services/api";
10
-
11
- describe("getAiSuggestions saga", () => {
12
- it("Should handle valid response from api", () => {
13
- const successCallback = () => {};
14
- const failureCallback = () => {};
15
- const action = {
16
- type: types.GET_AI_SUGGESTIONS,
17
- prompt: {},
18
- successCallback,
19
- failureCallback,
20
- };
21
- expectSaga(getAiSuggestions, action)
22
- .provide([
23
- [
24
- matchers.call.fn(Api.getAiSuggestions),
25
- {
26
- success: true,
27
- status: {
28
- isError: false,
29
- code: 200,
30
- message: "success",
31
- },
32
- message: "Meta data fetched successfully",
33
- response: {
34
- "https://response.com": 1400,
35
- },
36
- },
37
- ],
38
- [matchers.call.fn(successCallback)],
39
- ])
40
- .run();
41
- });
42
-
43
- it("Should handles error thrown from api", () => {
44
- const successCallback = () => {};
45
- const failureCallback = () => {};
46
- const action = {
47
- type: types.GET_AI_SUGGESTIONS,
48
- prompt: {},
49
- successCallback,
50
- failureCallback,
51
- };
52
- expectSaga(getAiSuggestions, action)
53
- .provide([[matchers.call.fn(Api.getAiSuggestions), throwError()]])
54
- .run();
55
- });
56
- });
57
-
58
- describe("watchAiSuggestions saga", () => {
59
- let generator = null;
60
- beforeEach(() => {
61
- generator = watchAiSuggestions();
62
- });
63
- it("Should handle valid response from api", () => {
64
- const progress1 = generator.next();
65
- const mockTask = takeLatest(types.GET_AI_SUGGESTIONS, getAiSuggestions);
66
- expect(progress1.value).toEqual(mockTask);
67
- const progress2 = generator.next();
68
- expect(progress2.value).toEqual(take(LOCATION_CHANGE));
69
- });
70
-
71
- it("Should handle LOCATION_CHANGE action and cancel the watcher", () => {
72
- generator = watchAiSuggestions();
73
- const mockTask = createMockTask();
74
-
75
- expect(generator.next().value).toEqual(
76
- takeLatest(types.GET_AI_SUGGESTIONS, getAiSuggestions)
77
- );
78
- expect(generator.next(mockTask).value).toEqual(take(LOCATION_CHANGE));
79
- expect(generator.next().value).toEqual(cancel(mockTask));
80
- expect(generator.next().done).toEqual(true);
81
- });
82
- });