1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/frontend/src/store/application/actions.js

35 lines
994 B
JavaScript
Raw Normal View History

2016-12-03 15:54:15 +01:00
import api from '../../data/applications-api';
2016-12-05 15:15:01 +01:00
export const RECEIVE_ALL_APPLICATIONS = 'RECEIVE_ALL_APPLICATIONS';
export const ERROR_RECEIVE_ALL_APPLICATIONS = 'ERROR_RECEIVE_ALL_APPLICATIONS';
2016-12-03 15:54:15 +01:00
2016-12-05 15:15:01 +01:00
export const RECEIVE_APPLICATION = 'RECEIVE_APPLICATION';
const recieveAllApplications = (json) => ({
type: RECEIVE_ALL_APPLICATIONS,
value: json,
});
const recieveApplication = (json) => ({
type: RECEIVE_APPLICATION,
2016-12-03 15:54:15 +01:00
value: json,
});
const errorReceiveApplications = (statusCode) => ({
2016-12-05 15:15:01 +01:00
type: ERROR_RECEIVE_ALL_APPLICATIONS,
2016-12-03 15:54:15 +01:00
statusCode,
});
2016-12-05 15:15:01 +01:00
export function fetchAll () {
2016-12-03 15:54:15 +01:00
return dispatch => api.fetchAll()
2016-12-05 15:15:01 +01:00
.then(json => dispatch(recieveAllApplications(json)))
2016-12-03 15:54:15 +01:00
.catch(error => dispatch(errorReceiveApplications(error)));
}
2016-12-05 15:15:01 +01:00
export function fetchApplication (appName) {
return dispatch => api.fetchApplication(appName)
.then(json => dispatch(recieveApplication(json)))
.catch(error => dispatch(errorReceiveApplications(error)));
}