import Action from '../../types/Store/Actions';
import { Service } from '@/api/home';

const INITIAL_STATE: Service[] = [];
export type ServiceState = StoreState<{ list: Service[] }>;

export const updateServiceList = (entity: Service[]): Action => ({
  type: 'UPDATE_SERVICE_LIST',
  payload: entity,
});

export default function serviceList(
  state: Service[] = INITIAL_STATE,
  actions: Action,
): Service[] {
  switch (actions.type) {
    case 'UPDATE_SERVICE_LIST':
      return actions.payload;
    default:
      return state;
  }
}
