Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6632 Rev 6753
Línea 1... Línea -...
1
/* eslint-disable react/prop-types */
-
 
2
import React, { useEffect, useRef, useState } from 'react'
1
import React, { useRef, useState } from 'react'
3
import Avatar from '../../../shared/Avatar/Avatar'
-
 
4
import axios from '../../../utils/axios'
2
import { axios } from '../../../utils'
5
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'
3
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'
Línea -... Línea 4...
-
 
4
 
-
 
5
import Avatar from '../../UI/AvatarImage'
-
 
6
import useOutsideClick from '../../../hooks/useOutsideClick'
6
 
7
 
7
const UserOptions = ({
8
const UserOptions = ({
8
  image = '',
9
  image = '',
9
  name = '',
10
  name = '',
10
  adminUrl = '',
11
  adminUrl = '',
Línea 13... Línea 14...
13
  routeKnowledge,
14
  routeKnowledge,
14
  knowledgeAuth,
15
  knowledgeAuth,
15
}) => {
16
}) => {
16
  const [displayOptions, setDisplayOptions] = useState(false)
17
  const [displayOptions, setDisplayOptions] = useState(false)
17
  const userDropdownContainer = useRef(null)
18
  const userDropdownContainer = useRef(null)
18
 
-
 
19
  useEffect(() => {
-
 
20
    const handleClickOutside = (event) => {
-
 
21
      if (
-
 
22
        userDropdownContainer?.current &&
-
 
23
        !userDropdownContainer?.current?.contains(event.target)
19
  useOutsideClick(userDropdownContainer, () => setDisplayOptions(false))
24
      ) {
-
 
25
        setDisplayOptions(false)
-
 
26
      }
-
 
27
    }
-
 
28
    document.addEventListener('mousedown', handleClickOutside)
-
 
29
 
-
 
30
    return () => {
-
 
31
      document.removeEventListener('mousedown', handleClickOutside)
-
 
32
    }
-
 
33
  }, [userDropdownContainer])
-
 
Línea 34... Línea 20...
34
 
20
 
35
  const handleDisplay = async (e) => {
21
  const handleDisplay = async (e) => {
36
    e.preventDefault()
22
    e.preventDefault()
37
    setDisplayOptions(!displayOptions)
23
    setDisplayOptions(!displayOptions)