Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3432 Rev 3719
Línea 1... Línea 1...
1
import React from "react";
1
import React from 'react';
2
import { useDispatch } from "react-redux";
2
import { useDispatch } from 'react-redux';
3
import parse from "html-react-parser";
3
import parse from 'html-react-parser';
4
 
4
 
5
import { axios } from "utils/index";
5
import { axios } from '@utils/index.js';
6
import { addNotification } from "../../redux/notification/notification.actions";
6
import { addNotification } from '@store/notification/notification.actions';
7
import Modal from "components/UI/modal/Modal";
7
import Modal from '@components/UI/modal/modal';
8
import { Box } from "@mui/material";
8
import { Box } from '@mui/material';
9
 
9
 
10
const EventModal = ({ event, show, onClose }) => {
10
const EventModal = ({ event, show, onClose }) => {
11
  const dispatch = useDispatch();
11
  const dispatch = useDispatch();
12
 
12
 
13
  const getBackendVarUrl = (url = "") => {
13
  const getBackendVarUrl = (url = '') => {
14
    if (!url) return;
14
    if (!url) return;
15
 
15
 
16
    axios
16
    axios
17
      .get(url)
17
      .get(url)
18
      .then((response) => {
18
      .then((response) => {
19
        const { data, success } = response.data;
19
        const { data, success } = response.data;
20
 
20
 
21
        if (!success) {
21
        if (!success) {
22
          const errorMessage =
22
          const errorMessage =
23
            typeof data === "string"
-
 
24
              ? data
-
 
25
              : "Error interno. Por favor, intente más tarde.";
23
            typeof data === 'string' ? data : 'Error interno. Por favor, intente más tarde.';
26
          throw new Error(errorMessage);
24
          throw new Error(errorMessage);
27
        }
25
        }
28
 
26
 
29
        window.open(data, "_blank");
27
        window.open(data, '_blank');
30
      })
28
      })
31
      .catch((err) => {
29
      .catch((err) => {
32
        dispatch(addNotification({ style: "danger", message: err.message }));
30
        dispatch(addNotification({ style: 'danger', message: err.message }));
33
      });
31
      });
34
  };
32
  };
35
 
33
 
36
  return (
34
  return (
37
    <Modal title={event?.title} show={show} onClose={onClose}>
35
    <Modal title={event?.title} show={show} onClose={onClose}>
38
      <Box
36
      <Box
39
        sx={{ cursor: event?.ur ? "pointer" : "default" }}
37
        sx={{ cursor: event?.ur ? 'pointer' : 'default' }}
40
        onClick={() => getBackendVarUrl(event?.url)}
38
        onClick={() => getBackendVarUrl(event?.url)}
41
      >
39
      >
42
        {event?.agenda && parse(event?.agenda)}
40
        {event?.agenda && parse(event?.agenda)}
43
      </Box>
41
      </Box>
44
    </Modal>
42
    </Modal>
45
  );
43
  );
46
};
44
};
47
 
45
 
48
export default EventModal;
46
export default EventModal;