diff --git a/app/api/rigs/route.ts b/app/api/rigs/route.ts index e1e386f8..1543d8bc 100644 --- a/app/api/rigs/route.ts +++ b/app/api/rigs/route.ts @@ -1,4 +1,4 @@ -// app/api/my/rigs/route.ts +// app/api/rigs/route.ts import { NextResponse } from "next/server"; import { dxGET, dxPOST, dxDELETE } from "@/lib/directus"; import { requireBearer } from "@/app/api/_lib/auth"; @@ -43,9 +43,8 @@ export async function GET(req: Request) { `&sort=-date_updated` + `&limit=${limit}`; - // ⬇️ dxGET already returns the unwrapped `data` + // dxGET already returns the unwrapped `data` array const rows = await dxGET(path, bearer); - return NextResponse.json(rows ?? []); } catch (e: any) { return bad(e?.message || "Failed to load rigs", e?.status || 500); @@ -58,7 +57,7 @@ export async function POST(req: Request) { const body = await req.json().catch(() => ({})); const name = (body?.name || "").trim(); - const rig_type = body?.rig_type; // id + const rig_type = body?.rig_type; // id const laser_source = body?.laser_source; // submission_id const laser_scan_lens = body?.laser_scan_lens || null; const laser_focus_lens = body?.laser_focus_lens || null; @@ -69,7 +68,7 @@ export async function POST(req: Request) { if (!rig_type) return bad("Missing: rig_type"); if (!laser_source) return bad("Missing: laser_source"); - // Derive owner from auth’d user; ignore any spoofed owner in body + // set owner from the authenticated user const me = await dxGET<{ id: string }>("/users/me?fields=id", bearer); const payload: any = { @@ -102,7 +101,7 @@ export async function DELETE(req: Request) { const id = url.searchParams.get("id"); if (!id) return bad("Missing: id"); - // Hard-guard: ensure the rig belongs to the current user + // ensure the rig belongs to the current user const me = await dxGET<{ id: string }>("/users/me?fields=id", bearer); const rig = await dxGET( `/items/user_rigs/${encodeURIComponent(id)}?fields=id,owner`, diff --git a/app/rigs/RigsListClient.tsx b/app/rigs/RigsListClient.tsx index cdc71d9c..53dad629 100644 --- a/app/rigs/RigsListClient.tsx +++ b/app/rigs/RigsListClient.tsx @@ -69,32 +69,22 @@ export default function RigsListClient() { {[ r.laser_source.make, r.laser_source.model, - ] - .filter(Boolean) - .join(" ") || r.laser_source.submission_id} + ].filter(Boolean).join(" ") || r.laser_source.submission_id} .{" "} ) : null} - {r.laser_focus_lens?.name ? ( - <>Focus Lens: {r.laser_focus_lens.name}. - ) : null} + {r.laser_focus_lens?.name ? <>Focus Lens: {r.laser_focus_lens.name}. : null} {r.laser_scan_lens ? ( <> Scan Lens:{" "} {[ - r.laser_scan_lens.field_size && - `${r.laser_scan_lens.field_size}mm`, - r.laser_scan_lens.focal_length && - `${r.laser_scan_lens.focal_length}mm`, - ] - .filter(Boolean) - .join(" / ")} + r.laser_scan_lens.field_size && `${r.laser_scan_lens.field_size}mm`, + r.laser_scan_lens.focal_length && `${r.laser_scan_lens.focal_length}mm`, + ].filter(Boolean).join(" / ")} .{" "} ) : null} - {r.laser_software?.name ? ( - <>Software: {r.laser_software.name}. - ) : null} + {r.laser_software?.name ? <>Software: {r.laser_software.name}. : null} {r.notes ?
{r.notes}
: null}