diff --git a/app/settings/co2-galvo/[id]/co2-galvo.tsx b/app/settings/co2-galvo/[id]/co2-galvo.tsx index 7acc74ce..e0c83d0a 100644 --- a/app/settings/co2-galvo/[id]/co2-galvo.tsx +++ b/app/settings/co2-galvo/[id]/co2-galvo.tsx @@ -15,15 +15,15 @@ type Rec = { photo?: { id?: string } | string | null; screen?: { id?: string } | string | null; - // shapes pass-through for form - mat?: any; - mat_coat?: any; - mat_color?: any; - mat_opacity?: any; + // relations (may be id or object) + mat?: { id?: string | number } | string | number | null; + mat_coat?: { id?: string | number } | string | number | null; + mat_color?: { id?: string | number } | string | number | null; + mat_opacity?: { id?: string | number } | string | number | null; mat_thickness?: number | null; - source?: any; - lens?: any; + source?: { submission_id?: string | number } | string | number | null; + lens?: { id?: string | number } | string | number | null; focus?: number | null; laser_soft?: any; @@ -69,25 +69,35 @@ export default function CO2GalvoSettingDetailPage() { setLoading(true); setErr(null); + // Request the specific IDs needed to prefill selects const fields = [ "submission_id", "setting_title", "setting_notes", "photo.id", "screen.id", - "mat", - "mat_coat", - "mat_color", - "mat_opacity", + + // relations: request their ids explicitly + "mat.id", + "mat_coat.id", + "mat_color.id", + "mat_opacity.id", "mat_thickness", - "source", - "lens", + + // source is keyed by submission_id in the selector + "source.submission_id", + + // lens select expects numeric id + "lens.id", "focus", + "laser_soft", "repeat_all", + "fill_settings", "line_settings", "raster_settings", + "owner.id", "owner.username", "uploader", @@ -121,8 +131,20 @@ export default function CO2GalvoSettingDetailPage() { if (!rec) return null; // normalize existing file refs to ids for the form - const photoId = typeof rec.photo === "string" ? rec.photo : rec.photo?.id ?? null; - const screenId = typeof rec.screen === "string" ? rec.screen : rec.screen?.id ?? null; + const photoId = typeof rec.photo === "string" || typeof rec.photo === "number" ? String(rec.photo) : rec.photo?.id ?? null; + const screenId = typeof rec.screen === "string" || typeof rec.screen === "number" ? String(rec.screen) : rec.screen?.id ?? null; + + // normalize relations to id strings expected by - + {filtered.map((o) => (