import { ActionType, Actions } from './meta-sensor-status.action';
import {
  State,
  initialState,
  metaSensorStatusEntityAdapter,
} from './meta-sensor-status.state';

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

    default: {
      return state;
    }
  }
}
