import { Link, useNavigate } from "react-router-dom"; import { ChevronDown } from "lucide-react"; interface SliceSubNavProps { handle: string; rkey: string; sliceName?: string; activeTab: | "overview" | "records" | "jetstream" | "sync" | "oauth" | "settings"; isOwner?: boolean; } export function SliceSubNav( { handle, rkey, sliceName, activeTab, isOwner = false }: SliceSubNavProps, ) { const navigate = useNavigate(); const allTabs = [ { value: "overview", label: "Overview", path: `/profile/${handle}/slice/${rkey}`, ownerOnly: false, }, { value: "records", label: "Records", path: `/profile/${handle}/slice/${rkey}/records`, ownerOnly: false, }, { value: "jetstream", label: "Jetstream", path: `/profile/${handle}/slice/${rkey}/jetstream`, ownerOnly: false, }, { value: "sync", label: "Sync", path: `/profile/${handle}/slice/${rkey}/sync`, ownerOnly: true, }, { value: "oauth", label: "OAuth", path: `/profile/${handle}/slice/${rkey}/oauth`, ownerOnly: true, }, { value: "settings", label: "Settings", path: `/profile/${handle}/slice/${rkey}/settings`, ownerOnly: true, }, ]; // Filter tabs based on ownership const tabs = allTabs.filter(tab => !tab.ownerOnly || isOwner); const handleChange = (e: React.ChangeEvent) => { const selectedTab = tabs.find((tab) => tab.value === e.target.value); if (selectedTab) { navigate(selectedTab.path); } }; return (
Slices / @{handle} {sliceName && ( <> / {sliceName} )}
); }