diff --git a/app/lasers/[id]/page.tsx b/app/lasers/[id]/page.tsx index 25fc2ea8..32c38e46 100644 --- a/app/lasers/[id]/page.tsx +++ b/app/lasers/[id]/page.tsx @@ -1,4 +1,5 @@ // app/lasers/[id]/page.tsx +import type { PageProps } from "next"; import { cookies } from "next/headers"; import { redirect, notFound } from "next/navigation"; import { dxGET } from "@/lib/directus"; @@ -61,16 +62,21 @@ const FIELD_KEYS = Array.from( new Set(["make", "model", ...FIELD_GROUPS.flatMap((g) => Object.keys(g.fields))]) ); -export default async function Page({ params }: { params: { id: string } }) { - const token = cookies().get("ma_at")?.value; +export default async function Page( + { params }: PageProps<{ id: string }> +) { + const { id: submissionId } = await params; // Next 15: params is a Promise + const jar = await cookies(); // Next 15: cookies() is async + const token = jar.get("ma_at")?.value; + if (!token) { - redirect(`/auth/sign-in?next=${encodeURIComponent(`/lasers/${params.id}`)}`); + redirect(`/auth/sign-in?next=${encodeURIComponent(`/lasers/${submissionId}`)}`); } + const bearer = `Bearer ${token}`; const fields = encodeURIComponent(FIELD_KEYS.join(",")); - const submissionId = params.id; // CONFIRMED: primary key is submission_id - // Fetch by item endpoint using submission_id as PK + // submission_id is the PK const res = await dxGET( `/items/laser_source/${encodeURIComponent(submissionId)}?fields=${fields}`, bearer