import fs from "node:fs";
import path from "node:path";

export type ProductDetailsSlug =
  | "consentiq"
  | "atlas"
  | "orthoprep"
  | "academy";

export const PRODUCT_DETAILS_SLUGS: ProductDetailsSlug[] = [
  "consentiq",
  "atlas",
  "orthoprep",
  "academy",
];

export const PRODUCT_DETAILS_TITLES: Record<ProductDetailsSlug, string> = {
  consentiq: "ConsentIQ — Full brief",
  atlas: "OrthoAtlas — Full brief",
  orthoprep: "OrthoPrep — Full brief",
  academy: "OrthoGlobe Academy — Full brief",
};

export function getProductDetails(
  slug: ProductDetailsSlug,
): { html: string } | null {
  if (!PRODUCT_DETAILS_SLUGS.includes(slug)) return null;
  const filePath = path.join(
    process.cwd(),
    "content",
    "product-details",
    `${slug}.html`,
  );
  if (!fs.existsSync(filePath)) return null;
  const html = fs.readFileSync(filePath, "utf-8");
  return { html };
}
