All files / src/features/collections CollectionHomeMenu.tsx

57.14% Statements 4/7
100% Branches 2/2
25% Functions 1/4
57.14% Lines 4/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 212x               27x 27x                 27x    
"use client";
 
import { useRouter } from "next/navigation";
import { OverflowMenu, type OverflowMenuItem } from "@/components/ui";
 
// The home's rarer actions (PRODUCT "Familiar first"): every member can add an
// item by hand; settings and members are the owner's (each page is server-gated too).
export function CollectionHomeMenu({ href, name, isOwner }: { href: string; name: string; isOwner: boolean }) {
  const router = useRouter();
  const items: OverflowMenuItem[] = [
    { label: "Add item", onSelect: () => router.push(`${href}/items/new`) },
    ...(isOwner
      ? [
          { label: "Collection settings", onSelect: () => router.push(`${href}/edit`) },
          { label: "Members", onSelect: () => router.push(`${href}/members`) },
        ]
      : []),
  ];
  return <OverflowMenu label={`More for ${name}`} items={items} />;
}