co2 galvo owner test

This commit is contained in:
makearmy 2025-10-01 18:51:00 -04:00
parent 8b9987c0a0
commit 39d9723e23

View file

@ -10,7 +10,6 @@ export default function CO2GalvoSettingDetailPage() {
const [setting, setSetting] = useState<any>(null);
const [loading, setLoading] = useState(true);
// claim UI state
const [claimBusy, setClaimBusy] = useState(false);
const [claimMsg, setClaimMsg] = useState<string | null>(null);
const [claimErr, setClaimErr] = useState<string | null>(null);
@ -25,7 +24,7 @@ export default function CO2GalvoSettingDetailPage() {
"submission_id",
"setting_title",
"uploader",
// ✅ fetch username directly
// ✅ request username explicitly
"owner.id",
"owner.username",
"setting_notes",
@ -46,7 +45,7 @@ export default function CO2GalvoSettingDetailPage() {
"lens_apt.name",
"lens_exp.name",
"focus",
// ✅ handle both shapes
// ✅ handle string-or-relation
"laser_soft",
"laser_soft.name",
"repeat_all",
@ -68,10 +67,11 @@ export default function CO2GalvoSettingDetailPage() {
if (loading) return <p className="p-6">Loading setting...</p>;
if (!setting) return <p className="p-6">Setting not found.</p>;
// ✅ prefer username
const ownerName = (row: any) => row?.owner?.username ?? null;
// ✅ prefer username; fall back to id or uploader (just in case)
const ownerName = (row: any) =>
row?.owner?.username ?? (row?.owner?.id ? String(row.owner.id) : null) ?? null;
// Render “name” if relation, or raw string if the field is plain text.
// ✅ show string or relation.name
const softwareLabel =
typeof setting.laser_soft === "object"
? setting.laser_soft?.name ?? "—"
@ -97,10 +97,8 @@ export default function CO2GalvoSettingDetailPage() {
return (
<p key={key} className="text-sm">
<strong>{label}:</strong>{" "}
{typeof value === "boolean"
? formatBoolean(value)
: value || "—"}
</p>
{typeof value === "boolean" ? formatBoolean(value) : value || "—"}
</p>
);
})}
</div>