Rev 3432 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React from 'react';
import { useDispatch } from 'react-redux';
import parse from 'html-react-parser';
import { axios } from '@utils/index.js';
import { addNotification } from '@store/notification/notification.actions';
import Modal from '@components/UI/modal/modal';
import { Box } from '@mui/material';
const EventModal = ({ event, show, onClose }) => {
const dispatch = useDispatch();
const getBackendVarUrl = (url = '') => {
if (!url) return;
axios
.get(url)
.then((response) => {
const { data, success } = response.data;
if (!success) {
const errorMessage =
typeof data === 'string' ? data : 'Error interno. Por favor, intente más tarde.';
throw new Error(errorMessage);
}
window.open(data, '_blank');
})
.catch((err) => {
dispatch(addNotification({ style: 'danger', message: err.message }));
});
};
return (
<Modal title={event?.title} show={show} onClose={onClose}>
<Box
sx={{ cursor: event?.ur ? 'pointer' : 'default' }}
onClick={() => getBackendVarUrl(event?.url)}
>
{event?.agenda && parse(event?.agenda)}
</Box>
</Modal>
);
};
export default EventModal;