- Initial commit

This commit is contained in:
2019-07-09 03:48:02 -04:00
commit 8ecf036cc4
105 changed files with 11254 additions and 0 deletions

29
app/actions/index.js Normal file
View File

@@ -0,0 +1,29 @@
import { getEndpointUrl } from '../api/index.js';
import {
EVENTS_LOADED,
GET_EVENTS,
GET_ITEMS,
ITEMS_LOADED,
} from '../constants/actionTypes.js';
import { API_ENDPOINTS } from '../constants/constants.js';
export const getEvents = () => (dispatch) => {
return fetch(getEndpointUrl[API_ENDPOINTS.GET_EVENTS])
.then(response => response.json())
.then(payload => {
dispatch({ type: EVENTS_LOADED, payload });
});
};
export const getItems = () => (dispatch, getState) => {
const { activeEvent } = getState();
let apiUrl = getEndpointUrl[API_ENDPOINTS.GET_ITEMS];
apiUrl = apiUrl.replace(/:event_id/, activeEvent);
return fetch(apiUrl)
.then(response => response.json())
.then(payload => {
dispatch({ type: ITEMS_LOADED, payload });
});
};