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
@@ -1,6 +1,7 @@
import {
Body,
Controller,
Delete,
Get,
Param,
ParseIntPipe,
@@ -55,4 +56,9 @@ findConsumptionHistory(@Param('id', ParseIntPipe) id: number) {
) {
return this.inventoryService.update(id, body);
}
@Delete(':id')
remove(@Param('id', ParseIntPipe) id: number) {
return this.inventoryService.remove(id);
}
}
@@ -239,4 +239,12 @@ export class InventoryService {
},
});
}
async remove(id: number) {
const existing = await this.prisma.inventoryItem.findUnique({ where: { id } });
if (!existing) {
throw new NotFoundException(`Inventory item with id ${id} not found`);
}
return this.prisma.inventoryItem.delete({ where: { id } });
}
}