Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3545 | Rev 3610 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3545 Rev 3546
Línea 13... Línea 13...
13
  const [show, setShow] = useState(false);
13
  const [show, setShow] = useState(false);
14
  const [message, setMessage] = useState('');
14
  const [message, setMessage] = useState('');
15
  const [onConfirm, setOnConfirm] = useState(() => {});
15
  const [onConfirm, setOnConfirm] = useState(() => {});
16
  const [onCancel, setOnCancel] = useState(() => {});
16
  const [onCancel, setOnCancel] = useState(() => {});
Línea 17... Línea 17...
17
 
17
 
18
  const showAlert = useCallback(({ message = '', onConfirm = () => {}, onCancel = () => {} }) => {
18
  const showAlert = useCallback(({ message = '', onConfirm = () => {}, onCancel }) => {
19
    try {
19
    try {
20
      setMessage(message);
20
      setMessage(message);
21
      setOnConfirm(() => onConfirm);
21
      setOnConfirm(() => onConfirm);
22
      setOnCancel(() => onCancel);
22
      setOnCancel(() => (onCancel ? onCancel : closeAlert));
23
      setShow(true);
23
      setShow(true);
24
    } catch (error) {
24
    } catch (error) {
25
      console.error('Error showing alert:', error);
25
      console.error('Error showing alert:', error);
26
      setShow(false);
26
      setShow(false);
Línea 41... Línea 41...
41
        show,
41
        show,
42
        message,
42
        message,
43
        showAlert,
43
        showAlert,
44
        closeAlert,
44
        closeAlert,
45
        onConfirm,
45
        onConfirm,
46
        onCancel: onCancel || closeAlert
46
        onCancel
47
      }}
47
      }}
48
    >
48
    >
49
      {children}
49
      {children}
50
    </AlertModalContext.Provider>
50
    </AlertModalContext.Provider>
51
  );
51
  );