import { fetchCrescentHealthLogisticsData } from '@/services/crescent-health.service';
import React from 'react';

interface PageData {
  title: string;
  description: string; 
}

export default async function Page() {
  let pageData: PageData | null = null;

  try {
    const response = await fetchCrescentHealthLogisticsData(
      'b1eb6537-517c-4716-b14e-5e4bd210b367'
    );
    pageData = response?.pagedata ?? null;
  } catch (error) {
    console.error('Error fetching Crescent Health logistics data:', 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-justify text-lg leading-relaxed">
      <div className="space-y-6">
        <h1 className="mb-6 text-[28px] md:text-[36px] font-[300] leading-6 text-gray-800">
          {pageData.title}
        </h1>
        <div
          className="text-gray-700 leading-6 text-[16px] "
          dangerouslySetInnerHTML={{ __html: pageData.description }}
        />
      </div>
    </section>
  );
}
