1234567891011121314151617181920212223242526272829303132333435363738 |
- import * as types from "../actionTypes/actionTypes";
- const initialState = {
- events: [],
- eventsArrShort: []
- }
- export default (state = initialState, action) => {
- switch (action.type) {
- case types.GET_REQUEST_EVENTS: {
- return state;
- }
- case types.GET_REQUEST_SUCCESS_EVENTS: {
- //console.log('events',action.payload.events);
-
- const allEvents = action.payload.events;
- const eventsArr = allEvents.map(event => ({
- title: event.title,
- id: event._id
- }));
- return {
- ...state,
- events: allEvents,
- eventsArrShort: eventsArr
- };
- }
- case types.GET_REQUEST_ERROR_EVENTS: {
- console.log('error events');
- return state;
- }
- default:
- return state;
- }
- }
|