export const dynamic = "force-dynamic";
import HeroAccreditationBody from "@/components/OrganizationMemeberInner/InnerAbout";
import { BASE_URL } from "@/Constant";

// Data fetching
async function getData() {
  try {
    const endpoints = ["abPageData", "abPageData/table"];
    const [resUp, resTable] = await Promise.all(
      endpoints.map((endpoint) =>
        fetch(`${BASE_URL}${endpoint}`, { cache: "no-store" })
          .then((res) => (res.ok ? res.json() : null))
          .catch(() => null),
      ),
    );

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

// Page Component
export default async function AccreditationPage() {
  const { resUp, resTable } = await getData();
  return (
    <div className="bg-hero bg-cover">
      <HeroAccreditationBody main={resUp} table={resTable} />
    </div>
  );
}
