import { ActionType, Actions } from './meta-vendor-crawler-sensor-item.action';
import {
  State,
  initialState,
  metaVendorCrawlerSensorItemEntityAdapter,
} from './meta-vendor-crawler-sensor-item.state';

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

    default: {
      return state;
    }
  }
}
