Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6753 Rev 7088
Línea 1... Línea 1...
1
import React, { useRef, useState } from 'react'
1
import React, { useEffect, useRef, useState } from 'react'
2
import { axios } from '../../../utils'
2
import { axios } from '../../../utils'
3
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'
3
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'
Línea 4... Línea -...
4
 
-
 
5
import Avatar from '../../UI/AvatarImage'
4
 
-
 
5
import useOutsideClick from '../../../hooks/useOutsideClick'
Línea 6... Línea 6...
6
import useOutsideClick from '../../../hooks/useOutsideClick'
6
import { Avatar } from '@mui/material'
7
 
7
 
8
const UserOptions = ({
8
const UserOptions = ({
9
  image = '',
9
  image = '',
10
  name = '',
10
  name = '',
11
  adminUrl = '',
11
  adminUrl = '',
12
  impersonateUrl = '',
-
 
13
  defaultNetwork = 'y',
12
  impersonateUrl = '',
14
  routeKnowledge,
13
  defaultNetwork = 'y',
-
 
14
  knowledgeAuth,
-
 
15
}) => {
-
 
16
  const [userImage, setUserImage] = useState(
15
  knowledgeAuth,
17
    '/storage/type/user/code/f3df3718-37d9-4e4d-bd84-71f7924a858d/'
16
}) => {
18
  )
-
 
19
  const [displayOptions, setDisplayOptions] = useState(false)
17
  const [displayOptions, setDisplayOptions] = useState(false)
20
  const userDropdownContainer = useRef(null)
Línea -... Línea 21...
-
 
21
 
-
 
22
  useOutsideClick(userDropdownContainer, () => setDisplayOptions(false))
-
 
23
 
-
 
24
  const checkUserImage = () => {
-
 
25
    const session_image = sessionStorage.getItem('user_session_image')
-
 
26
 
-
 
27
    if (!session_image) {
-
 
28
      return
-
 
29
    }
-
 
30
 
-
 
31
    setUserImage(session_image)
18
  const userDropdownContainer = useRef(null)
32
    sessionStorage.removeItem('user_session_image')
19
  useOutsideClick(userDropdownContainer, () => setDisplayOptions(false))
33
  }
20
 
34
 
21
  const handleDisplay = async (e) => {
35
  const handleDisplay = async (e) => {
Línea 31... Línea 45...
31
    } catch (error) {
45
    } catch (error) {
32
      console.log('>>: error > ', error)
46
      console.log('>>: error > ', error)
33
    }
47
    }
34
  }
48
  }
Línea -... Línea 49...
-
 
49
 
-
 
50
  useEffect(() => {
-
 
51
    const timer = setInterval(() => {
-
 
52
      checkUserImage()
-
 
53
    }, 2000)
-
 
54
 
-
 
55
    return () => {
-
 
56
      clearInterval(timer)
-
 
57
    }
-
 
58
  }, [])
-
 
59
 
-
 
60
  useEffect(() => {
-
 
61
    setUserImage(image)
-
 
62
  }, [image])
35
 
63
 
36
  return (
64
  return (
37
    <li>
65
    <li>
-
 
66
      <a href="#" className="header__option mobile" onClick={handleDisplay}>
-
 
67
        <Avatar
38
      <a href="#" className="header__option mobile" onClick={handleDisplay}>
68
          src={userImage}
-
 
69
          alt={`${name} profile image`}
-
 
70
          sx={{ height: '30px', width: '30px' }}
39
        <Avatar imageUrl={image} name={name} size="md" />
71
        />
40
        <span>
72
        <span>
41
          Me <ArrowDropDownIcon className="user__option-icon" />
73
          Me <ArrowDropDownIcon className="user__option-icon" />
42
        </span>
74
        </span>
43
      </a>
75
      </a>
Línea 47... Línea 79...
47
        }`}
79
        }`}
48
        ref={userDropdownContainer}
80
        ref={userDropdownContainer}
49
      >
81
      >
50
        <div className="user__options-description">
82
        <div className="user__options-description">
51
          <div className="user__options-info">
83
          <div className="user__options-info">
52
            <Avatar imageUrl={image} name={name} size="xl" />
84
            <Avatar />
53
            <h3>{name}</h3>
85
            <h3>{name}</h3>
54
          </div>
86
          </div>
55
          {/* <a href='#' className='btn__profile'>
87
          {/* <a href='#' className='btn__profile'>
56
                        View profile
88
                        View profile
57
                    </a> */}
89
                    </a> */}