Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4448 Rev 4629
Línea 1... Línea 1...
1
/* eslint-disable react/prop-types */
1
/* eslint-disable react/prop-types */
2
import React, { useEffect, useRef, useState } from 'react'
2
import React, { useEffect, useRef, useState } from 'react'
3
import SearchIcon from '@mui/icons-material/Search'
3
import SearchIcon from '@mui/icons-material/Search'
4
import HomeIcon from '@mui/icons-material/Home'
4
import HomeIcon from '@mui/icons-material/Home'
5
import BusinessCenterIcon from '@mui/icons-material/BusinessCenter'
5
import BusinessCenterIcon from '@mui/icons-material/BusinessCenter'
6
import CalendarMonthIcon from '@mui/icons-material/CalendarMonth';
-
 
7
import SellIcon from '@mui/icons-material/Sell';
6
import SellIcon from '@mui/icons-material/Sell';
8
import PeopleIcon from '@mui/icons-material/People';
7
import PeopleIcon from '@mui/icons-material/People';
9
import GroupsIcon from '@mui/icons-material/Groups';
8
import GroupsIcon from '@mui/icons-material/Groups';
10
import HeaderOptions from './HeaderOptions'
9
import HeaderOptions from './HeaderOptions'
11
import ChatIcon from '@mui/icons-material/Chat'
10
import ChatIcon from '@mui/icons-material/Chat'
Línea 19... Línea 18...
19
  HomeIcon,
18
  HomeIcon,
20
  PeopleIcon,
19
  PeopleIcon,
21
  BusinessCenterIcon,
20
  BusinessCenterIcon,
22
  GroupsIcon,
21
  GroupsIcon,
23
  SellIcon,
22
  SellIcon,
24
  CalendarMonthIcon,
-
 
25
]
23
]
Línea 26... Línea 24...
26
 
24
 
27
const Header = ({
25
const Header = ({
28
  menu: menuItems = [],
26
  menu,
29
  image = '',
27
  image = '',
30
  logoForNavbar = '',
28
  logoForNavbar = '',
31
  fullName,
29
  fullName,
32
  linkAdmin,
30
  linkAdmin,
33
  linkImpersonate,
31
  linkImpersonate,
34
  //companyVars,
32
  //companyVars,
35
  //isChatPage,
33
  //isChatPage,
36
  //routeCheckSession,
34
  //routeCheckSession,
37
}) => {
-
 
-
 
35
}) => {
-
 
36
  const [menuItems, setMenuItems] = useState(menu || [])
38
 
37
  const [aditionalItems, setAditionalItems] = useState([])
39
  const [userImage, setUserImage] = useState(image)
38
  const [userImage, setUserImage] = useState(image)
40
  const [showMobileSearch, setShowMobileSearch] = useState(false)
39
  const [showMobileSearch, setShowMobileSearch] = useState(false)
41
  const [loading, setLoading] = useState(false);
40
  const [loading, setLoading] = useState(false);
Línea 42... Línea 41...
42
  const searchInput = useRef(null);
41
  const searchInput = useRef(null);
43
 
42
 
Línea 44... Línea -...
44
  const { handleSubmit, register } = useForm()
-
 
45
  const handleOnSubmit = (data) => window.location.replace(`/search/entity/user?keyword=${data.keyword}`)
-
 
46
 
-
 
47
  useEffect(() => {
-
 
48
    let timer;
-
 
49
    if (!loading) {
-
 
50
      timer = setTimeout(() => checkUserImage(), 1000);
-
 
51
    }
-
 
52
    return () => {
-
 
53
      clearTimeout(timer);
-
 
54
    };
43
  const { handleSubmit, register } = useForm()
55
  }, [loading])
44
  const handleOnSubmit = (data) => window.location.replace(`/search/entity/user?keyword=${data.keyword}`)
56
 
45
 
57
  const checkUserImage = async () => {
46
  const checkUserImage = async () => {
58
    setLoading(true);
47
    setLoading(true);
59
    const session_image = sessionStorage.getItem('user_session_image')
48
    const session_image = sessionStorage.getItem('user_session_image')
60
    if (session_image) {
49
    if (session_image) {
61
      await setUserImage(session_image)
50
      await setUserImage(session_image)
62
      sessionStorage.removeItem('user_session_image')
51
      sessionStorage.removeItem('user_session_image')
Línea 63... Línea -...
63
    }
-
 
64
    setLoading(false);
52
    }
65
  }
53
    setLoading(false);
66
 
54
  }
67
 
55
 
68
  const handleDisplayMobileSearch = () => {
56
  const handleDisplayMobileSearch = () => {
Línea 69... Línea 57...
69
    if (window.innerWidth < 992) {
57
    if (window.innerWidth < 992) {
-
 
58
      setShowMobileSearch(true)
-
 
59
    }
-
 
60
  }
-
 
61
 
-
 
62
  useEffect(() => {
-
 
63
    let timer;
-
 
64
    if (!loading) {
-
 
65
      timer = setTimeout(() => checkUserImage(), 1000);
-
 
66
    }
-
 
67
    return () => {
-
 
68
      clearTimeout(timer);
-
 
69
    };
-
 
70
  }, [loading])
-
 
71
 
-
 
72
  useEffect(() => {
-
 
73
    if (menu.length > 5) {
-
 
74
      setMenuItems(menu.splice(0, 5))
70
      setShowMobileSearch(true)
75
      setAditionalItems(menu.splice(menu.length - 5))
71
    }
76
    }
72
  }
77
  }, [])
73
 
78
 
74
  useEffect(() => {
79
  useEffect(() => {
Línea 119... Línea 124...
119
                    childs={item.childs}
124
                    childs={item.childs}
120
                  />
125
                  />
121
                )
126
                )
122
              })}
127
              })}
123
              <HeaderOptions
128
              <HeaderOptions
-
 
129
                Icon={NotificationsIcon}
-
 
130
                title='Notificaciones'
-
 
131
                url='/notifications'
-
 
132
              />
-
 
133
              <HeaderOptions
124
                Icon={ChatIcon}
134
                Icon={ChatIcon}
125
                title='Comunicación'
135
                title='Comunicación'
126
                url=''
136
                url=''
127
                childs={[
137
                childs={[
-
 
138
                  ...aditionalItems,
128
                  { label: 'Inmail', href: '/inmail' },
139
                  { label: 'Inmail', href: '/inmail' },
129
                  { label: 'Chat', href: '/chat' }
140
                  { label: 'Chat', href: '/chat' }
130
                ]}
141
                ]}
131
              />
142
              />
132
              <UserOptions
143
              <UserOptions