Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 5004 Rev 5110
Línea 1... Línea 1...
1
/* eslint-disable react/prop-types */
1
/* eslint-disable react/prop-types */
2
/* eslint-disable react/jsx-key */
2
/* eslint-disable react/jsx-key */
3
import React, { useEffect, useState } from "react";
3
import React, { useEffect, useState } from 'react'
4
import axios from "../../../../utils/axios";
4
import axios from '../../../../utils/axios'
5
import { connect } from "react-redux"
5
import { connect } from 'react-redux'
6
import { HiOutlineTag } from "react-icons/hi";
6
import { HiOutlineTag } from 'react-icons/hi'
7
import { addNotification } from "../../../../redux/notification/notification.actions";
7
import { addNotification } from '../../../../redux/notification/notification.actions'
Línea 8... Línea 8...
8
 
8
 
9
const ICON_OPTIONS = [
9
const ICON_OPTIONS = [
10
  <img src="/images/icons/home.png" className="img-icon lg" />,
10
  <img src="/images/icons/home.png" className="img-icon lg" />,
11
  <img src="/images/icons/conecctions.png" className="img-icon lg" />,
11
  <img src="/images/icons/conecctions.png" className="img-icon lg" />,
12
  <img src="/images/icons/company.png" className="img-icon lg" />,
12
  <img src="/images/icons/company.png" className="img-icon lg" />,
13
  <img src="/images/icons/groups.png" className="img-icon lg" />,
13
  <img src="/images/icons/groups.png" className="img-icon lg" />,
14
  <HiOutlineTag />
14
  <HiOutlineTag />
Línea 15... Línea 15...
15
]
15
]
16
 
16
 
17
const ADD_OPTIONS = [
17
const ADD_OPTIONS = [
Línea 18... Línea 18...
18
  <i className="fa fa-calendar img-icon lg" />,
18
  <i className="fa fa-calendar img-icon lg" />
19
]
-
 
20
 
19
]
21
const NavLinks = ({ menuData, sessionLink, addNotification }) => {
20
 
22
 
21
const NavLinks = ({ menuData, sessionLink, addNotification }) => {
23
  const [menuItems, setMenuItems] = useState(menuData || [])
22
  const [menuItems, setMenuItems] = useState(menuData || [])
24
  const [aditionalItems, setAditionalItems] = useState([])
23
  const [aditionalItems, setAditionalItems] = useState([])
25
  const [notifications, setNotifications] = useState([])
24
  const [notifications, setNotifications] = useState([])
Línea 26... Línea 25...
26
  const [notificationsCount, setNotificationsCount] = useState(0)
25
  const [notificationsCount, setNotificationsCount] = useState(0)
27
  const [totalMessages, setTotalMessages] = useState(0)
26
  const [totalMessages, setTotalMessages] = useState(0)
28
  const [loading, setLoading] = useState(false);
27
  const [loading, setLoading] = useState(false)
Línea 37... Línea 36...
37
      setAditionalItems(menuData.splice(menuData.length - 5))
36
      setAditionalItems(menuData.splice(menuData.length - 5))
38
    }
37
    }
39
  }, [])
38
  }, [])
Línea 40... Línea 39...
40
 
39
 
41
  useEffect(() => {
40
  useEffect(() => {
42
    let timer;
41
    let timer
43
    if (!loading) {
42
    if (!loading) {
44
      timer = setTimeout(() => checkSession(), 1000);
43
      timer = setTimeout(() => checkSession(), 1000)
45
    }
44
    }
46
    return () => {
45
    return () => {
47
      clearTimeout(timer);
46
      clearTimeout(timer)
48
    };
47
    }
Línea 49... Línea 48...
49
  }, [loading])
48
  }, [loading])
50
 
49
 
51
  const checkSession = async () => {
50
  const checkSession = async () => {
Línea 86... Línea 85...
86
 
85
 
87
  const handleNotifications = () => {
86
  const handleNotifications = () => {
88
    axios.get('/notifications/unreads')
87
    axios.get('/notifications/unreads')
89
      .then(({ data }) => {
88
      .then(({ data }) => {
90
        if (data.success) {
89
        if (data.success) {
91
          let notifications = new Set(data.data.notifications)
90
          const notifications = new Set(data.data.notifications)
92
          setNotifications([...notifications])
91
          setNotifications([...notifications])
93
        }
92
        }
94
      })
93
      })
95
      .catch(err => {
94
      .catch(err => {
96
        addNotification({
95
        addNotification({
97
          style: "error",
96
          style: 'error',
98
          msg: 'Disculpe, ha ocurrido un error buscando notificaciones',
97
          msg: 'Disculpe, ha ocurrido un error buscando notificaciones'
99
        })
98
        })
100
        console.log('>>: err > ', err)
99
        console.log('>>: err > ', err)
101
      })
100
      })
Línea 139... Línea 138...
139
                      : <a href={_element.href[0] === '/' ? _element.href : `/${_element.href}`} target='framename'>{_element.label}</a>
138
                      : <a href={_element.href[0] === '/' ? _element.href : `/${_element.href}`} target='framename'>{_element.label}</a>
140
                    }
139
                    }
141
                    {!!_element.childs?.length &&
140
                    {!!_element.childs?.length &&
142
                      <>
141
                      <>
143
                        <i className="fa fa-angle-right" />
142
                        <i className="fa fa-angle-right" />
144
                        <nav className='navLinkLevelThree'>
143
                        <nav className='navigation-level_three'>
145
                          <ul>
144
                          <ul>
146
                            {_element.childs?.map((levelThree, index) =>
145
                            {_element.childs?.map((levelThree, index) =>
147
                              <li key={index}>
146
                              <li key={index}>
148
                                <a href={levelThree.href}>
147
                                <a href={levelThree.href}>
149
                                  {levelThree.label}
148
                                  {levelThree.label}
Línea 203... Línea 202...
203
                  <span className={`badge ${notificationsCount ? 'd-block' : 'd-none'}`}>
202
                  <span className={`badge ${notificationsCount ? 'd-block' : 'd-none'}`}>
204
                    {notificationsCount}
203
                    {notificationsCount}
205
                  </span>
204
                  </span>
206
                </a>
205
                </a>
207
                {!!notifications.length &&
206
                {!!notifications.length &&
208
                  <nav className='notifications-list'>
207
                  <nav className='navigation-level_three'>
209
                    <ul>
208
                    <ul>
210
                      {[...notifications].reverse().map(element => {
209
                      {[...notifications].reverse().map(element => {
211
                        return (
210
                        return (
212
                          <li key={element.message} className="d-block text-center">
211
                          <li key={element.message} className="d-block text-center">
213
                            <div className="d-inline-flex align-items-center">
212
                            <div className="d-inline-flex align-items-center">
Línea 236... Línea 235...
236
            </ul>
235
            </ul>
237
          </div>
236
          </div>
238
        </li>
237
        </li>
239
      }
238
      }
240
    </ul>
239
    </ul>
241
  );
240
  )
242
};
241
}
Línea 243... Línea 242...
243
 
242
 
244
const mapDispatchToProps = {
243
const mapDispatchToProps = {
245
  addNotification: (notification) => addNotification(notification),
244
  addNotification: (notification) => addNotification(notification)
Línea 246... Línea -...
246
};
-
 
247
 
245
}
-
 
246