Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 7101 Rev 7331
Línea 2... Línea 2...
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...
4
 
4
 
5
import useOutsideClick from '../../../hooks/useOutsideClick'
5
import useOutsideClick from '../../../hooks/useOutsideClick'
-
 
6
import { Avatar } from '@mui/material'
-
 
7
import { Link } from 'react-router-dom'
-
 
8
import { logout } from '../../../redux/auth/auth.actions'
-
 
9
import { useDispatch } from 'react-redux'
Línea 6... Línea 10...
6
import { Avatar } from '@mui/material'
10
import { addNotification } from '../../../redux/notification/notification.actions'
7
 
11
 
8
const UserOptions = ({
12
const UserOptions = ({
9
  image = '',
13
  image = '',
10
  name = '',
14
  name = '',
11
  adminUrl = '',
15
  adminUrl = '',
12
  impersonateUrl = '',
16
  impersonateUrl = '',
-
 
17
  defaultNetwork = 'y',
-
 
18
  knowledgeAuth,
13
  defaultNetwork = 'y',
19
  routeAdmin = '',
14
  knowledgeAuth,
20
  routeImpersonate = '',
15
}) => {
21
}) => {
16
  const [userImage, setUserImage] = useState(
22
  const [userImage, setUserImage] = useState(
17
    '/storage/type/user/code/f3df3718-37d9-4e4d-bd84-71f7924a858d/'
23
    '/storage/type/user/code/f3df3718-37d9-4e4d-bd84-71f7924a858d/'
18
  )
24
  )
-
 
25
  const [displayOptions, setDisplayOptions] = useState(false)
Línea 19... Línea 26...
19
  const [displayOptions, setDisplayOptions] = useState(false)
26
  const userDropdownContainer = useRef(null)
Línea 20... Línea 27...
20
  const userDropdownContainer = useRef(null)
27
  const dispatch = useDispatch()
21
 
28
 
Línea 38... Línea 45...
38
  }
45
  }
Línea 39... Línea 46...
39
 
46
 
40
  const getAdminUrl = async (e) => {
47
  const getAdminUrl = async (e) => {
41
    e.preventDefault()
48
    e.preventDefault()
42
    try {
49
    try {
43
      const { data } = await axios.get('/backend/signin-admin')
50
      const { data } = await axios.get(routeAdmin)
44
      if (data.success) return window.open(data.data)
51
      if (data.success) return window.open(data.data)
45
    } catch (error) {
52
    } catch (error) {
46
      console.log('>>: error > ', error)
53
      console.log('>>: error > ', error)
47
    }
54
    }
Línea -... Línea 55...
-
 
55
  }
-
 
56
 
-
 
57
  const handleLogout = (e) => {
-
 
58
    e.preventDefault()
-
 
59
      .get('/logout')
-
 
60
      .then((response) => {
-
 
61
        if (response.status === 200) {
-
 
62
          dispatch(logout())
-
 
63
        }
-
 
64
      })
-
 
65
      .catch(() => {
-
 
66
        dispatch(
-
 
67
          addNotification({
-
 
68
            style: 'danger',
-
 
69
            message: 'Error interno. Intente más tarde.',
-
 
70
          })
-
 
71
        )
-
 
72
        throw new Error()
-
 
73
      })
48
  }
74
  }
49
 
75
 
50
  useEffect(() => {
76
  useEffect(() => {
51
    const timer = setInterval(() => {
77
    const timer = setInterval(() => {
Línea 88... Línea 114...
88
          <div className="user__options-item">
114
          <div className="user__options-item">
89
            <h3>Admin</h3>
115
            <h3>Admin</h3>
90
            <ul>
116
            <ul>
91
              {adminUrl && (
117
              {adminUrl && (
92
                <li>
118
                <li>
93
                  <a href="#" onClick={getAdminUrl}>
119
                  <Link to="/admin" onClick={getAdminUrl}>
94
                    Administración
120
                    Administración
95
                  </a>
121
                  </Link>
96
                </li>
122
                </li>
97
              )}
123
              )}
98
              {impersonateUrl && (
124
              {impersonateUrl && (
99
                <li>
125
                <li>
100
                  <a href="/impersonate" target="secondary">
126
                  <Link to={routeImpersonate} target="secondary">
101
                    Personificar otro usuario
127
                    Personificar otro usuario
102
                  </a>
128
                  </Link>
103
                </li>
129
                </li>
104
              )}
130
              )}
105
            </ul>
131
            </ul>
106
          </div>
132
          </div>
107
        )}
133
        )}
108
        <div className="user__options-item">
134
        <div className="user__options-item">
109
          <h3>Cuenta</h3>
135
          <h3>Cuenta</h3>
110
          <ul>
136
          <ul>
111
            <li>
137
            <li>
112
              <a href="/account-settings" target="secondary">
138
              <Link to="/account-settings" target="secondary">
113
                Configuración de la cuenta
139
                Configuración de la cuenta
114
              </a>
140
              </Link>
115
            </li>
141
            </li>
116
            {defaultNetwork === 'y' && (
142
            {defaultNetwork === 'y' && (
117
              <>
143
              <>
118
                <li>
144
                <li>
119
                  <a href="/privacy-policy" target="secondary">
145
                  <Link to="/privacy-policy" target="secondary">
120
                    Política de privacidad
146
                    Política de privacidad
121
                  </a>
147
                  </Link>
122
                </li>
148
                </li>
123
                <li>
149
                <li>
124
                  <a href="/cookies" target="secondary">
150
                  <Link to="/cookies" target="secondary">
125
                    Política de cookies
151
                    Política de cookies
126
                  </a>
152
                  </Link>
127
                </li>
153
                </li>
128
              </>
154
              </>
129
            )}
155
            )}
130
          </ul>
156
          </ul>
131
        </div>
157
        </div>
132
        <div className="user__options-item">
158
        <div className="user__options-item">
133
          <ul>
159
          <ul>
134
            <li className="logOutContainer">
160
            <li className="logOutContainer">
-
 
161
              <Link
135
              <a className="logOutContainer__a" href="/signout">
162
                className="logOutContainer__a"
-
 
163
                to="/signout"
-
 
164
                onClick={handleLogout}
-
 
165
              >
136
                Cerrar sesión
166
                Cerrar sesión
137
              </a>
167
              </Link>
138
            </li>
168
            </li>
139
          </ul>
169
          </ul>
140
        </div>
170
        </div>
141
      </div>
171
      </div>
142
    </li>
172
    </li>