bigbuffet-rw/app/gabsocial/actions/patron.js

32 lines
737 B
JavaScript
Raw Normal View History

2020-04-01 12:40:14 -07:00
import api from '../api';
2020-03-31 15:45:12 -07:00
export const PATRON_FUNDING_IMPORT = 'PATRON_FUNDING_IMPORT';
2020-04-01 12:40:14 -07:00
export const PATRON_FUNDING_FETCH_FAIL = 'PATRON_FUNDING_FETCH_FAIL';
2020-03-31 15:45:12 -07:00
export function fetchFunding() {
return (dispatch, getState) => {
api(getState).get(`/patron/v1/funding`).then(response => {
dispatch(importFetchedFunding(response.data));
}).then(() => {
dispatch(fetchFundingSuccess());
}).catch(error => {
dispatch(fetchFundingFail(error));
});
};
};
export function importFetchedFunding(funding) {
return {
type: PATRON_FUNDING_IMPORT,
funding
};
}
export function fetchFundingFail(error) {
return {
type: PATRON_FUNDING_FETCH_FAIL,
error,
skipAlert: true,
};
};