Proyectos de Subversion LeadersLinked - SPA

Rev

Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import { useCallback } from 'react';
import { useDispatch } from 'react-redux';

import { addNotification } from '@store/notification/notification.actions';

export function useAlert() {
  const dispatch = useDispatch();

  const showSuccess = useCallback(
    (message) => {
      dispatch(addNotification({ style: 'success', msg: message }));
    },
    [dispatch]
  );

  const showError = useCallback(
    (message) => {
      dispatch(addNotification({ style: 'danger', msg: message }));
    },
    [dispatch]
  );

  return {
    showSuccess,
    showError
  };
}