delete list
This commit is contained in:
@@ -72,6 +72,17 @@ class ShoppingListController {
|
||||
res.json({ success: true });
|
||||
}
|
||||
|
||||
deleteList(req, res) {
|
||||
const list = ShoppingListRepository.findById(req.params.id, req.user.household_id);
|
||||
if (!list) return res.status(404).json({ error: "Lijst niet gevonden" });
|
||||
|
||||
const result = ShoppingListRepository.deleteList(list.id);
|
||||
if (result.changes === 0) return res.status(404).json({ error: "Lijst niet gevonden" });
|
||||
|
||||
this.broadcastUpdate(req, list.id);
|
||||
res.json({ success: true });
|
||||
}
|
||||
|
||||
broadcastUpdate(req, listId) {
|
||||
if (req.app.locals.io) {
|
||||
req.app.locals.io.to(`list:${listId}`).emit("list:updated", { listId });
|
||||
|
||||
Reference in New Issue
Block a user