import { DataTable } from "@/components/admin/DataTable";
import { AdminPageHeader, AdminPreviewCell, AdminTextCell } from "@/components/admin/AdminPresentation";
import { prisma } from "@/lib/prisma";

export default async function EmailTemplatesPage() {
  const rows = await prisma.emailTemplate.findMany();
  return (
    <section>
      <AdminPageHeader title="Email Templates" subtitle="Reference templates used for customer and fulfillment communication." />
      <DataTable headers={["Key", "Subject", "Body"]} rows={rows.map((t) => [
        <AdminTextCell key="key" value={t.key} className="max-w-[180px] font-black" />,
        <AdminTextCell key="subject" value={t.subject} className="max-w-[260px]" />,
        <AdminPreviewCell key="body" value={t.body} />
      ])} />
    </section>
  );
}
