feat(api): implement new API routes for bulk category updates, inventory consumption, and product management with authentication
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user