makearmy-app/app/portal/laser-settings/Client.tsx

59 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-10-03 19:05:32 -04:00
// app/portal/laser-settings/Client.tsx
2025-09-27 18:34:59 -04:00
"use client";
import dynamic from "next/dynamic";
import { useSearchParams } from "next/navigation";
const SettingsSwitcher = dynamic(
() => import("@/components/portal/SettingsSwitcher"),
{ ssr: false }
);
function DetailsFrame({ src }: { src: string }) {
return (
<iframe
key={src}
src={src}
className="w-full h-[70vh] rounded-md border"
sandbox="allow-same-origin allow-scripts allow-forms allow-popups"
/>
);
}
export default function LaserSettingsClient() {
const search = useSearchParams();
const t = (search.get("t") || "fiber").toLowerCase();
const id = search.get("id");
2025-10-03 19:05:32 -04:00
const view = (search.get("view") || "list").toLowerCase();
2025-09-27 18:34:59 -04:00
2025-10-03 19:05:32 -04:00
// Only use legacy detail pages for tabs we haven't migrated yet.
// CO₂ Galvo renders its detail INSIDE the panel, so never iFrame it here.
2025-09-27 18:34:59 -04:00
const detailSrc =
2025-10-03 19:05:32 -04:00
id && view === "detail" && (t === "fiber" || t === "uv" || t === "co2-gantry")
? t === "fiber"
2025-09-27 18:34:59 -04:00
? `/settings/fiber/${id}`
: t === "uv"
? `/settings/uv/${id}`
2025-10-03 19:05:32 -04:00
: `/settings/co2-gantry/${id}`
2025-09-27 18:34:59 -04:00
: null;
return (
<div className="space-y-4">
<div className="rounded-lg border p-6">
<h2 className="mb-4 text-xl font-semibold">Laser Settings</h2>
<SettingsSwitcher />
</div>
2025-10-03 19:05:32 -04:00
{/* Only show legacy iframe for non-CO₂ Galvo tabs, and only when explicitly in detail view */}
2025-09-27 18:34:59 -04:00
{detailSrc && (
<div className="rounded-lg border p-4">
<div className="mb-2 text-sm opacity-70">
Viewing detail #{id} ({t})
</div>
<DetailsFrame src={detailSrc} />
</div>
)}
</div>
);
}