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) => {
|
2020-04-14 11:44:40 -07:00
|
|
|
api(getState).get('/patron/v1/funding').then(response => {
|
2020-03-31 15:45:12 -07:00
|
|
|
dispatch(importFetchedFunding(response.data));
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch(fetchFundingFail(error));
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export function importFetchedFunding(funding) {
|
|
|
|
return {
|
|
|
|
type: PATRON_FUNDING_IMPORT,
|
2020-04-14 11:44:40 -07:00
|
|
|
funding,
|
2020-03-31 15:45:12 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function fetchFundingFail(error) {
|
|
|
|
return {
|
|
|
|
type: PATRON_FUNDING_FETCH_FAIL,
|
|
|
|
error,
|
|
|
|
skipAlert: true,
|
|
|
|
};
|
|
|
|
};
|