import Preamble from "@/components/TempDesignSystem/Text/Preamble"
import Title from "@/components/TempDesignSystem/Text/Title"

import SectionLink from "../Link"

import styles from "./header.module.css"

import type { HeaderProps } from "@/types/components/myPages/header"

export default function SectionHeader({
  link,
  preamble,
  title,
  topTitle = false,
  textTransform,
}: HeaderProps) {
  if (!title && !preamble && !link) {
    return null
  }

  return (
    <header className={styles.header}>
      <Title
        as={topTitle ? "h3" : "h4"}
        className={styles.title}
        level={topTitle ? "h1" : "h2"}
        textTransform={textTransform}
      >
        {title}
      </Title>
      {preamble && <Preamble className={styles.preamble}>{preamble}</Preamble>}
      <SectionLink link={link} variant="desktop" />
    </header>
  )
}
