import { notFound } from "next/navigation";
import { getImageIdByCode } from "@/lib/db/queries";
import { ImageDetailView } from "@/components/image/ImageDetailView";

export const dynamic = "force-dynamic";

export default async function IdPage({ params }: { params: Promise<{ code: string }> }) {
  const { code } = await params;
  const decoded = decodeURIComponent(code);
  const id = getImageIdByCode(decoded);
  if (id == null) notFound();
  return <ImageDetailView imageId={id} />;
}
