diff --git a/app/api/options/[collection]/route.ts b/app/api/options/[collection]/route.ts index 71d71c06..f9f09a33 100644 --- a/app/api/options/[collection]/route.ts +++ b/app/api/options/[collection]/route.ts @@ -5,19 +5,19 @@ import { directusFetch } from "@/lib/directus"; type MapEntry = { path: string; fields: string; label: (x: any) => string }; const MAP: Record = { - material: { path: "/items/material", fields: "id,name", label: (x) => String(x.name ?? x.id) }, - material_coating: { path: "/items/material_coating", fields: "id,name", label: (x) => String(x.name ?? x.id) }, - material_color: { path: "/items/material_color", fields: "id,name", label: (x) => String(x.name ?? x.id) }, - material_opacity: { path: "/items/material_opacity", fields: "id,opacity", label: (x) => String(x.opacity ?? x.id) }, - laser_software: { path: "/items/laser_software", fields: "id,name", label: (x) => String(x.name ?? x.id) }, - // laser_source and lens are handled by dedicated routes + material: { path: "/items/material", fields: "id,name", label: (x) => String(x.name ?? x.id) }, + material_coating: { path: "/items/material_coating", fields: "id,name", label: (x) => String(x.name ?? x.id) }, + material_color: { path: "/items/material_color", fields: "id,name", label: (x) => String(x.name ?? x.id) }, + material_opacity: { path: "/items/material_opacity", fields: "id,opacity", label: (x) => String(x.opacity ?? x.id) }, + laser_software: { path: "/items/laser_software", fields: "id,name", label: (x) => String(x.name ?? x.id) }, + // laser_source and lens have dedicated routes }; -export async function GET(req: Request, ctx: { params: { collection: string } }) { +export async function GET(req: Request, ctx: any) { try { const { searchParams } = new URL(req.url); - const key = ctx.params.collection; - const q = (searchParams.get("q") || "").trim().toLowerCase(); + const key = ctx?.params?.collection as string; + const q = (searchParams.get("q") || "").trim().toLowerCase(); const limit = Number(searchParams.get("limit") || "500"); const cfg = MAP[key];