2017-05-16 13:34:00 +02:00
|
|
|
import axios from 'axios';
|
|
|
|
import {apiError} from 'components/errors/actions'
|
2017-05-23 15:52:19 +02:00
|
|
|
import {loadRejectReasonsSuccess,
|
|
|
|
loadNoExportReasonsSuccess}
|
|
|
|
from 'components/routeservers/large-communities/actions';
|
2017-05-16 13:34:00 +02:00
|
|
|
|
|
|
|
export const LOAD_CONFIG_SUCCESS = "@birdseye/LOAD_CONFIG_SUCCESS";
|
|
|
|
|
2017-07-04 12:37:16 +02:00
|
|
|
function loadConfigSuccess(config) {
|
2017-05-16 13:34:00 +02:00
|
|
|
return {
|
|
|
|
type: LOAD_CONFIG_SUCCESS,
|
2017-07-04 12:37:16 +02:00
|
|
|
payload: config
|
|
|
|
};
|
2017-05-16 13:34:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function loadConfig() {
|
|
|
|
return (dispatch) => {
|
2017-05-22 15:17:40 +02:00
|
|
|
axios.get(`/api/config`)
|
2017-05-16 13:34:00 +02:00
|
|
|
.then(({data}) => {
|
|
|
|
dispatch(
|
2017-05-22 16:44:30 +02:00
|
|
|
loadRejectReasonsSuccess(data.rejection.asn,
|
|
|
|
data.rejection.reject_id,
|
|
|
|
data.reject_reasons)
|
2017-05-16 13:34:00 +02:00
|
|
|
);
|
2017-05-23 15:52:19 +02:00
|
|
|
dispatch(
|
|
|
|
loadNoExportReasonsSuccess(
|
2017-05-23 16:08:43 +02:00
|
|
|
data.noexport.asn,
|
|
|
|
data.noexport.noexport_id,
|
|
|
|
data.noexport_reasons)
|
2017-05-23 15:52:19 +02:00
|
|
|
);
|
2017-07-04 12:37:16 +02:00
|
|
|
dispatch(loadConfigSuccess(data));
|
2017-05-16 13:34:00 +02:00
|
|
|
})
|
|
|
|
.catch(error => dispatch(apiError(error)));
|
|
|
|
}
|
|
|
|
}
|