import { NewsDetails } from "@/services/NewsDetails";

import NewsDetailsComponent from "@/components/NewsDetails/NewsDetailsComponent";

export default async function NewsDetailsPage({
  params,
}: {
  params: { id: string };
}) {
  // Await the params to ensure they are resolved
  const { id } = await params;

  // Find the news item based on the id
  const newsItem = NewsDetails.find((news) => news.id === id);

  if (!newsItem) {
    return (
      <>
        <main className="container mx-auto px-6 lg:px-12 py-16 text-center">
          <h1 className="text-2xl font-bold text-gray-600">News Not Found</h1>
          <p className="text-gray-500">
            Sorry, the news item you are looking for does not exist.
          </p>
        </main>
      </>
    );
  }

  return (
    <>
      <main>
        <NewsDetailsComponent id={id} />
      </main>
    </>
  );
}
