diff --git a/components/details/CO2GalvoDetail.tsx b/components/details/CO2GalvoDetail.tsx index 918b59a9..58ece1d9 100644 --- a/components/details/CO2GalvoDetail.tsx +++ b/components/details/CO2GalvoDetail.tsx @@ -92,9 +92,13 @@ export default function CO2GalvoDetail({ id, editable }: { id: string | number; const j = t ? JSON.parse(t) : null; const idVal = j?.data?.id ?? j?.id ?? null; if (alive) setMeId(idVal ? String(idVal) : null); - } catch { /* ignore */ } + } catch { + /* ignore */ + } })(); - return () => { alive = false; }; + return () => { + alive = false; + }; }, []); useEffect(() => { @@ -170,7 +174,9 @@ export default function CO2GalvoDetail({ id, editable }: { id: string | number; if (!dead) setLoading(false); } })(); - return () => { dead = true; }; + return () => { + dead = true; + }; }, [id]); if (loading) return
Loading setting…
; @@ -197,9 +203,16 @@ export default function CO2GalvoDetail({ id, editable }: { id: string | number; const isMine = meId && ownerId ? meId === ownerId : false; // Small field renderer (label on top, value below) - const Field = ({ label, value, suffix }: { label: string; value: React.ReactNode | string | number | null | undefined; suffix?: string }) => { - const primitive = - typeof value === "string" || typeof value === "number" || typeof value === "boolean"; + const Field = ({ + label, + value, + suffix, + }: { + label: string; + value: React.ReactNode | string | number | null | undefined; + suffix?: string; + }) => { + const primitive = typeof value === "string" || typeof value === "number" || typeof value === "boolean"; const isEmpty = value == null || value === "" || (typeof value === "number" && isNaN(value as number)); return ( @@ -240,10 +253,19 @@ 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); + const toId = (v: any) => (v == null ? "" : typeof v === "object" ? (v.id ?? v.submission_id ?? "") : String(v)); const initialValues = { submission_id: rec.submission_id, @@ -307,9 +329,7 @@ export default function CO2GalvoDetail({ id, editable }: { id: string | number;Submitting as {meLabel}
: null} - {submitErr ?