import { createSelector } from 'reselect';
import shallowVaccines from './vaccines';

const shallowVaccinations = (state) => state.get('vaccinations');

export default createSelector(
  [shallowVaccinations, shallowVaccines],
  (vaccinations, vaccines) => {
    return vaccinations.map((vaccination, id) => {
      return vaccination
        .set('vaccine', vaccines.get(vaccination.get('id')))
        .set('listId', id);
    });
  }
);

import { createSelector } from 'reselect';
import shallowVaccines from './vaccines';
import { Map } from 'immutable';

const shallowVaccinations = (state) => state.get('vaccinations');

export default createSelector(
  [shallowVaccinations, shallowVaccines],
  (vaccinations, vaccines) => {
    if (!vaccinations) return Map();
    return vaccinations.map((vaccination, id) => {
      return vaccination
        .set('vaccine', vaccines.get(vaccination.get('id')))
        .set('listId', id);
    });
  }
);

fix selector for case when no vaccinations exists