| Línea 10... |
Línea 10... |
| 10 |
|
10 |
|
| 11 |
import { useDispatch } from 'react-redux';
|
11 |
import { useDispatch } from 'react-redux';
|
| Línea 12... |
Línea 12... |
| 12 |
import { addNotification } from '../redux/notification/notification.actions';
|
12 |
import { addNotification } from '../redux/notification/notification.actions';
|
| 13 |
|
- |
|
| 14 |
const Notifications = ({ backendVars }) => {
|
13 |
|
| 15 |
|
14 |
const Notifications = ({ backendVars }) => {
|
| 16 |
const { image, fullName, country, visits, connections, description } = backendVars
|
15 |
const { image, fullName, country, visits, connections, description } = backendVars
|
| 17 |
const [notifications, setNotifications] = useState([])
|
16 |
const [notifications, setNotifications] = useState([])
|
| 18 |
const [displayOption, setDisplayOption] = useState(false)
|
17 |
const [displayOption, setDisplayOption] = useState(false)
|
| Línea 62... |
Línea 61... |
| 62 |
.catch(err => dispatch(addNotification({ style: "danger", msg: `Error: ${err}` })))
|
61 |
.catch(err => dispatch(addNotification({ style: "danger", msg: `Error: ${err}` })))
|
| 63 |
}
|
62 |
}
|
| Línea 64... |
Línea 63... |
| 64 |
|
63 |
|
| 65 |
const deleteNotification = (url) => {
|
64 |
const deleteNotification = (url) => {
|
| 66 |
axios.post(url)
|
65 |
axios.post(url)
|
| 67 |
.then(({ data }) => {
|
66 |
.then(({ data: response }) => {
|
| 68 |
if (!data.success) {
|
67 |
if (!response.success) {
|
| 69 |
return dispatch(addNotification({ style: 'danger', msg: data.data }))
|
68 |
return dispatch(addNotification({ style: 'danger', msg: response.data }))
|
| 70 |
}
|
69 |
}
|
| 71 |
dispatch(addNotification({ style: 'success', msg: data.data }))
|
70 |
dispatch(addNotification({ style: 'success', msg: response.data }))
|
| 72 |
setNotifications((prevNotifications) => prevNotifications.filter((notification) => notification.link_delete === url))
|
71 |
setNotifications((prevNotifications) => prevNotifications.filter((notification) => notification.link_delete !== url))
|
| 73 |
})
|
72 |
})
|
| 74 |
.catch(err => dispatch(addNotification({ style: "danger", msg: `Error: ${err}` })))
|
73 |
.catch(err => dispatch(addNotification({ style: "danger", msg: `Error: ${err}` })))
|
| Línea 75... |
Línea 74... |
| 75 |
}
|
74 |
}
|
| Línea 138... |
Línea 137... |
| 138 |
<div className="notification-item">
|
137 |
<div className="notification-item">
|
| 139 |
<div className="d-flex align-items-center justify-content-between" style={{ gap: '.5rem' }}>
|
138 |
<div className="d-flex align-items-center justify-content-between" style={{ gap: '.5rem' }}>
|
| 140 |
<a href={element.link}>
|
139 |
<a href={element.link}>
|
| 141 |
{element.message}
|
140 |
{element.message}
|
| 142 |
</a>
|
141 |
</a>
|
| 143 |
<DeleteOutline onClick={() => deleteNotification(element.link_delete)} />
|
142 |
<DeleteOutline className='cursor-pointer' onClick={() => deleteNotification(element.link_delete)} />
|
| 144 |
</div>
|
143 |
</div>
|
| 145 |
<span>
|
144 |
<span>
|
| 146 |
{element.time_elapsed}
|
145 |
{element.time_elapsed}
|
| 147 |
</span>
|
146 |
</span>
|
| 148 |
</div>
|
147 |
</div>
|