import { db } from "@/lib/db"; import type { TermsByCategory } from "@/lib/terms"; /** Active T&C clause texts grouped by category, for the PO form dropdowns (#11). */ export async function getActiveTermsByCategory(): Promise { const rows = await db.termsCondition.findMany({ where: { isActive: true }, orderBy: [{ category: "asc" }, { createdAt: "asc" }], select: { category: true, text: true }, }); const map: TermsByCategory = {}; for (const r of rows) (map[r.category] ??= []).push(r.text); return map; }