export function reducer()

in src/app/customers/store/identityCards/identity-cards.reducer.ts [31:60]


export function reducer(state = initialState, action: identityCards.Actions): ResourceState {

  switch (action.type) {

    case identityCards.LOAD_ALL: {
      return initialState;
    }

    case identityCards.LOAD_ALL_COMPLETE: {
      const identificationCards: IdentificationCard[] = action.payload;

      const ids = identificationCards.map(identificationCard => identificationCard.number);

      const entities = resourcesToHash(identificationCards, 'number');

      const loadedAt = idsToHashWithCurrentTimestamp(ids);

      return {
        ids: [ ...ids ],
        entities: entities,
        loadedAt: loadedAt,
        selectedId: state.selectedId
      };
    }

    default: {
      return state;
    }
  }
}