import { fetchCrescentHealthInformationData } from "@/services/crescent-health.service";

export default async function Page() {
  let pageData: { title: string; description: string } | null = null;

  try {
    const response = await fetchCrescentHealthInformationData(
      "648e3b7b-26b2-482a-a6c6-104cf1824b12"
    );
    pageData = response?.pagedata ?? null;
  } catch (error) {
    console.error("Error fetching product info:", error);
  }

  if (!pageData) {
    return (
      <section className="mx-auto max-w-6xl py-10 text-center">
        <p className="text-gray-600">No data available.</p>
      </section>
    );
  }

  return (
    <section className="mx-auto max-w-6xl py-2 sm:py-10 text-lg leading-relaxed">
      <h1 className="mb-8 font-sans text-[28px] md:text-[36px] font-[300] text-gray-800 leading-8">
        {pageData.title}
      </h1>

      <div
        className="custom-content prose max-w-none text-[16px] text-gray-700"
        dangerouslySetInnerHTML={{ __html: pageData.description }}
      />
    </section>
  );
}
