import { ActionType, Actions } from './meta-infra-type.action';
import {
  State,
  initialState,
  metaInfraTypeEntityAdapter,
} from './meta-infra-type.state';

export function reducer(state: State = initialState, action: Actions): State {
  switch (action.type) {
    case ActionType.ReadAll: {
      return {
        ...state,
      };
    }
    case ActionType.ReadAllSuccess: {
      return metaInfraTypeEntityAdapter.setAll(action.payload, state);
    }
    case ActionType.ReadAllFailure: {
      return metaInfraTypeEntityAdapter.setError(action.payload, state);
    }

    default: {
      return state;
    }
  }
}
