'use client'; import { useTransition } from 'react'; import { removePantryItem } from './actions'; type PantryItem = { id: number; product: { id: number; name: string; canonicalName: string | null; category: string | null }; }; type Props = { items: PantryItem[]; }; export default function PantryList({ items }: Props) { const [isPending, startTransition] = useTransition(); function handleRemove(id: number, name: string) { if (!confirm(`Ta bort "${name}" från baslagret?`)) return; startTransition(async () => { await removePantryItem(id); }); } if (items.length === 0) { return (
Baslagret är tomt. Lägg till produkter ovan.
); } // Gruppera per kategori const grouped = items.reduce