Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5128 | Rev 5399 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
4250 stevensc 1
/* eslint-disable react/prop-types */
5128 stevensc 2
import React, { useEffect, useState } from 'react'
3
import NavLinks from './nav-links/NavLinks'
4
import ChatHelper from '../../../chat/chatHelper/ChatHelper'
5
import UserImageDropdown from './user-dropdown/UserImageDropdown'
6
import SearchInput from './searchbox/SearchInput'
7
import ResponsiveNavbar from './responsive-navbar/ResponsiveNavbar'
4250 stevensc 8
 
5173 stevensc 9
const Navbar = ({ navbarVars, LABELS }) => {
4250 stevensc 10
  const {
11
    image,
12
    fullName,
13
    companyVars,
14
    isChatPage,
15
    linkAdmin,
16
    linkImpersonate,
17
    routeCheckSession,
18
    logoForNavbar,
19
    menu: menuProps
5128 stevensc 20
  } = navbarVars
4250 stevensc 21
 
5128 stevensc 22
  const [navbarOpen, setNavbarOpen] = useState(false)
4250 stevensc 23
  const [sessionImage, setSessionImage] = useState(null)
5128 stevensc 24
  const [loading, setLoading] = useState(false)
4250 stevensc 25
 
26
  useEffect(() => {
5128 stevensc 27
    let timer
4250 stevensc 28
    if (!loading) {
5128 stevensc 29
      timer = setTimeout(() => checkSessionImage(), 1000)
4250 stevensc 30
    }
31
    return () => {
5128 stevensc 32
      clearTimeout(timer)
33
    }
4250 stevensc 34
  }, [loading])
35
 
36
  const checkSessionImage = async () => {
5128 stevensc 37
    setLoading(true)
4250 stevensc 38
    const session_image = sessionStorage.getItem('user_session_image')
39
    if (session_image) {
40
      await setSessionImage(session_image)
41
      sessionStorage.removeItem('user_session_image')
42
    }
5128 stevensc 43
    setLoading(false)
4250 stevensc 44
  }
45
 
46
  return (
47
    <>
48
      <nav className='navbar'>
4917 stevensc 49
        <a href="/" className='logo d-none d-xl-block'>
4250 stevensc 50
          <img src={logoForNavbar} alt="logo" />
51
        </a>
52
        <SearchInput />
53
        <div className='hamburgerIcon'>
4913 stevensc 54
          <i className="fa fa-bars text-gray" onClick={() => setNavbarOpen(!navbarOpen)} />
4250 stevensc 55
        </div>
56
        <nav className='navLinksContainer'>
57
          <NavLinks
4335 stevensc 58
            menuData={menuProps}
4250 stevensc 59
            companyVars={companyVars}
60
            sessionLink={routeCheckSession}
61
          />
62
        </nav>
4913 stevensc 63
        <UserImageDropdown
64
          image={image}
65
          fullName={fullName}
66
          linkAdmin={linkAdmin}
67
          linkImpersonate={linkImpersonate}
68
          sessionImage={sessionImage}
69
        />
4250 stevensc 70
      </nav>
71
      <ResponsiveNavbar
72
        show={navbarOpen}
73
        navbarVars={navbarVars}
74
        companyVars={companyVars}
75
        image={image}
76
        fullName={fullName}
77
        linkAdmin={linkAdmin}
78
        linkImpersonate={linkImpersonate}
79
        sessionImage={sessionImage}
5173 stevensc 80
        LABELS={LABELS}
4250 stevensc 81
      />
82
      {window.innerWidth < 1000 && !isChatPage && <ChatHelper />}
83
    </>
84
  )
85
}
86
 
5128 stevensc 87
export default Navbar