Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3596 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3719 stevensc 1
import React from 'react';
2
import { NavLink as Link, useLocation } from 'react-router-dom';
3
import { Typography, styled, Breadcrumbs } from '@mui/material';
4
 
5
import { useFetch } from '@hooks';
6
import colors from '@styles/config/colors';
7
 
8
const StyledBreadcrumbs = styled(Breadcrumbs)`
9
  li a {
10
    padding: 0.3rem 1rem;
11
    background-color: var(--font-color);
12
    color: var(--bg-color);
13
    border-radius: 20px;
14
    &.active {
15
      display: none;
16
    }
17
  }
18
`;
19
 
20
const StyledPoliciesPage = styled('div')`
21
  h1 {
22
    margin-bottom: 1rem;
23
  }
24
 
25
  h2,
26
  h3,
27
  h4,
28
  h5,
29
  h6 {
30
    margin-bottom: 0.5rem;
31
  }
32
 
33
  > p {
34
    margin-bottom: 0.5rem;
35
  }
36
 
37
  table {
38
    background-color: ${colors.main};
39
 
40
    &,
41
    tr,
42
    td {
43
      border: 1px solid ${colors.border.primary};
44
    }
45
 
46
    td {
47
      padding: 5px;
48
    }
49
  }
50
`;
51
 
52
const PoliciesLayout = ({ children, title }) => {
53
  return (
54
    <>
55
      <PoliciesNavigation />
56
      <Typography variant='h1'>{title}</Typography>
57
      <StyledPoliciesPage>{children}</StyledPoliciesPage>
58
    </>
59
  );
60
};
61
 
62
const PoliciesNavigation = () => {
63
  const { data, isLoading } = useFetch('/helpers/footer');
64
  const { pathname } = useLocation();
65
 
66
  if (isLoading) return null;
67
 
68
  return (
69
    <StyledBreadcrumbs sx={{ my: 2 }} aria-label='breadcrumb'>
70
      <Link exact to='/'>
71
        Inicio
72
      </Link>
73
 
74
      {Object.entries(data).map(([href, label]) => {
75
        if (pathname.includes(href)) {
76
          return null;
77
        }
78
 
79
        return (
80
          <Link key={`${href}-${label}`} to={href}>
81
            {label}
82
          </Link>
83
        );
84
      })}
85
    </StyledBreadcrumbs>
86
  );
87
};
88
 
89
export default PoliciesLayout;