diff --git a/public/bestellformular/bestellformular.html b/public/bestellformular/bestellformular.html index 56b2411..7678c66 100644 --- a/public/bestellformular/bestellformular.html +++ b/public/bestellformular/bestellformular.html @@ -15,7 +15,7 @@
-
+

Bestellformular

@@ -42,11 +42,46 @@ - Bestellung absenden + Bestellung absenden
+ + diff --git a/public/bestellung/bestellung.html b/public/bestellung/bestellung.html index 54e2885..3916acd 100644 --- a/public/bestellung/bestellung.html +++ b/public/bestellung/bestellung.html @@ -25,6 +25,30 @@ + + diff --git a/server.js b/server.js index 53a0685..53cf5ba 100644 --- a/server.js +++ b/server.js @@ -168,6 +168,41 @@ app.post('/api/user/login', (req, res) => { }) }) +app.post('/api/bestellung', (req, res) => { + const { userId, productId} = req.body; + + // 1. Produktpreis holen + const productSql = 'SELECT price FROM product WHERE productId = ?'; + const producNameSql = 'SELECT name FROM product WHERE productId = ?'; + + db.query(productSql, [productId], (err, productResults) => { + if (err || productResults.length === 0) { + console.error('Fehler beim Abrufen des Produkts: ', err); + return res.status(500).json({ message: 'Produkt nicht gefunden oder Serverfehler' }); + } + + const productPrice = productResults[0].price; + + }); +}); + +app.get('/api/bestellung/daten', (req, res) => { + + + db.query(sql, [userId], (err, results) => { + if (err) { + console.error('Fehler beim Abrufen der Bestellung: ', err); + return res.status(500).json({ message: 'Fehler beim Abrufen der Bestellung' }); + } + + if (results.length === 0) { + return res.status(404).json({ message: 'Keine Bestellung gefunden' }); + } + + res.json(results); + }); +}); + const getIndexRoute = require('./scripts/routes/other/route-index'); app.use('/', getIndexRoute);