build error fix
This commit is contained in:
parent
59b26635d9
commit
ddec51d753
1 changed files with 11 additions and 5 deletions
|
|
@ -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<any>(
|
||||
`/items/laser_source/${encodeURIComponent(submissionId)}?fields=${fields}`,
|
||||
bearer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue