Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3661 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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