Werk hoofdapplicatie bij

Legt de bestaande wijzigingen in de hoofdworktree vast voordat de laatste worktree wordt gemerged.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-08-07 20:45:36 +02:00
parent 26a820b41a
commit c07d503d83
41 changed files with 1837 additions and 313 deletions
+29 -11
View File
@@ -1,35 +1,53 @@
const ProductService =
require("../services/ProductService");
const db = require("../config/database");
class ProductController {
index(req,res) {
index(req, res) {
const products =
ProductService.getProducts();
const categories = db.prepare(`
SELECT * FROM categories ORDER BY name
`).all();
res.locals.title = "Producten";
res.render(
"products/index",
{
title:"Producten",
products
products,
categories,
user: req.user
}
);
}
create(req, res) {
const { name, category_id } = req.body;
if (!name || name.trim().length === 0) {
req.flash("error", "Geef een productnaam op");
return res.redirect("/products");
}
ProductService.createProduct({
name: name.trim(),
category_id: category_id || null
});
req.flash("success", "Product toegevoegd");
res.redirect("/products");
}
}
module.exports =
new ProductController();