import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { disposition } from "@/content/routes";
import { StatusPage } from "@/components/status-page";

type Props = { params: Promise<{ retired: string[] }> };

export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const { retired } = await params;
  return {
    title:
      disposition(`/${retired.join("/")}`).status === 410
        ? "Page no longer available"
        : "Page not found",
    robots: { index: false },
  };
}

export default async function RetiredPage({ params }: Props) {
  const { retired } = await params;
  if (disposition(`/${retired.join("/")}`).status !== 410) notFound();
  return (
    <StatusPage
      title="Page no longer available"
      description="This older page has been retired. Visit the MaxCredit homepage to explore our current loan services."
    />
  );
}
