Multi tenant DB, registratie per huishouden V1.2
This commit is contained in:
@@ -25,8 +25,8 @@ class ShoppingListController {
|
||||
res.locals.title = list.name;
|
||||
res.render("lists/show", {
|
||||
list,
|
||||
items: ShoppingListRepository.getItems(list.id),
|
||||
products: ProductRepository.getAll(),
|
||||
items: ShoppingListRepository.getItems(list.id, req.user.household_id),
|
||||
products: ProductRepository.getAll(req.user.household_id),
|
||||
user: req.user
|
||||
});
|
||||
}
|
||||
@@ -35,7 +35,9 @@ class ShoppingListController {
|
||||
const list = ShoppingListRepository.findById(req.params.id, req.user.household_id);
|
||||
const productId = Number.parseInt(req.body.product_id, 10);
|
||||
const amount = Number.parseFloat(req.body.amount || "1");
|
||||
const product = Number.isInteger(productId) ? ProductRepository.findById(productId) : null;
|
||||
const product = Number.isInteger(productId)
|
||||
? ProductRepository.findById(productId, req.user.household_id)
|
||||
: null;
|
||||
if (!list || !product || !Number.isFinite(amount) || amount <= 0) {
|
||||
req.flash("error", "Ongeldig product of ongeldige hoeveelheid");
|
||||
return res.redirect(`/lists/${req.params.id}`);
|
||||
|
||||
Reference in New Issue
Block a user