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

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

const edoReducer = (state = initialState.edo, action) => 
{
	switch (action.type) 
	{
		case actionTypes.EDO_LOADED: 
		{
			return {
				...state, 
				loaded: action.data.loaded, 
			};
		}

		case actionTypes.EDO_OPERATORS_LIST: 
		{
			console.log("actionTypes.EDO_OPERATORS_LIST", actionTypes.EDO_OPERATORS_LIST, { action });
			console.log({
				...state, 
				operators: action.data.operators, 
				message: action.data.message, 
			});

			return {
				...state, 
				operators: action.data.operators, 
				message: action.data.message, 
			};
		}

		case actionTypes.EDO_INVITES_LIST: 
		{
			console.log("actionTypes.EDO_INVITES_LIST", actionTypes.EDO_INVITES_LIST, { action });
			console.log({
				...state, 
				invites: action.data.invites, 
			});

			return {
				...state, 
				invites: action.data.invites, 
			};
		}

		case actionTypes.EDO_RESET: 
		{
			return {
				loaded: false, 
				operators: null, 
				invites: null, 
			};
		}

		default: {
			return state;
		}
	}
};

export default edoReducer;