[id] pages render in portal

This commit is contained in:
makearmy 2025-09-27 17:45:20 -04:00
parent dcd88b200f
commit 656ad5fe7e
17 changed files with 1028 additions and 1025 deletions

View file

@ -1,9 +1,36 @@
// app/portal/laser-settings/page.tsx
import { redirect } from "next/navigation";
import SettingsSwitcher from "@/components/portal/SettingsSwitcher";
export const metadata = { title: "MakerDash • Laser Settings" };
export default function LaserSettingsPortalPage() {
function pickOne<T>(v: T | T[] | undefined): T | undefined {
if (Array.isArray(v)) return v[0];
return v;
}
export default function LaserSettingsPortalPage({
searchParams,
}: {
searchParams?: Record<string, string | string[] | undefined>;
}) {
// Read tab + optional id from query
const t = (pickOne(searchParams?.t) || "fiber").toLowerCase();
const id = pickOne(searchParams?.id);
// If an id is present, hop directly to the existing detail route
if (id) {
const slugMap: Record<string, string> = {
fiber: "fiber",
uv: "uv",
"co2-galvo": "co2-galvo",
"co2-gantry": "co2-gantry",
};
const slug = slugMap[t] ?? "fiber";
redirect(`/settings/${slug}/${encodeURIComponent(id)}`);
}
// Otherwise show the normal portal view
return (
<div className="rounded-lg border p-6">
<h2 className="mb-4 text-xl font-semibold">Laser Settings</h2>