Proyectos de Subversion LeadersLinked - SPA

Rev

Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3452 stevensc 1
import { useCallback } from 'react';
2
import { useDispatch } from 'react-redux';
3
 
4
import { addNotification } from '@store/notification/notification.actions';
5
 
6
export function useAlert() {
7
  const dispatch = useDispatch();
8
 
9
  const showSuccess = useCallback(
10
    (message) => {
11
      dispatch(addNotification({ style: 'success', msg: message }));
12
    },
13
    [dispatch]
14
  );
15
 
16
  const showError = useCallback(
17
    (message) => {
18
      dispatch(addNotification({ style: 'danger', msg: message }));
19
    },
20
    [dispatch]
21
  );
22
 
23
  return {
24
    showSuccess,
25
    showError
26
  };
27
}