// components/portal/ProjectsSwitcher.tsx "use client"; import { useRouter, useSearchParams } from "next/navigation"; import dynamic from "next/dynamic"; import { cn } from "@/lib/utils"; // Canonical viewer page; use dynamic in a client component const ProjectsView = dynamic(() => import("@/app/projects/page"), { ssr: false }); const TABS = [ { key: "list", label: "Projects" }, { key: "add", label: "Add Project" }, ]; function Panel({ tab }: { tab: string }) { switch (tab) { case "list": return (
); case "add": return (

Add Project

Project submission form will be embedded here. We’ll wire to an authenticated endpoint (e.g. POST /api/my/projects) and auto-assign owner.
); default: return null; } } export default function ProjectsSwitcher() { const router = useRouter(); const sp = useSearchParams(); const active = sp.get("t") || "list"; function setTab(nextKey: string) { const q = new URLSearchParams(sp.toString()); q.set("t", nextKey); router.replace(`/portal/projects?${q.toString()}`, { scroll: false }); } return (
{TABS.map(({ key, label }) => ( ))}
); }