import { INITIAL_CUSTOMERS_STATE, customersStateAdapter, CustomersState } from './customers.state';
import * as actions from './customers.actions';
import { createReducer, on, Action } from '@ngrx/store';

export const _customersReducer = createReducer(
  INITIAL_CUSTOMERS_STATE,
  on(actions.addCustomer, (s, a) => customersStateAdapter.addOne(a.customer, s))
);

export function customersReducer(state: CustomersState, action: Action) {
  return _customersReducer(state, action);
}
