Ivan - Add admin data reducer with custom response data [skip ci]
This commit is contained in:
parent
a10aebfdf5
commit
7e74fbe360
|
@ -0,0 +1,14 @@
|
|||
import API from 'lib-app/api-call';
|
||||
|
||||
export default {
|
||||
|
||||
retrieveCustomResponses() {
|
||||
return {
|
||||
type: 'CUSTOM_RESPONSES',
|
||||
payload: API.call({
|
||||
path: '/ticket/get-custom-responses',
|
||||
data: {}
|
||||
})
|
||||
};
|
||||
}
|
||||
};
|
|
@ -1,12 +1,23 @@
|
|||
import React from 'react';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import i18n from 'lib-app/i18n';
|
||||
|
||||
import AdminDataActions from 'actions/admin-data-actions';
|
||||
import Header from 'core-components/header';
|
||||
import Listing from 'core-components/listing';
|
||||
import Loading from 'core-components/loading';
|
||||
|
||||
class AdminPanelCustomResponses extends React.Component {
|
||||
static defaultProps = {
|
||||
items: []
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
if(!this.props.loaded) {
|
||||
this.props.dispatch(AdminDataActions.retrieveCustomResponses());
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
|
@ -41,10 +52,23 @@ class AdminPanelCustomResponses extends React.Component {
|
|||
getListingProps() {
|
||||
return {
|
||||
title: 'Custom Responses',
|
||||
items: [{content: 'Connection issue'}, {content: 'Change existent name'}, {content: 'Connection issue'}],
|
||||
items: this.getItems(),
|
||||
enableAddNew: true
|
||||
};
|
||||
}
|
||||
|
||||
getItems() {
|
||||
return this.props.items.map((item) => {
|
||||
return {
|
||||
content: item.name
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default AdminPanelCustomResponses;
|
||||
export default connect((store) => {
|
||||
return {
|
||||
loaded: store.adminData.customResponsesLoaded,
|
||||
items: store.adminData.customResponses
|
||||
};
|
||||
})(AdminPanelCustomResponses);
|
||||
|
|
|
@ -31,5 +31,21 @@ module.exports = [
|
|||
data: {}
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/ticket/get-custom-responses',
|
||||
time: 1000,
|
||||
response: function () {
|
||||
return {
|
||||
status: 'success',
|
||||
data: [
|
||||
{name: 'Common issue #1', language: 'en', content: 'some content'},
|
||||
{name: 'Common issue #2', language: 'en', content: 'some content'},
|
||||
{name: 'Common issue #3', language: 'en', content: 'some content'},
|
||||
{name: 'Häufiges Problem #1', language: 'de', content: 'einige Inhalte'},
|
||||
{name: 'Häufiges Problem #2', language: 'de', content: 'einige Inhalte'}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
];
|
|
@ -4,10 +4,12 @@ import { routerReducer } from 'react-router-redux';
|
|||
import sessionReducer from 'reducers/session-reducer';
|
||||
import configReducer from 'reducers/config-reducer';
|
||||
import modalReducer from 'reducers/modal-reducer';
|
||||
import adminDataReducer from 'reducers/admin-data-reducer';
|
||||
|
||||
export default combineReducers({
|
||||
session: sessionReducer,
|
||||
config: configReducer,
|
||||
modal: modalReducer,
|
||||
adminData: adminDataReducer,
|
||||
routing: routerReducer
|
||||
});
|
|
@ -0,0 +1,31 @@
|
|||
import _ from 'lodash';
|
||||
|
||||
import Reducer from 'reducers/reducer';
|
||||
//import sessionStore from 'lib-app/session-store';
|
||||
|
||||
class AdminDataReducer extends Reducer {
|
||||
|
||||
getInitialState() {
|
||||
return {
|
||||
customResponses: [],
|
||||
customResponsesLoaded: false
|
||||
};
|
||||
}
|
||||
|
||||
getTypeHandlers() {
|
||||
return {
|
||||
'CUSTOM_RESPONSES_FULFILLED': this.onCustomResponses
|
||||
};
|
||||
}
|
||||
|
||||
onCustomResponses(state, payload) {
|
||||
//sessionStore.setItem('language', payload);
|
||||
|
||||
return _.extend({}, state, {
|
||||
customResponses: payload.data,
|
||||
customResponsesLoaded: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default AdminDataReducer.getInstance();
|
Loading…
Reference in New Issue