@capillarytech/creatives-library 7.16.19 → 7.16.20
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/containers/Cap/index.js +10 -5
- package/containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/package.json +1 -1
- package/translations/en.json +1 -0
- package/translations/ja-JP.json +1 -0
- package/translations/zh.json +1 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/ImageMap/index.js +1 -1
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +17 -0
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +47 -0
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +8 -0
- package/v2Containers/Templates/index.js +1 -1
- package/v2Containers/Templates/messages.js +4 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +71 -0
- package/v2Containers/ChannelTemplates/actions.js +0 -20
- package/v2Containers/ChannelTemplates/constants.js +0 -8
- package/v2Containers/ChannelTemplates/index.js +0 -47
- package/v2Containers/ChannelTemplates/messages.js +0 -13
- package/v2Containers/ChannelTemplates/reducer.js +0 -34
- package/v2Containers/ChannelTemplates/sagas.js +0 -32
- package/v2Containers/ChannelTemplates/selectors.js +0 -25
- package/v2Containers/Sms/Create/tests/sagas.test.js +0 -82
|
@@ -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
|
-
});
|