import { LegalArt } from '@/site/components/art/legal-art';
import { PageHero, sheet } from '@/site/components/sections/page-hero';
import { useShared } from '@/site/hooks/use-shared';
import { formatDate, useT } from '@/site/i18n';
import { cx } from '@/site/lib/cx';

type LegalProps = {
    page: {
        key: string;
        title: string;
        /** Rendered from Markdown on the server; raw HTML in the source is stripped there. */
        html: string;
        updatedAt: string | null;
    };
};

/** A legal page (KVKK notice, privacy policy, cookie policy) — Admin → Sayfalar. */
export default function Legal({ page }: LegalProps) {
    const { locale } = useShared();
    const t = useT();

    return (
        <>
            <PageHero
                title={page.title}
                lead={
                    page.updatedAt
                        ? t.legal.updated(formatDate(page.updatedAt, locale))
                        : undefined
                }
                art={<LegalArt page={page.key} />}
            />

            <section className={cx('stage-light section-y-sm', sheet)}>
                <article
                    className="prose-legal shell-narrow"
                    dangerouslySetInnerHTML={{ __html: page.html }}
                />
            </section>
        </>
    );
}
