routing fixes
This commit is contained in:
parent
0ee9686fb1
commit
44a690f4d2
20 changed files with 769 additions and 962 deletions
11
app/api/options/material/route.ts
Normal file
11
app/api/options/material/route.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { NextRequest } from "next/server";
|
||||
import { dFetchJSON, applyQFilter, json, Option } from "../_lib";
|
||||
|
||||
type Row = { id: number | string; name?: string | null };
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const q = new URL(req.url).searchParams.get("q");
|
||||
const { data } = await dFetchJSON<{ data: Row[] }>(req, "/items/material?fields=id,name&limit=1000&sort=name");
|
||||
const options: Option[] = data.map((r) => ({ id: r.id, label: r.name ?? String(r.id) }));
|
||||
return json(applyQFilter(options, q, (o) => o.label));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue