Add createFilter function
This commit is contained in:
parent
7b02e1a823
commit
32a5a31591
|
@ -4,6 +4,10 @@ export const FILTERS_FETCH_REQUEST = 'FILTERS_FETCH_REQUEST';
|
||||||
export const FILTERS_FETCH_SUCCESS = 'FILTERS_FETCH_SUCCESS';
|
export const FILTERS_FETCH_SUCCESS = 'FILTERS_FETCH_SUCCESS';
|
||||||
export const FILTERS_FETCH_FAIL = 'FILTERS_FETCH_FAIL';
|
export const FILTERS_FETCH_FAIL = 'FILTERS_FETCH_FAIL';
|
||||||
|
|
||||||
|
export const FILTERS_CREATE_REQUEST = 'FILTERS_CREATE_REQUEST';
|
||||||
|
export const FILTERS_CREATE_SUCCESS = 'FILTERS_CREATE_SUCCESS';
|
||||||
|
export const FILTERS_CREATE_FAIL = 'FILTERS_CREATE_FAIL';
|
||||||
|
|
||||||
export const fetchFilters = () => (dispatch, getState) => {
|
export const fetchFilters = () => (dispatch, getState) => {
|
||||||
if (!getState().get('me')) return;
|
if (!getState().get('me')) return;
|
||||||
|
|
||||||
|
@ -26,3 +30,14 @@ export const fetchFilters = () => (dispatch, getState) => {
|
||||||
skipAlert: true,
|
skipAlert: true,
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function createFilter(params) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
dispatch({ type: FILTERS_CREATE_REQUEST });
|
||||||
|
return api(getState).post('/api/v1/filters', params).then(response => {
|
||||||
|
dispatch({ type: FILTERS_CREATE_SUCCESS, filter: response.data });
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch({ type: FILTERS_CREATE_FAIL, error });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue