diff --git a/components/details/CO2GalvoDetail.tsx b/components/details/CO2GalvoDetail.tsx index 58ece1d9..67a93389 100644 --- a/components/details/CO2GalvoDetail.tsx +++ b/components/details/CO2GalvoDetail.tsx @@ -1,7 +1,7 @@ // components/details/CO2GalvoDetail.tsx "use client"; -import { useEffect, useMemo, useState } from "react"; +import { useEffect, useState } from "react"; import { useRouter, useSearchParams } from "next/navigation"; import SettingsSubmit from "@/components/forms/SettingsSubmit"; @@ -82,6 +82,16 @@ export default function CO2GalvoDetail({ id, editable }: { id: string | number; return "—"; }; + // numeric helper (treat booleans/objects as null) + const asNumOrNull = (v: any): number | null => { + if (typeof v === "number") return Number.isFinite(v) ? v : null; + if (typeof v === "string" && v.trim() !== "") { + const n = Number(v); + return Number.isFinite(n) ? n : null; + } + return null; + }; + // fetch me id useEffect(() => { let alive = true; @@ -253,16 +263,6 @@ export default function CO2GalvoDetail({ id, editable }: { id: string | number; }; const DITHER_LABEL = (v: string | undefined) => (v ? v.charAt(0).toUpperCase() + v.slice(1) : "—"); - const asNumOrNull = (v: any): number | null => { - if (typeof v === "number") return Number.isFinite(v) ? v : null; - if (typeof v === "string" && v.trim() !== "") { - const n = Number(v); - return Number.isFinite(n) ? n : null; - } - // treat booleans/objects as null for numeric-only display - return null; - }; - // ----- EDIT MODE ----- if (editMode && rec) { const toId = (v: any) => (v == null ? "" : typeof v === "object" ? (v.id ?? v.submission_id ?? "") : String(v)); @@ -281,7 +281,8 @@ export default function CO2GalvoDetail({ id, editable }: { id: string | number; mat_thickness: rec.mat_thickness ?? null, // Rig & Optics laser_soft: typeof rec.laser_soft === "object" ? String(rec.laser_soft?.id ?? "") : String(rec.laser_soft ?? "") || "", - source: rec.source && typeof rec.source === "object" ? String(rec.source.submission_id ?? "") : String(rec.source ?? "") || "", + source: + rec.source && typeof rec.source === "object" ? String(rec.source.submission_id ?? "") : String(rec.source ?? "") || "", lens: toId(rec.lens) || "", focus: rec.focus ?? null, // CO2 triplet @@ -441,8 +442,8 @@ export default function CO2GalvoDetail({ id, editable }: { id: string | number; {rec.line_settings!.map((r: any, i: number) => { const perfEnabled = !!r.perf; const wobbleEnabled = !!r.wobble; - const cutVal = asNumOrNull(r.cut); - const skipVal = asNumOrNull(r.skip); + const cutVal = asNumOrNull(r.cut ?? r.perf_cut ?? r.cut_length); + const skipVal = asNumOrNull(r.skip ?? r.perf_skip ?? r.skip_length); const stepVal = asNumOrNull(r.step); const sizeVal = asNumOrNull(r.size); @@ -450,7 +451,7 @@ export default function CO2GalvoDetail({ id, editable }: { id: string | number;
{r.name || `Line ${i + 1}`}
- {/* Base fields – match form order (Pulse removed) */} + {/* Base fields – Pulse removed for CO2 */}
diff --git a/components/lists/CO2GalvoList.tsx b/components/lists/CO2GalvoList.tsx index 5caec5f5..fdacdd38 100644 --- a/components/lists/CO2GalvoList.tsx +++ b/components/lists/CO2GalvoList.tsx @@ -28,8 +28,6 @@ type Row = { lens?: { field_size?: string | number | null } | null; }; -const API = (process.env.NEXT_PUBLIC_API_BASE_URL || "").replace(/\/$/, ""); - async function readJson(r: Response) { const t = await r.text(); try { @@ -82,16 +80,19 @@ export default function CO2GalvoList({ const fields = [ "submission_id", "setting_title", - // IMPORTANT: request the expanded relation only (do NOT include bare 'owner' id) "owner.id", "owner.username", + "owner.first_name", + "owner.last_name", + "owner.email", "uploader", "mat.name", "mat_coat.name", "source.model", "lens.field_size", ].join(","); - const url = `${API}/items/settings_co2gal?fields=${encodeURIComponent(fields)}&limit=-1`; + // Use the same proxy as Details so relation expansion & auth match + const url = `/api/dx/items/settings_co2gal?fields=${encodeURIComponent(fields)}&limit=-1`; const r = await fetch(url, { credentials: "include", cache: "no-store" }); if (!r.ok) { const j = await readJson(r);