Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev Autor Línea Nro. Línea
2854 stevensc 1
import React from 'react'
2614 stevensc 2
import { useNavigate } from 'react-router-dom'
677 stevensc 3
import { useDispatch } from 'react-redux'
2854 stevensc 4
import { Avatar, styled, Typography } from '@mui/material'
5
import {
6
  VisibilityOutlined,
7
  MapOutlined,
8
  ShareOutlined
9
} from '@mui/icons-material'
674 stevensc 10
 
2994 stevensc 11
import { axios, parse } from '@utils'
12
import { addNotification } from '@store/notification/notification.actions'
5 stevensc 13
 
2854 stevensc 14
import Widget from '@components/UI/Widget'
15
import Options from '@components/UI/Option'
676 stevensc 16
 
2854 stevensc 17
const Row = styled('div')(() => ({
18
  display: 'flex',
19
  justifyContent: 'space-around',
20
  alignItems: 'center'
21
}))
674 stevensc 22
 
5 stevensc 23
export default function ProfileInfo({
24
  image,
25
  name,
26
  description,
27
  visits,
28
  country,
29
  connections,
30
  linkAdmin,
671 stevensc 31
  linkImpersonate
5 stevensc 32
}) {
2614 stevensc 33
  const navigate = useNavigate()
34
  const dispatch = useDispatch()
676 stevensc 35
 
2854 stevensc 36
  const getAdminUrl = async () => {
37
    try {
38
      const response = await axios.get('/backend/signin-admin')
39
      const { data, success } = response.data
40
      if (!success) throw new Error(data)
41
      window.open(data)
42
    } catch (error) {
43
      dispatch(addNotification({ style: 'danger', msg: error.message }))
44
    }
5 stevensc 45
  }
46
 
47
  return (
2854 stevensc 48
    <Widget>
672 stevensc 49
      <Avatar
50
        src={image}
51
        alt={`${name} profile-image`}
52
        sx={{ margin: '0 auto', width: 100, height: 100 }}
53
      />
2854 stevensc 54
      <Typography variant='h2'>{name}</Typography>
55
      <Typography>{parse(description)}</Typography>
674 stevensc 56
 
2854 stevensc 57
      <Row>
2917 stevensc 58
        <Typography variant='overline'>
2854 stevensc 59
          <VisibilityOutlined />
674 stevensc 60
          {visits}
2854 stevensc 61
        </Typography>
62
 
2917 stevensc 63
        <Typography variant='overline'>
2854 stevensc 64
          <MapOutlined />
674 stevensc 65
          {country}
2854 stevensc 66
        </Typography>
67
 
2917 stevensc 68
        <Typography variant='overline'>
2854 stevensc 69
          <ShareOutlined />
674 stevensc 70
          {connections}
2854 stevensc 71
        </Typography>
72
      </Row>
674 stevensc 73
 
2854 stevensc 74
      <Options>
75
        {linkAdmin ? (
76
          <Options.Item onClick={getAdminUrl}>Administración</Options.Item>
77
        ) : null}
78
 
79
        {linkImpersonate ? (
80
          <Options.Item onClick={() => navigate('/impersonate')}>
81
            Personificar otro usuario
82
          </Options.Item>
83
        ) : null}
84
 
85
        <Options.Item onClick={() => navigate('/account-settings')}>
86
          Configuración de la cuenta
87
        </Options.Item>
88
        <Options.Item onClick={() => navigate('/privacy-policy')}>
89
          Política de privacidad
90
        </Options.Item>
91
        <Options.Item onClick={() => navigate('/cookies')}>
92
          Política de cookies
93
        </Options.Item>
94
        <Options.Item onClick={() => navigate('/signout')}>
95
          Cerrar sesión
96
        </Options.Item>
97
      </Options>
98
    </Widget>
5 stevensc 99
  )
100
}