// components/portal/RigsSwitcher.tsx
"use client";
import { useRouter, useSearchParams } from "next/navigation";
import { cn } from "@/lib/utils";
import RigsListClient from "@/app/rigs/RigsListClient";
const TABS = [
{ key: "my", label: "My Rigs" },
{ key: "add", label: "Add Rig" },
];
function Panel({ tab }: { tab: string }) {
switch (tab) {
case "my":
return (
);
case "add":
// Placeholder: we’ll retrofit the builder (or a minimal create form) next sprint
return (
Add Rig form will go here. We’ll wire to POST /api/my/rigs with user auth.
- Fields: name (required), rig_type (required), optional notes
- Use
/api/options/user_rig_type for types
- On success: refresh list tab
);
default:
return null;
}
}
export default function RigsSwitcher() {
const router = useRouter();
const sp = useSearchParams();
const active = sp.get("t") || "my";
function setTab(nextKey: string) {
const q = new URLSearchParams(sp.toString());
q.set("t", nextKey);
router.replace(`/portal/rigs?${q.toString()}`, { scroll: false });
}
return (
{TABS.map(({ key, label }) => (
))}
);
}