Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 1437 Rev 3432
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";
6
import { addNotification } from '../../redux/notification/notification.actions'
6
import { addNotification } from "../../redux/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";
Línea 9... Línea 9...
9
 
9
 
10
const EventModal = ({ event, show, onClose }) => {
10
const EventModal = ({ event, show, onClose }) => {
Línea 11... Línea 11...
11
  const dispatch = useDispatch()
11
  const dispatch = useDispatch();
12
 
12
 
Línea 13... Línea 13...
13
  const getBackendVarUrl = (url = '') => {
13
  const getBackendVarUrl = (url = "") => {
14
    if (!url) return
14
    if (!url) return;
15
 
15
 
16
    axios
16
    axios
Línea 17... Línea 17...
17
      .get(url)
17
      .get(url)
18
      .then(({ data: responseData }) => {
18
      .then((response) => {
19
        const { data, success } = responseData
19
        const { data, success } = response.data;
20
 
20
 
21
        if (!success) {
21
        if (!success) {
22
          const errorMessage =
22
          const errorMessage =
23
            typeof data === 'string'
23
            typeof data === "string"
Línea 24... Línea 24...
24
              ? data
24
              ? data
25
              : 'Error interno. Por favor, intente más tarde.'
25
              : "Error interno. Por favor, intente más tarde.";
26
          throw new Error(errorMessage)
26
          throw new Error(errorMessage);
27
        }
27
        }
28
 
28
 
29
        window.open(data, '_blank')
29
        window.open(data, "_blank");
Línea 30... Línea 30...
30
      })
30
      })
31
      .catch((err) => {
31
      .catch((err) => {
32
        dispatch(addNotification({ style: 'danger', message: err.message }))
32
        dispatch(addNotification({ style: "danger", message: err.message }));
33
      })
33
      });
34
  }
34
  };
35
 
35
 
36
  return (
36
  return (
37
    <Modal title={event?.title} show={show} onClose={onClose}>
37
    <Modal title={event?.title} show={show} onClose={onClose}>
38
      <Box
38
      <Box
39
        sx={{ cursor: event?.ur ? 'pointer' : 'default' }}
39
        sx={{ cursor: event?.ur ? "pointer" : "default" }}
40
        onClick={() => getBackendVarUrl(event?.url)}
40
        onClick={() => getBackendVarUrl(event?.url)}
Línea 41... Línea 41...
41
      >
41
      >