import { ActionType, Actions } from './meta-probe-architecture.action';
import {
  State,
  initialState,
  metaProbeArchitectureEntityAdapter,
} from './meta-probe-architecture.state';

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

    default: {
      return state;
    }
  }
}
