added exp and apt to rigs.
This commit is contained in:
parent
d142ba464a
commit
9390b52aae
3 changed files with 91 additions and 15 deletions
|
|
@ -30,19 +30,21 @@ export async function GET(req: Request) {
|
|||
"laser_scan_lens.focal_length",
|
||||
"laser_focus_lens.id",
|
||||
"laser_focus_lens.name",
|
||||
"laser_scan_lens_apt.id", // NEW
|
||||
"laser_scan_lens_apt.name", // NEW
|
||||
"laser_scan_lens_exp.id", // NEW
|
||||
"laser_scan_lens_exp.name", // NEW
|
||||
"laser_software.id",
|
||||
"laser_software.name",
|
||||
"date_created",
|
||||
"date_updated",
|
||||
].join(",");
|
||||
|
||||
// Rely entirely on Directus role rules to scope results ("My Rigs")
|
||||
const path =
|
||||
`/items/user_rigs?fields=${encodeURIComponent(fields)}` +
|
||||
`&sort=-date_updated` +
|
||||
`&limit=${limit}`;
|
||||
|
||||
// dxGET returns the unwrapped `data` array
|
||||
const rows = await dxGET<any[]>(path, bearer);
|
||||
return NextResponse.json(rows ?? []);
|
||||
} catch (e: any) {
|
||||
|
|
@ -60,6 +62,8 @@ export async function POST(req: Request) {
|
|||
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;
|
||||
const laser_scan_lens_apt = body?.laser_scan_lens_apt || null; // NEW
|
||||
const laser_scan_lens_exp = body?.laser_scan_lens_exp || null; // NEW
|
||||
const laser_software = body?.laser_software || null;
|
||||
const notes = (body?.notes || "").trim();
|
||||
|
||||
|
|
@ -67,7 +71,6 @@ 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 the authenticated user
|
||||
const me = await dxGET<{ id: string }>("/users/me?fields=id", bearer);
|
||||
|
||||
const payload: any = {
|
||||
|
|
@ -77,6 +80,8 @@ export async function POST(req: Request) {
|
|||
laser_source,
|
||||
laser_scan_lens,
|
||||
laser_focus_lens,
|
||||
laser_scan_lens_apt, // NEW
|
||||
laser_scan_lens_exp, // NEW
|
||||
laser_software,
|
||||
notes,
|
||||
};
|
||||
|
|
@ -100,7 +105,6 @@ export async function DELETE(req: Request) {
|
|||
const id = url.searchParams.get("id");
|
||||
if (!id) return bad("Missing: id");
|
||||
|
||||
// ensure the rig belongs to the current user
|
||||
const me = await dxGET<{ id: string }>("/users/me?fields=id", bearer);
|
||||
const rig = await dxGET<any>(
|
||||
`/items/user_rigs/${encodeURIComponent(id)}?fields=id,owner`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue