Rev 7305 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React from 'react'
import { Modal } from 'react-bootstrap'
import parse from 'html-react-parser'
import { axios } from '../../utils'
import { addNotification } from '../../redux/notification/notification.actions'
import { useDispatch } from 'react-redux'
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) {
dispatch(
addNotification({
style: 'danger',
msg: 'Error interno. Por favor, intente más tarde.',
})
)
return
}
window.open(data, '_blank')
})
.catch((error) => {
dispatch(
addNotification({ style: 'danger', message: 'Ha ocurrido un error' })
)
throw new Error(error)
})
}
return (
<Modal show={show} onHide={onClose}>
<Modal.Header className="pb-0" closeButton>
<Modal.Title>{event?.title}</Modal.Title>
</Modal.Header>
<Modal.Body>
<div
className={event?.url && 'cursor-pointer'}
onClick={() => getBackendVarUrl(event?.url)}
>
{event && parse(event?.agenda)}
</div>
</Modal.Body>
</Modal>
)
}
export default EventModal