text: import {
      SET_NEWSLETTER,
      FETCH_NEWSLETTER_ID
  } from '../actions/types';
  
  const INITIAL_STATE = {
      newsletter: [],
      newsletterToEdit: {}
  }
  
  export default function(state = INITIAL_STATE, action) {
      switch (action.type) {
          case SET_NEWSLETTER: 
              const newsletters = action.payload; 
              return {
                  ...state, 
                  newsletters
              }
  
          case FETCH_NEWSLETTER_ID:
              const newsletterID = action.payload;
              var newsletterToEdit = {};
              state.newsletters.map(newsletter => {
                  if(newsletter._id == newsletterID) {
                      newsletterToEdit = newsletter; 
                  }
              })
              return {
                  ...state,
                  newsletterToEdit
              }
  
          default: return state; 
      }
  }