Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2614 | Rev 2917 | 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'
10
import parse from 'html-react-parser'
674 stevensc 11
 
2854 stevensc 12
import { axios } from '@app/utils'
13
import { addNotification } from '@app/redux/notification/notification.actions'
5 stevensc 14
 
2854 stevensc 15
import Widget from '@components/UI/Widget'
16
import Options from '@components/UI/Option'
676 stevensc 17
 
2854 stevensc 18
const Row = styled('div')(() => ({
19
  display: 'flex',
20
  justifyContent: 'space-around',
21
  alignItems: 'center'
22
}))
674 stevensc 23
 
5 stevensc 24
export default function ProfileInfo({
25
  image,
26
  name,
27
  description,
28
  visits,
29
  country,
30
  connections,
31
  linkAdmin,
671 stevensc 32
  linkImpersonate
5 stevensc 33
}) {
2614 stevensc 34
  const navigate = useNavigate()
35
  const dispatch = useDispatch()
676 stevensc 36
 
2854 stevensc 37
  const getAdminUrl = async () => {
38
    try {
39
      const response = await axios.get('/backend/signin-admin')
40
      const { data, success } = response.data
41
      if (!success) throw new Error(data)
42
      window.open(data)
43
    } catch (error) {
44
      dispatch(addNotification({ style: 'danger', msg: error.message }))
45
    }
5 stevensc 46
  }
47
 
48
  return (
2854 stevensc 49
    <Widget>
672 stevensc 50
      <Avatar
51
        src={image}
52
        alt={`${name} profile-image`}
53
        sx={{ margin: '0 auto', width: 100, height: 100 }}
54
      />
2854 stevensc 55
      <Typography variant='h2'>{name}</Typography>
56
      <Typography>{parse(description)}</Typography>
674 stevensc 57
 
2854 stevensc 58
      <Row>
59
        <Typography variant='body2'>
60
          <VisibilityOutlined />
674 stevensc 61
          {visits}
2854 stevensc 62
        </Typography>
63
 
64
        <Typography variant='body2'>
65
          <MapOutlined />
674 stevensc 66
          {country}
2854 stevensc 67
        </Typography>
68
 
69
        <Typography variant='body2'>
70
          <ShareOutlined />
674 stevensc 71
          {connections}
2854 stevensc 72
        </Typography>
73
      </Row>
674 stevensc 74
 
2854 stevensc 75
      <Options>
76
        {linkAdmin ? (
77
          <Options.Item onClick={getAdminUrl}>Administración</Options.Item>
78
        ) : null}
79
 
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
88
        </Options.Item>
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>
5 stevensc 100
  )
101
}