build error fix
This commit is contained in:
parent
4b416b01e7
commit
a7d83e625b
1 changed files with 8 additions and 16 deletions
|
|
@ -20,7 +20,7 @@ const FIELD_GROUPS = [
|
||||||
w: "Laser Wattage (W)",
|
w: "Laser Wattage (W)",
|
||||||
mj: "milliJoule Max (mJ)",
|
mj: "milliJoule Max (mJ)",
|
||||||
nm: "Wavelength (nm)",
|
nm: "Wavelength (nm)",
|
||||||
k_hz: "Pulse Repetition Rate (kHz)",
|
kHz: "Pulse Repetition Rate (kHz)", // NOTE: schema uses kHz (not k_hz)
|
||||||
ns: "Pulse Width (ns)",
|
ns: "Pulse Width (ns)",
|
||||||
d: "Beam Diameter (mm)",
|
d: "Beam Diameter (mm)",
|
||||||
m2: "M² - Quality",
|
m2: "M² - Quality",
|
||||||
|
|
@ -57,34 +57,26 @@ const FIELD_GROUPS = [
|
||||||
},
|
},
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
const FIELD_KEYS = Array.from(
|
|
||||||
new Set(["make", "model", ...FIELD_GROUPS.flatMap((g) => Object.keys(g.fields))])
|
|
||||||
);
|
|
||||||
|
|
||||||
export default async function Page(
|
export default async function Page(
|
||||||
{ params }: { params: Promise<{ id: string }> } // Next 15: params is a Promise
|
{ params }: { params: Promise<{ id: string }> } // Next 15: params is Promise
|
||||||
) {
|
) {
|
||||||
const { id: submissionId } = await params;
|
const { id: submissionId } = await params;
|
||||||
|
|
||||||
// Next 15: cookies() is async
|
const jar = await cookies(); // Next 15: cookies() is async
|
||||||
const jar = await cookies();
|
|
||||||
const token = jar.get("ma_at")?.value;
|
const token = jar.get("ma_at")?.value;
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
redirect(`/auth/sign-in?next=${encodeURIComponent(`/lasers/${submissionId}`)}`);
|
redirect(`/auth/sign-in?next=${encodeURIComponent(`/lasers/${submissionId}`)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bearer = `Bearer ${token}`;
|
const bearer = `Bearer ${token}`;
|
||||||
const fields = encodeURIComponent(FIELD_KEYS.join(","));
|
|
||||||
|
|
||||||
// Primary key is submission_id
|
// Pull EVERYTHING the role can see. (No fragile field list.)
|
||||||
const res = await dxGET<any>(
|
const res = await dxGET<any>(
|
||||||
`/items/laser_source/${encodeURIComponent(submissionId)}?fields=${fields}`,
|
`/items/laser_source/${encodeURIComponent(submissionId)}?fields=*`,
|
||||||
bearer
|
bearer
|
||||||
);
|
);
|
||||||
const row = res?.data ?? res ?? null;
|
const laser = res?.data ?? res ?? null;
|
||||||
|
if (!laser) notFound();
|
||||||
|
|
||||||
if (!row) notFound();
|
return <LaserDetailsClient laser={laser} fieldGroups={FIELD_GROUPS as any} />;
|
||||||
|
|
||||||
return <LaserDetailsClient laser={row} fieldGroups={FIELD_GROUPS as any} />;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue