import { UI } from "@/lib/config";
import type { Lang } from "@/lib/config";
import { getCachedHealthChecks } from "@/lib/health-checks";
import type { HealthStatus } from "@/lib/types/health";
import StatusPageClient from "./StatusPageClient";

export const dynamic = "force-dynamic";
export const revalidate = 0;

interface PageProps {
  params: { lang: Lang };
}

export default async function StatusPage({ params }: PageProps) {
  const lang = params.lang;

  // Fetch initial status data on server
  let initialHealth;
  try {
    initialHealth = await getCachedHealthChecks();
  } catch (error) {
    console.error("Failed to fetch initial health status:", error);
    initialHealth = {
      overall: "down" as HealthStatus,
      components: [],
      timestamp: new Date().toISOString(),
    };
  }

  return <StatusPageClient lang={lang} initialHealth={initialHealth} />;
}
