@capillarytech/creatives-library 3.3.1 → 3.4.0
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/config/app.js +2 -0
- package/index.js +6 -0
- package/initialState.js +3 -0
- package/package.json +1 -1
- package/routes.js +6 -1
- package/services/api.js +25 -9
- package/translations/en.json +47 -0
- package/translations/zh.json +47 -0
- package/v2Components/MarketingObjective/MarketingObjective.style.js +73 -0
- package/v2Components/MarketingObjective/index.js +107 -0
- package/v2Components/MarketingObjective/messages.js +23 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +18 -0
- package/v2Containers/CreativesContainer/constants.js +1 -0
- package/v2Containers/CreativesContainer/index.js +10 -1
- package/v2Containers/Facebook/Facebook.style.js +75 -0
- package/v2Containers/Facebook/actions.js +13 -0
- package/v2Containers/Facebook/constants.js +24 -0
- package/v2Containers/Facebook/index.js +358 -0
- package/v2Containers/Facebook/messages.js +167 -0
- package/v2Containers/Facebook/reducer.js +31 -0
- package/v2Containers/Facebook/sagas.js +41 -0
- package/v2Containers/Facebook/selectors.js +20 -0
- package/v2Containers/TemplatesV2/index.js +53 -22
- package/v2Containers/TemplatesV2/messages.js +4 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { take, call, put, takeLatest, cancel } from 'redux-saga/effects';
|
|
2
|
+
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
3
|
+
import * as Api from '../../services/api';
|
|
4
|
+
import {
|
|
5
|
+
GET_MARKETING_OBJECTIVES,
|
|
6
|
+
SET_MARKETING_OBJECTIVES_SUCCESS,
|
|
7
|
+
SET_MARKETING_OBJECTIVES_FAILURE,
|
|
8
|
+
} from './constants';
|
|
9
|
+
|
|
10
|
+
export function* fetchMarketingObjectives() {
|
|
11
|
+
try {
|
|
12
|
+
const response = yield call(Api.getMarketingObjectives, 'FACEBOOK');
|
|
13
|
+
const { errors, data } = response;
|
|
14
|
+
if (errors && errors.length) {
|
|
15
|
+
yield put({
|
|
16
|
+
type: SET_MARKETING_OBJECTIVES_FAILURE,
|
|
17
|
+
payload: errors,
|
|
18
|
+
});
|
|
19
|
+
} else {
|
|
20
|
+
yield put({
|
|
21
|
+
type: SET_MARKETING_OBJECTIVES_SUCCESS,
|
|
22
|
+
payload: data,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
} catch (error) {
|
|
26
|
+
yield put({
|
|
27
|
+
type: SET_MARKETING_OBJECTIVES_FAILURE,
|
|
28
|
+
payload: error,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function* watchFetchMarketingObjective() {
|
|
34
|
+
const watcher = yield takeLatest(GET_MARKETING_OBJECTIVES, fetchMarketingObjectives);
|
|
35
|
+
yield take(LOCATION_CHANGE);
|
|
36
|
+
yield cancel(watcher);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default [
|
|
40
|
+
watchFetchMarketingObjective,
|
|
41
|
+
];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createSelector } from 'reselect';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Direct selector to the facebook state domain
|
|
5
|
+
*/
|
|
6
|
+
const selectFacebookDomain = () => (state) => state.get('facebook');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Other specific selectors
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Default selector used by Facebook
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const makeSelectMarketingObjectiveList = () => createSelector(
|
|
18
|
+
selectFacebookDomain(),
|
|
19
|
+
(substate) => substate && substate.get('marketinObjectivesData'),
|
|
20
|
+
);
|
|
@@ -21,6 +21,7 @@ import messages from './messages';
|
|
|
21
21
|
import * as actions from './actions';
|
|
22
22
|
import Templates from '../Templates';
|
|
23
23
|
import CallTask from '../CallTask';
|
|
24
|
+
import Facebook from '../Facebook';
|
|
24
25
|
import Gallery from '../Assets/Gallery';
|
|
25
26
|
import withStyles from '../../hoc/withStyles';
|
|
26
27
|
import styles, { CapTabStyle } from './TemplatesV2.style';
|
|
@@ -33,32 +34,44 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
33
34
|
constructor(props) {
|
|
34
35
|
super(props);
|
|
35
36
|
let defaultChannel = get(this, 'props.channel') || get(this, 'props.params.channel') || 'sms';
|
|
37
|
+
const {
|
|
38
|
+
intl,
|
|
39
|
+
channelsToHide = [],
|
|
40
|
+
channelsToDisable = [],
|
|
41
|
+
isFullMode,
|
|
42
|
+
onChannelChange,
|
|
43
|
+
} = props;
|
|
44
|
+
|
|
36
45
|
const defaultPanes = {
|
|
37
|
-
sms: {content: <div></div>, tab:
|
|
38
|
-
email: {content: <div></div>, tab:
|
|
39
|
-
weChat: {content: <div></div>, tab:
|
|
46
|
+
sms: {content: <div></div>, tab: intl.formatMessage(messages.sms), key: 'sms'},
|
|
47
|
+
email: {content: <div></div>, tab: intl.formatMessage(messages.email), key: 'email'},
|
|
48
|
+
weChat: {content: <div></div>, tab: intl.formatMessage(messages.wechat), key: 'wechat'},
|
|
40
49
|
//'wechat': {content: this.getTemplatesComponent('wechat'), tab: 'Wechat', key: 'wechat'},
|
|
41
|
-
mPush: {content: <div></div>, tab:
|
|
50
|
+
mPush: {content: <div></div>, tab: intl.formatMessage(messages.pushNotification), key: 'mobilepush'},
|
|
42
51
|
};
|
|
43
|
-
const channelsToHide = this.props.channelsToHide || [];
|
|
44
|
-
const channelsToDisable = this.props.channelsToDisable || [];
|
|
45
52
|
let filteredPanes = Object.keys(defaultPanes)
|
|
46
53
|
.filter((key) => !channelsToHide.includes(key)).reduce((obj = [], key) => {
|
|
47
54
|
obj.push(defaultPanes[key]);
|
|
48
55
|
return obj;
|
|
49
56
|
}, []);
|
|
50
57
|
|
|
51
|
-
if (
|
|
52
|
-
filteredPanes.push({content: <div></div>, tab:
|
|
53
|
-
} else
|
|
54
|
-
|
|
58
|
+
if (isFullMode ) {
|
|
59
|
+
filteredPanes.push({content: <div></div>, tab: intl.formatMessage(messages.gallery), key: 'assets'});
|
|
60
|
+
} else {
|
|
61
|
+
if (!channelsToHide.includes('callTask')) {
|
|
62
|
+
filteredPanes.push({content: <div></div>, tab: intl.formatMessage(messages.callTask), key: 'call_task'});
|
|
63
|
+
}
|
|
64
|
+
if (!channelsToHide.includes('facebook')) {
|
|
65
|
+
filteredPanes.push({content: <div></div>, tab: intl.formatMessage(messages.facebook), key: 'facebook'});
|
|
66
|
+
}
|
|
55
67
|
}
|
|
56
68
|
|
|
57
69
|
filteredPanes = filteredPanes.map( (pane) => {
|
|
58
70
|
if (channelsToDisable.includes(pane.key)) {
|
|
71
|
+
// eslint-disable-next-line no-param-reassign
|
|
59
72
|
pane.disabled = true;
|
|
60
73
|
}
|
|
61
|
-
|
|
74
|
+
return pane;
|
|
62
75
|
});
|
|
63
76
|
|
|
64
77
|
const channel = ['sms', 'email', 'mobilepush', 'call_task'];
|
|
@@ -78,7 +91,9 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
78
91
|
selectedChannel: defaultChannel,
|
|
79
92
|
panes,
|
|
80
93
|
};
|
|
81
|
-
!
|
|
94
|
+
if (!isFullMode) {
|
|
95
|
+
onChannelChange(defaultChannel);
|
|
96
|
+
}
|
|
82
97
|
}
|
|
83
98
|
componentWillReceiveProps(nextProps) {
|
|
84
99
|
if (this.props.channel !== nextProps.channel) {
|
|
@@ -122,6 +137,17 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
122
137
|
/>
|
|
123
138
|
);
|
|
124
139
|
|
|
140
|
+
getFacebookComponent = () => {
|
|
141
|
+
const { messageDetails, cap, onFacebookSubmit } = this.props;
|
|
142
|
+
return (
|
|
143
|
+
<Facebook
|
|
144
|
+
messageDetails={messageDetails}
|
|
145
|
+
cap={cap}
|
|
146
|
+
onFacebookSubmit={onFacebookSubmit}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
125
151
|
getTemplatesComponent(channel) {
|
|
126
152
|
// const templates = this.props.Templates[`${channel}Templates`];
|
|
127
153
|
let query = {};
|
|
@@ -134,6 +160,8 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
134
160
|
return this.getCallTaskComponent();
|
|
135
161
|
case 'assets':
|
|
136
162
|
return this.getGalleryComponent(location);
|
|
163
|
+
case 'facebook':
|
|
164
|
+
return this.getFacebookComponent();
|
|
137
165
|
default:
|
|
138
166
|
return (<Templates
|
|
139
167
|
key={channel}
|
|
@@ -182,16 +210,16 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
182
210
|
{ name: 'description', content: this.props.intl.formatMessage(messages.creativesDesc) },
|
|
183
211
|
]}
|
|
184
212
|
/>}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
213
|
+
<div className="component-wrapper">
|
|
214
|
+
{isFullMode && <CapHeader title={<FormattedMessage {...messages.creatives}/>} description={<FormattedMessage {...messages.creativesDesc}/>}/>}
|
|
215
|
+
<StyledCapTab
|
|
216
|
+
panes={this.state.panes}
|
|
217
|
+
onChange={this.channelChange}
|
|
218
|
+
activeKey={this.state.selectedChannel}
|
|
219
|
+
defaultActiveKey={this.state.selectedChannel}
|
|
220
|
+
isFullMode={isFullMode}
|
|
221
|
+
/>
|
|
222
|
+
</div>
|
|
195
223
|
</div>
|
|
196
224
|
|
|
197
225
|
);
|
|
@@ -213,6 +241,9 @@ TemplatesV2.propTypes = {
|
|
|
213
241
|
channelsToHide: PropTypes.array,
|
|
214
242
|
className: PropTypes.string.isRequired,
|
|
215
243
|
channelsToDisable: PropTypes.array,
|
|
244
|
+
onFacebookSubmit: PropTypes.func,
|
|
245
|
+
messageDetails: PropTypes.object,
|
|
246
|
+
cap: PropTypes.object,
|
|
216
247
|
};
|
|
217
248
|
|
|
218
249
|
TemplatesV2.defaultProps = {
|
|
@@ -42,6 +42,10 @@ export default defineMessages({
|
|
|
42
42
|
id: 'creatives.containersV2.TemplatesV2.callTask',
|
|
43
43
|
defaultMessage: 'Call Task',
|
|
44
44
|
},
|
|
45
|
+
facebook: {
|
|
46
|
+
id: 'creatives.containersV2.TemplatesV2.facebook',
|
|
47
|
+
defaultMessage: 'Facebook',
|
|
48
|
+
},
|
|
45
49
|
gallery: {
|
|
46
50
|
id: 'creatives.containersV2.TemplatesV2.gallery',
|
|
47
51
|
defaultMessage: 'Gallery',
|