export function reducer()

in src/app/loans/products/store/charges/charges.reducer.ts [37:66]


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

  switch (action.type) {

    case charge.LOAD_ALL: {
      return initialState;
    }

    case charge.LOAD_ALL_COMPLETE: {
      const chargeDefinitions: ChargeDefinition[] = action.payload;

      const ids = chargeDefinitions.map(chargeDefinition => chargeDefinition.identifier);

      const entities = resourcesToHash(chargeDefinitions);

      const loadedAt = idsToHashWithCurrentTimestamp(ids);

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

    default: {
      return state;
    }
  }
}