Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3694 Rev 3719
Línea 1... Línea 1...
1
import React from 'react';
1
import React from 'react';
2
import { useNavigate } from 'react-router-dom';
2
import { useNavigate } from 'react-router-dom';
3
import { Box, IconButton, Typography } from '@mui/material';
3
import { Box, IconButton, Typography } from '@mui/material';
4
import NavigateBefore from '@mui/icons-material/NavigateBefore';
4
import NavigateBefore from '@mui/icons-material/NavigateBefore';
5
 
5
 
6
export default function PageHeader({ title = '', goBack = false, action = () => null }) {
6
export default function PageHeader({ title = '', goBack = false, action = () => null }) {
7
  const navigate = useNavigate();
7
  const navigate = useNavigate();
8
 
8
 
9
  const navigateBefore = () => navigate(-1);
9
  const navigateBefore = () => navigate(-1);
10
 
10
 
11
  return (
11
  return (
12
    <Box
12
    <Box
13
      sx={{
13
      sx={{
14
        display: 'flex',
14
        display: 'flex',
15
        justifyContent: 'space-between',
15
        justifyContent: 'space-between',
16
        alignItems: 'center',
16
        alignItems: 'center',
17
        gap: 2,
17
        gap: 2,
18
        marginBottom: 1,
18
        marginBottom: 1,
19
        paddingX: 1
19
        paddingX: 1
20
      }}
20
      }}
21
    >
21
    >
22
      <Box
22
      <Box
23
        sx={{
23
        sx={{
24
          display: 'flex',
24
          display: 'flex',
25
          alignItems: 'center',
25
          alignItems: 'center',
26
          gap: ({ spacing }) => spacing(0.5)
26
          gap: ({ spacing }) => spacing(0.5)
27
        }}
27
        }}
28
      >
28
      >
29
        {goBack && (
29
        {goBack && (
30
          <IconButton onClick={navigateBefore}>
30
          <IconButton onClick={navigateBefore}>
31
            <NavigateBefore />
31
            <NavigateBefore />
32
          </IconButton>
32
          </IconButton>
33
        )}
33
        )}
34
        <Typography variant='h1'>{title}</Typography>
34
        <Typography variant='h1'>{title}</Typography>
35
      </Box>
35
      </Box>
36
 
36
 
37
      {action()}
37
      {action()}
38
    </Box>
38
    </Box>
39
  );
39
  );
40
}
40
}