Newer
Older
dmpopidor / lib / assets / javascripts / utils / notificationHelper.js
@Brian Riley Brian Riley on 12 Oct 2017 1010 bytes Added ajax to share plan page
import { isString, isObject } from './isType';
/*
  Helpers that will display the specified message in in the notification
  area at the top of the page
*/
export const renderNotice = (msg) => {
  const notificationArea = $('#notification-area');

  if (isString(msg) && isObject(notificationArea)) {
    notificationArea.removeClass('alert-warning').addClass('alert-info');
    notificationArea.find('i, span').remove();
    notificationArea.append(`
      <i class="fa fa-check-circle" aria-hidden="true"></i><span>${msg}</span>`);
    notificationArea.removeClass('hide');
  }
};

export const renderAlert = (msg) => {
  const notificationArea = $('#notification-area');

  if (isString(msg) && isObject(notificationArea)) {
    notificationArea.removeClass('alert-info').addClass('alert-warning');
    notificationArea.find('i, span').remove();
    notificationArea.append(`
      <i class="fa fa-times-circle" aria-hidden="true"></i><span>${msg}</span>`);
    notificationArea.removeClass('hide');
  }
};