Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev Autor Línea Nro. Línea
3481 stevensc 1
import React from 'react';
2
import { Avatar, Box, Typography } from '@mui/material';
3
 
3661 stevensc 4
import { useAlert, useApi } from '@shared/hooks';
5
import { getProfile } from '@microlearning/services';
6
 
3529 stevensc 7
import { Spinner } from '@shared/components';
8
import { DetailTag } from '@microlearning/components';
3481 stevensc 9
 
3505 stevensc 10
export function ProfilePage() {
3661 stevensc 11
  const { showError } = useAlert();
3481 stevensc 12
 
3661 stevensc 13
  const { data: profile, loading } = useApi(getProfile, {
14
    autoFetch: true,
15
    onError: (error) => {
16
      showError(error.message);
17
    }
18
  });
3481 stevensc 19
 
3661 stevensc 20
  if (loading) return <Spinner />;
21
 
3481 stevensc 22
  return (
23
    <>
24
      <Box textAlign='center'>
25
        <Avatar
3661 stevensc 26
          src={profile[0]?.image}
27
          alt={profile[0]?.name}
3481 stevensc 28
          sx={{ width: 100, height: 100, margin: '0 auto' }}
29
        />
3661 stevensc 30
        <Typography variant='h2'>{profile[0]?.name}</Typography>
3481 stevensc 31
      </Box>
32
 
33
      <Box display='flex' flexDirection='column' gap={1} width='100%' mt={2}>
3661 stevensc 34
        {profile[0]?.details?.map(({ uuid, label, value }) => (
3481 stevensc 35
          <DetailTag key={uuid} title={label} label={value} />
36
        ))}
37
      </Box>
38
    </>
39
  );
3505 stevensc 40
}