import { ButtonLink, PageHero } from "./ui";
type Document = { html: string; headings: { id: string; title: string }[] };
export function DocumentPage({
  title,
  description,
  kicker,
  document,
  booklet = false,
}: {
  title: string;
  description: string;
  kicker: string;
  document: Document;
  booklet?: boolean;
}) {
  return (
    <>
      <PageHero title={title} description={description} kicker={kicker} />
      <section className="page-content">
        <div className="wrap document-grid">
          <aside className="document-nav" aria-label="On this page">
            <p className="footer-heading">On this page</p>
            {document.headings.map((heading) => (
              <a href={`#${heading.id}`} key={heading.id}>
                {heading.title}
              </a>
            ))}
          </aside>
          <article className="prose">
            <div dangerouslySetInnerHTML={{ __html: document.html }} />
            {booklet && (
              <div className="download-box">
                <h3>The full reform booklet</h3>
                <p>
                  Read the movement’s paper on reforming the Australian
                  parliamentary system. Contact us if you would prefer a hard
                  copy.
                </p>
                <ButtonLink href="/assets/mbg-reform-plan.pdf" variant="dark">
                  Read the booklet (PDF)
                </ButtonLink>
              </div>
            )}
          </article>
        </div>
      </section>
    </>
  );
}
