text: import uuid from 'uuid';
  import { SET_ALERT, REMOVE_ALERT } from './types';
  
  export const setAlert = (msg, alertType, timeout = 2000) => dispatch => {
    //alert will have id, msg, and alert type
    //randomly generated with uuid
    const id = uuid.v4();
    dispatch({
      type: SET_ALERT,
      payload: {
        msg,
        alertType,
        id
      }
    });
  
    //remove alert after 2 secs
    setTimeout(
      () =>
        dispatch({
          type: REMOVE_ALERT,
          payload: id
        }),
      timeout
    );
  };
  