Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3452 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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