import type { PublicHeaderBanner as PublicHeaderBannerData } from "@cms/db"
import Link from "next/link"

type PublicHeaderBannerProps = {
  banner: PublicHeaderBannerData | null
}

export function PublicHeaderBanner({ banner }: PublicHeaderBannerProps) {
  if (!banner) {
    return null
  }

  return (
    <div className="border-b border-amber-200 bg-amber-50">
      <div className="mx-auto flex w-full max-w-6xl flex-wrap items-center justify-between gap-3 px-6 py-2 text-sm text-amber-900">
        <p>{banner.message}</p>
        {banner.ctaLabel && banner.ctaHref ? (
          <Link href={banner.ctaHref} className="font-medium underline underline-offset-2">
            {banner.ctaLabel}
          </Link>
        ) : null}
      </div>
    </div>
  )
}
