feat(api): implement new API routes for bulk category updates, inventory consumption, and product management with authentication

This commit is contained in:
Nils-Johan Gynther
2026-04-19 19:11:09 +02:00
parent 1ae9b336d8
commit 6f24aee18d
17 changed files with 440 additions and 85 deletions
+5 -7
View File
@@ -1,7 +1,6 @@
'use client';
import { useTransition } from 'react';
import { removePantryItem } from './actions';
import { useRouter } from 'next/navigation';
type PantryItem = {
id: number;
@@ -20,13 +19,12 @@ type Props = {
};
export default function PantryList({ items, inventoryByProductId }: Props) {
const [isPending, startTransition] = useTransition();
const router = useRouter();
function handleRemove(id: number, name: string) {
async function handleRemove(id: number, name: string) {
if (!confirm(`Ta bort "${name}" från baslagret?`)) return;
startTransition(async () => {
await removePantryItem(id);
});
const res = await fetch(`/api/admin/pantry-item/${id}`, { method: 'DELETE' });
if (res.ok) router.refresh();
}
if (items.length === 0) {