All files / src/components/LegalSection LegalSection.tsx

100% Statements 7/7
100% Branches 7/7
100% Functions 3/3
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46                                    4x 4x                 20x 1x           19x 1x   18x              
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import Divider from '@mui/material/Divider';
import Link from '@mui/material/Link';
 
interface SectionProps {
  id: string;
  title: string;
  content: string;
  isLast?: boolean;
}
 
export default function LegalSection({
  id,
  title,
  content,
  isLast = false,
}: SectionProps) {
  return (
    <Box id={id} sx={{ mb: 4, scrollMarginTop: theme => theme.mixins.toolbar.minHeight }}>
      <Typography variant="h6" gutterBottom>
        {title}
      </Typography>
      <Typography
        component="div"
        sx={{ whiteSpace: 'pre-wrap', fontSize: '0.9rem', fontWeight: 200, pl: 2 }}
      >
        {content.split(/(\s+)/).map((seg, i) => {
          if (/https?:\/\/\S+/.test(seg)) {
            return (
              <Link key={i} href={seg} target="_blank" rel="noopener noreferrer">
                {seg}
              </Link>
            );
          }
          if (/^[\w.+-]+@[\w-]+\.[\w.-]+$/.test(seg)) {
            return <Link key={i} href={`mailto:${seg}`}>{seg}</Link>;
          }
          return seg;
        })}
      </Typography>
      {!isLast && <Divider sx={{ mt: 5, mb: 0 }} />}
    </Box>
  );
}