diff --git a/app/settings/co2-galvo/[id]/co2-galvo.tsx b/app/settings/co2-galvo/[id]/co2-galvo.tsx index 492ad601..7bbef2eb 100644 --- a/app/settings/co2-galvo/[id]/co2-galvo.tsx +++ b/app/settings/co2-galvo/[id]/co2-galvo.tsx @@ -25,16 +25,14 @@ export default function CO2GalvoSettingDetailPage() { "submission_id", "setting_title", "uploader", - // ✅ Owner (M2O) — request username explicitly + // ✅ fetch username directly "owner.id", "owner.username", - // Content & assets "setting_notes", "photo.filename_disk", "photo.title", "screen.filename_disk", "screen.title", - // Denormalized relations / fields "mat.name", "mat_coat.name", "mat_color.name", @@ -42,14 +40,15 @@ export default function CO2GalvoSettingDetailPage() { "mat_thickness", "source.make", "source.model", - // ✅ laser_soft is a STRING, not a relation - "laser_soft", "lens.field_size", "lens.focal_length", "lens_conf.name", "lens_apt.name", "lens_exp.name", "focus", + // ✅ handle both shapes + "laser_soft", + "laser_soft.name", "repeat_all", "fill_settings", "line_settings", @@ -69,12 +68,14 @@ export default function CO2GalvoSettingDetailPage() { if (loading) return
Loading setting...
; if (!setting) returnSetting not found.
; - // ✅ Prefer the owner's username (string). Return null if absent so claim UI shows. - const ownerName = (row: any) => { - const o = row?.owner; - if (!o) return null; - return o.username || null; - }; + // ✅ prefer username + const ownerName = (row: any) => row?.owner?.username ?? null; + + // Render “name” if relation, or raw string if the field is plain text. + const softwareLabel = + typeof setting.laser_soft === "object" + ? setting.laser_soft?.name ?? "—" + : setting.laser_soft ?? "—"; const formatBoolean = (val: any) => val ? "Enabled" : val === false ? "Disabled" : "—"; @@ -109,7 +110,6 @@ export default function CO2GalvoSettingDetailPage() { ); }; - // ✅ Point searches back to the list route under /settings const openSearchInNewTab = (value: string) => { if (!value || typeof window === "undefined") return; const url = new URL("/settings/co2-galvo", window.location.origin); @@ -161,8 +161,7 @@ export default function CO2GalvoSettingDetailPage() {- Owner:{" "} - {owner ? {owner} : —} + Owner: {owner ? {owner} : —}
Uploader: {setting.uploader || "—"} @@ -178,17 +177,12 @@ export default function CO2GalvoSettingDetailPage() { > {claimBusy ? "Submitting…" : "Claim this setting"} - {claimMsg && ( - {claimMsg} - )} - {claimErr && ( - {claimErr} - )} + {claimMsg && {claimMsg}} + {claimErr && {claimErr}}
- Color: {setting.mat_color?.name || "—"} -
-- Opacity: {setting.mat_opacity?.opacity || "—"} -
+Color: {setting.mat_color?.name || "—"}
+Opacity: {setting.mat_opacity?.opacity || "—"}
Thickness:{" "} {setting.mat_thickness ? `${setting.mat_thickness} mm` : "Not Applicable"} @@ -253,20 +243,13 @@ export default function CO2GalvoSettingDetailPage() { {/* Setup */}
- Software: {setting.laser_soft || "—"} -
-- Repeat All (global): {setting.repeat_all ?? "—"} -
-- Focus: {setting.focus ?? "—"} mm -
+Software: {softwareLabel}
+Repeat All (global): {setting.repeat_all ?? "—"}
+Focus: {setting.focus ?? "—"} mm
-Values Focus Closer | +Values Focus Further- Source Make: {setting.source?.make || "—"} -
+Source Make: {setting.source?.make || "—"}
Source Model:{" "} {" "} mm | {setting.lens?.focal_length || "—"}
-- Lens Config: {setting.lens_conf?.name || "—"} -
-- Aperture Type: {setting.lens_apt?.name || "—"} -
-- Expansion Type: {setting.lens_exp?.name || "—"} -
+Lens Config: {setting.lens_conf?.name || "—"}
+Aperture Type: {setting.lens_apt?.name || "—"}
+Expansion Type: {setting.lens_exp?.name || "—"}