Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2994 | Rev 2996 | 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>
2995 stevensc 49
      <Widget.Body>
50
        <Avatar
51
          src={image}
52
          alt={`${name} profile-image`}
53
          sx={{ margin: '0 auto', width: 100, height: 100 }}
54
        />
55
        <Typography variant='h2'>{name}</Typography>
56
        <Typography>{parse(description)}</Typography>
674 stevensc 57
 
2995 stevensc 58
        <Row>
59
          <Typography variant='overline'>
60
            <VisibilityOutlined />
61
            {visits}
62
          </Typography>
2854 stevensc 63
 
2995 stevensc 64
          <Typography variant='overline'>
65
            <MapOutlined />
66
            {country}
67
          </Typography>
2854 stevensc 68
 
2995 stevensc 69
          <Typography variant='overline'>
70
            <ShareOutlined />
71
            {connections}
72
          </Typography>
73
        </Row>
674 stevensc 74
 
2995 stevensc 75
        <Options>
76
          {linkAdmin ? (
77
            <Options.Item onClick={getAdminUrl}>Administración</Options.Item>
78
          ) : null}
2854 stevensc 79
 
2995 stevensc 80
          {linkImpersonate ? (
81
            <Options.Item onClick={() => navigate('/impersonate')}>
82
              Personificar otro usuario
83
            </Options.Item>
84
          ) : null}
85
 
86
          <Options.Item onClick={() => navigate('/account-settings')}>
87
            Configuración de la cuenta
2854 stevensc 88
          </Options.Item>
2995 stevensc 89
          <Options.Item onClick={() => navigate('/privacy-policy')}>
90
            Política de privacidad
91
          </Options.Item>
92
          <Options.Item onClick={() => navigate('/cookies')}>
93
            Política de cookies
94
          </Options.Item>
95
          <Options.Item onClick={() => navigate('/signout')}>
96
            Cerrar sesión
97
          </Options.Item>
98
        </Options>
99
      </Widget.Body>
2854 stevensc 100
    </Widget>
5 stevensc 101
  )
102
}