import { HYDRATE } from 'next-redux-wrapper';

import * as actionTypes from '../constants/actionTypes';
import initialState from "./initialState";

const eventsReducer = (state = initialState.events, action) => 
{
	switch (action.type) 
	{
		case actionTypes.EVENTS: 
		{
			return {
				...state, 
				...action.data, 
			};
		}

		case actionTypes.EVENTS_FILTERED: 
		{
			return {
				...state, 
				...action.data, 
			};
		}

		case actionTypes.EVENTS_RESET: 
		{
			return {
				themes: null, 
				searched: null, 
				appeals: { list: null, new: 0 }, 
				appeal: null, 
				request: null, 
			};
		}

		default: {
			return state;
		}
	}
};

export default eventsReducer;