import { actionTypes as asyncDataFetchActionTypes } from '@bufferapp/async-data-fetch';
import keyWrapper from '@bufferapp/keywrapper';
export const actionTypes = keyWrapper('REPORTS', {
FETCH: 'FETCH',
});
const initialState = {
reports: [],
};
export default (state = initialState, action) => {
switch (action.type) {
case `list_reports_${asyncDataFetchActionTypes.FETCH_SUCCESS}`:
return {
...state,
reports: action.result,
};
case `list_reports_${asyncDataFetchActionTypes.FETCH_FAIL}`:
return {
...state,
hasError: true,
};
default:
return state;
}
};
export const actions = {
fetch: () => ({
type: actionTypes.FETCH,
}),
};
|