- Linting... Prettier...

This commit is contained in:
2019-08-07 01:59:10 -04:00
parent 3dc8589fb4
commit 847c9b192a
102 changed files with 2161 additions and 2109 deletions

View File

@@ -1,36 +1,31 @@
import { List } from 'immutable';
import { blockUI, unblockUI } from './index.js';
import { fetchEvents as fetchEventsApi } from '../api/events.js';
import {
EVENTS_LOAD_FAILED,
EVENTS_LOADED,
GET_EVENTS,
} from '../constants/actionTypes.js';
import { EVENTS_LOAD_FAILED, EVENTS_LOADED, GET_EVENTS } from '../constants/actionTypes.js';
import Event from '../domain/Event.js';
import { getAuthToken } from '../selectors/auth.js';
const beginFetchEvents = () => ({ type: GET_EVENTS });
const eventsLoaded = (payload) => ({ type: EVENTS_LOADED, payload });
const eventsLoadError = (payload) => ({ type: EVENTS_LOAD_FAILED, payload });
const eventsFetchSuccess = (items) => (dispatch) => {
const payload = List(items).map((i) => Event.fromJS(i));
dispatch(eventsLoaded(payload));
dispatch(unblockUI);
const payload = List(items).map((i) => Event.fromJS(i));
dispatch(eventsLoaded(payload));
};
const eventsFetchFailure = (error) => (dispatch) => {
console.error('[actions::events::eventsFetchFailure]', error);
dispatch(eventsLoadError(error));
dispatch(unblockUI);
console.error('[actions::events::eventsFetchFailure]', error);
dispatch(eventsLoadError(error));
};
export const fetchEvents = () => (dispatch, getState) => {
const authToken = getAuthToken(getState());
const authToken = getAuthToken(getState());
fetchEventsApi(authToken)
.then(payload => dispatch(eventsFetchSuccess(payload)))
.catch(err => dispatch(eventsFetchFailure(err)));
dispatch(beginFetchEvents());
fetchEventsApi(authToken)
.then((payload) => dispatch(eventsFetchSuccess(payload)))
.catch((err) => dispatch(eventsFetchFailure(err)));
};