feat: implement inventory and pantry management views with CRUD functionality and user-friendly interfaces

This commit is contained in:
Nils-Johan Gynther
2026-04-21 14:43:18 +02:00
parent 82c3dc3fee
commit 81b63b3fdb
14 changed files with 352 additions and 59 deletions
@@ -29,3 +29,28 @@ export async function PATCH(req: Request, { params }: { params: Promise<{ id: st
return NextResponse.json({ ok: true });
}
export async function DELETE(_req: Request, { params }: { params: Promise<{ id: string }> }) {
const session = await auth();
if (!session?.accessToken) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const { id } = await params;
const res = await fetch(`${API_BASE}/api/inventory/${id}`, {
method: 'DELETE',
headers: {
Authorization: `Bearer ${session.accessToken}`,
},
cache: 'no-store',
});
if (!res.ok) {
const text = await res.text();
return NextResponse.json({ error: text || 'Kunde inte ta bort inventory-rad' }, { status: res.status });
}
return NextResponse.json({ ok: true });
}