@capillarytech/creatives-library 7.17.56 → 7.17.57-alpha.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/containers/App/constants.js +15 -0
- package/package.json +1 -1
- package/utils/common.js +7 -0
- package/v2Containers/ChannelTemplates/actions.js +20 -0
- package/v2Containers/ChannelTemplates/constants.js +8 -0
- package/v2Containers/ChannelTemplates/index.js +47 -0
- package/v2Containers/ChannelTemplates/messages.js +13 -0
- package/v2Containers/ChannelTemplates/reducer.js +34 -0
- package/v2Containers/ChannelTemplates/sagas.js +32 -0
- package/v2Containers/ChannelTemplates/selectors.js +25 -0
- package/v2Containers/TagList/index.js +6 -2
|
@@ -12,6 +12,7 @@ export const PROMO_ENGINE = 'PROMO_ENGINE';
|
|
|
12
12
|
export const CUSTOM_TAG = 'CustomTagMessage';
|
|
13
13
|
export const CUSTOMER_EXTENDED_FIELD = 'Customer extended fields';
|
|
14
14
|
export const EXTENDED_TAG = 'ExtendedTagMessage';
|
|
15
|
+
export const BADGES_UI_ENABLED = 'BADGES_UI_ENABLED';
|
|
15
16
|
export const JP_LOCALE_HIDE_FEATURE = 'JP_LOCALE_HIDE_FEATURE';
|
|
16
17
|
export const ENABLE_CUSTOMER_BARCODE_TAG = "ENABLE_CUSTOMER_BARCODE_TAG";
|
|
17
18
|
|
|
@@ -70,5 +71,19 @@ export const PROMO_ENGINE_RELATED_TAGS = [
|
|
|
70
71
|
"promotion_expiry_date",
|
|
71
72
|
];
|
|
72
73
|
|
|
74
|
+
export const BADGES_RELATED_TAGS = [
|
|
75
|
+
"Badge",
|
|
76
|
+
"Badge_expiry_date",
|
|
77
|
+
"badge_expiry_mm_slash_dd_slash_yyyy",
|
|
78
|
+
"badge_expiry_dd_slash_mm_slash_yyyy",
|
|
79
|
+
"badge_expiry_yyyy_hyphen_mm_hyphen_dd",
|
|
80
|
+
"badge_expiry_mm_slash_dd_slash_yy",
|
|
81
|
+
"badge_expiry_dd_space_Mon_space_yyyy",
|
|
82
|
+
"badge_expiry_Day_comma_space_Mon_space_dd_comma_space_yy",
|
|
83
|
+
"badge_expiry_Dd_dot_mm_dot_yy",
|
|
84
|
+
"badge_expiry_dd_space_Mon",
|
|
85
|
+
"Days_until_expiry",
|
|
86
|
+
];
|
|
87
|
+
|
|
73
88
|
export const CUSTOMER_BARCODE_TAG = "customer_barcode";
|
|
74
89
|
export const COPY_OF = "Copy of";
|
package/package.json
CHANGED
package/utils/common.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
REGISTRATION_CUSTOM_FIELD,
|
|
16
16
|
JP_LOCALE_HIDE_FEATURE,
|
|
17
17
|
ENABLE_CUSTOMER_BARCODE_TAG,
|
|
18
|
+
BADGES_UI_ENABLED,
|
|
18
19
|
} from '../containers/App/constants';
|
|
19
20
|
import { apiMessageFormatHandler } from './commonUtils';
|
|
20
21
|
|
|
@@ -77,6 +78,12 @@ export const hasGiftVoucherFeature = Auth.hasFeatureAccess.bind(
|
|
|
77
78
|
null,
|
|
78
79
|
GIFT_CARDS,
|
|
79
80
|
);
|
|
81
|
+
|
|
82
|
+
export const hasBadgesFeature = Auth.hasFeatureAccess.bind(
|
|
83
|
+
null,
|
|
84
|
+
BADGES_UI_ENABLED
|
|
85
|
+
);
|
|
86
|
+
|
|
80
87
|
export const hasJPLocaleHideFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
81
88
|
null,
|
|
82
89
|
JP_LOCALE_HIDE_FEATURE,
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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);
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
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;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
];
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
};
|
|
@@ -22,8 +22,8 @@ import './_tagList.scss';
|
|
|
22
22
|
import { selectCurrentOrgDetails } from '../Cap/selectors';
|
|
23
23
|
import { injectIntl } from 'react-intl';
|
|
24
24
|
import { scope } from './messages';
|
|
25
|
-
import { handleInjectedData, hasGiftVoucherFeature, hasPromoFeature } from '../../utils/common';
|
|
26
|
-
import { GIFT_VOUCHER_RELATED_TAGS, PROMO_ENGINE_RELATED_TAGS } from '../../containers/App/constants';
|
|
25
|
+
import { handleInjectedData, hasGiftVoucherFeature, hasPromoFeature, hasBadgesFeature } from '../../utils/common';
|
|
26
|
+
import { GIFT_VOUCHER_RELATED_TAGS, PROMO_ENGINE_RELATED_TAGS, BADGES_RELATED_TAGS } from '../../containers/App/constants';
|
|
27
27
|
|
|
28
28
|
const TreeNode = Tree.TreeNode;
|
|
29
29
|
|
|
@@ -105,6 +105,10 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
105
105
|
//filtering GIFT_VOUCHER_RELATED_TAGS if org does not have GIFT_CARDS feature enabled
|
|
106
106
|
excludedTags.push(...GIFT_VOUCHER_RELATED_TAGS);
|
|
107
107
|
}
|
|
108
|
+
if (!hasBadgesFeature()) {
|
|
109
|
+
//filtering BADGES_RELATED_TAGS if org does not have BADGES feature enabled
|
|
110
|
+
excludedTags.push(...BADGES_RELATED_TAGS);
|
|
111
|
+
}
|
|
108
112
|
//Form tags object with tag headers
|
|
109
113
|
_.forEach(tagsList, (temp) => {
|
|
110
114
|
const tag = temp.definition;
|