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

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

    default: {
      return state;
    }
  }
}
