@capillarytech/creatives-library 7.17.31 → 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.31",
4
+ "version": "7.17.32",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -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
- });