- Linting... Prettier...
This commit is contained in:
@@ -1,39 +1,27 @@
|
||||
import { List } from 'immutable';
|
||||
|
||||
import { getEndpointUrl } from '../api/index.js';
|
||||
|
||||
import {
|
||||
AUCTIONS_UPDATED,
|
||||
ITEMS_LOADED,
|
||||
} from '../constants/actionTypes.js';
|
||||
|
||||
import { blockUI, unblockUI } from './index.js';
|
||||
import { API_ENDPOINTS } from '../constants/constants.js';
|
||||
import { fetchAuctionStatus as fetchActionStatusApi } from '../api/actionStatus.js';
|
||||
import { AUCTIONS_UPDATED } from '../constants/actionTypes.js';
|
||||
import { getActiveEventId } from '../selectors/activeEvent.js';
|
||||
import { getAuthToken } from '../selectors/auth.js';
|
||||
|
||||
import Auction from '../domain/Auction.js';
|
||||
|
||||
const auctionsUpdated = (payload) => ({
|
||||
type: AUCTIONS_UPDATED,
|
||||
payload,
|
||||
});
|
||||
|
||||
const autionStatusLoadSuccess = (auctions, dispatch) => {
|
||||
const payload = List(auctions).map((i) => Auction.fromJS(i));
|
||||
dispatch({ type: AUCTIONS_UPDATED, payload });
|
||||
dispatch(unblockUI);
|
||||
const autionStatusLoadSuccess = (auctions) => (dispatch) => {
|
||||
const payload = List(auctions).map((i) => Auction.fromJS(i));
|
||||
dispatch(auctionsUpdated(payload));
|
||||
};
|
||||
|
||||
export const fetchAuctionStatus = () => (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const activeEvent = state.get('activeEvent');
|
||||
const authToken = getAuthToken(getState());
|
||||
const eventId = getActiveEventId(getState());
|
||||
|
||||
let apiUrl = getEndpointUrl(API_ENDPOINTS.GET_STATUS);
|
||||
apiUrl = apiUrl.replace(/:event_id$/, '');
|
||||
if (activeEvent) {
|
||||
apiUrl = `${apiUrl}${activeEvent}`;
|
||||
}
|
||||
|
||||
dispatch(blockUI());
|
||||
|
||||
return fetch(apiUrl)
|
||||
.then(response => response.json())
|
||||
.then(payload => autionStatusLoadSuccess(payload, dispatch))
|
||||
.catch(err => console.error('[actions::getStatus]', err));
|
||||
return fetchActionStatusApi(eventId, authToken)
|
||||
.then((payload) => dispatch(autionStatusLoadSuccess(payload)))
|
||||
.catch((err) => console.error('[actions::getStatus]', err));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user