export const dynamic = "force-dynamic";
import HeroCertificationBody from "@/components/CertificationBody/HeroCertificationBody";

import { BASE_URL } from "@/Constant";

async function getData() {
  try {
    const [resData, tableData] = await Promise.all([
      fetch(`${BASE_URL}cbPageData`, { cache: "no-store" })
        .then((res) => (res.ok ? res.json() : null))
        .catch(() => null),

      fetch(`${BASE_URL}cbPageData/table`, { cache: "no-store" })
        .then((res) => (res.ok ? res.json() : null))
        .catch(() => null),
    ]);

    return {
      resUp: resData?.data || [],
      resTable: tableData?.data?.postCategory || [],
    };
  } catch (error) {
    console.error("Error fetching Certification Body data:", error);
    return { resUp: [], resTable: [] };
  }
}

export default async function CertificationBodyPage() {
  const { resUp, resTable } = await getData();

  return (
    <div className="bg-hero bg-cover">
      <HeroCertificationBody main={resUp} table={resTable} />
    </div>
  );
}
