added project, material, sources to portal
This commit is contained in:
parent
c7511b98fc
commit
45d4e08cd8
9 changed files with 90 additions and 282 deletions
59
components/portal/MaterialsSwitcher.tsx
Normal file
59
components/portal/MaterialsSwitcher.tsx
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
// components/portal/MaterialsSwitcher.tsx
|
||||
"use client";
|
||||
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import dynamic from "next/dynamic";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
// Reuse the *existing* canonical pages.
|
||||
// Adjust paths if your folders differ.
|
||||
const MaterialsPanel = dynamic(() => import("@/app/materials/materials/page"), { ssr: false });
|
||||
const CoatingsPanel = dynamic(() => import("@/app/materials/materials-coatings/page"), { ssr: false });
|
||||
|
||||
const TABS = [
|
||||
{ key: "materials", label: "Materials" },
|
||||
{ key: "materials-coatings", label: "Coatings" },
|
||||
];
|
||||
|
||||
function Panel({ tab }: { tab: string }) {
|
||||
switch (tab) {
|
||||
case "materials": return <MaterialsPanel />;
|
||||
case "materials-coatings": return <CoatingsPanel />;
|
||||
default: return <MaterialsPanel />;
|
||||
}
|
||||
}
|
||||
|
||||
export default function MaterialsSwitcher() {
|
||||
const router = useRouter();
|
||||
const sp = useSearchParams();
|
||||
const active = sp.get("t") || "materials";
|
||||
|
||||
function setTab(nextKey: string) {
|
||||
const q = new URLSearchParams(sp.toString());
|
||||
q.set("t", nextKey);
|
||||
router.replace(`/portal/materials?${q.toString()}`, { scroll: false });
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-4 flex flex-wrap items-center gap-2">
|
||||
{TABS.map(({ key, label }) => (
|
||||
<button
|
||||
key={key}
|
||||
onClick={() => setTab(key)}
|
||||
className={cn(
|
||||
"rounded-md border px-3 py-1.5 text-sm transition",
|
||||
active === key ? "bg-primary text-primary-foreground" : "hover:bg-muted"
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="rounded-md border p-4">
|
||||
<Panel tab={active} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue