Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4232 Rev 4633
Línea 1... Línea 1...
1
/* eslint-disable react/prop-types */
1
/* eslint-disable react/prop-types */
2
import React, { useState, useLayoutEffect, useRef } from 'react';
2
import React, { useState, useLayoutEffect, useRef } from 'react';
3
import { axios } from '../utils';
-
 
4
import { BiDotsVerticalRounded } from 'react-icons/bi';
3
import { BiDotsVerticalRounded } from 'react-icons/bi';
-
 
4
import DeleteOutline from '@mui/icons-material/DeleteOutline'
-
 
5
import { axios } from '../utils';
Línea 5... Línea 6...
5
 
6
 
6
import ProfileInfo from '../dashboard/components/home-section/ProfileInfo';
7
import ProfileInfo from '../dashboard/components/home-section/ProfileInfo';
7
import SocialNetworks from '../dashboard/components/home-section/SocialNetworks';
8
import SocialNetworks from '../dashboard/components/home-section/SocialNetworks';
Línea 59... Línea 60...
59
        setNotifications([])
60
        setNotifications([])
60
      })
61
      })
61
      .catch(err => dispatch(addNotification({ style: "danger", msg: `Error: ${err}` })))
62
      .catch(err => dispatch(addNotification({ style: "danger", msg: `Error: ${err}` })))
62
  }
63
  }
Línea -... Línea 64...
-
 
64
 
-
 
65
  const deleteNotification = (url) => {
-
 
66
    axios.post(url)
-
 
67
      .then(({ data }) => {
-
 
68
        if (!data.success) {
-
 
69
          return dispatch(addNotification({ style: 'danger', msg: data.data }))
-
 
70
        }
-
 
71
        dispatch(addNotification({ style: 'success', msg: data.data }))
-
 
72
        setNotifications((prevNotifications) => prevNotifications.filter((notification) => notification.link_delete === url))
-
 
73
      })
-
 
74
      .catch(err => dispatch(addNotification({ style: "danger", msg: `Error: ${err}` })))
-
 
75
  }
63
 
76
 
64
  useLayoutEffect(() => {
77
  useLayoutEffect(() => {
65
    const handleClickOutside = (event) => {
78
    const handleClickOutside = (event) => {
66
      if (menuOptions.current && !menuOptions.current.contains(event.target)) {
79
      if (menuOptions.current && !menuOptions.current.contains(event.target)) {
67
        setDisplayOption(false)
80
        setDisplayOption(false)
Línea 121... Línea 134...
121
            <ul>
134
            <ul>
122
              {notifications.length
135
              {notifications.length
123
                ? [...notifications].reverse().map((element, index) =>
136
                ? [...notifications].reverse().map((element, index) =>
124
                  <li key={index}>
137
                  <li key={index}>
125
                    <div className="notification-item">
138
                    <div className="notification-item">
-
 
139
                      <div className="d-flex align-items-center justify-content-center" style={{ gap: '.5rem' }}>
126
                      <a href={element.link}>
140
                        <a href={element.link}>
127
                        {element.message}
141
                          {element.message}
128
                      </a>
142
                        </a>
-
 
143
                        <DeleteOutline onClick={() => deleteNotification(element.link_delete)} />
-
 
144
                      </div>
129
                      <span>
145
                      <span>
130
                        {element.time_elapsed}
146
                        {element.time_elapsed}
131
                      </span>
147
                      </span>
132
                    </div>
148
                    </div>
133
                  </li>
149
                  </li>