From f99c8d11abf3dfed61316a8f6829b23b262ff0ce Mon Sep 17 00:00:00 2001 From: florianspengler Date: Tue, 29 Apr 2025 14:29:12 +0200 Subject: [PATCH] =?UTF-8?q?warenkorb=20=C3=BCberarbeitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/Warenkorb/warenkorb.html | 156 +++++++++++++++++--- public/bestellformular/bestellformular.html | 64 ++++++-- public/header_footer/header.html | 2 +- public/login/login.html | 2 + public/registrieren/registrieren.html | 2 + public/shop/shop.html | 58 ++++++-- public/shop/shop_lkw.html | 57 +++++-- public/shop/shop_motorrad.html | 61 ++++++-- public/shop/shop_oldtimer.html | 63 ++++++-- public/shop/shop_sportwagen.html | 73 ++++++--- public/startseite/startseite.html | 90 +++++++---- scripts/einfĂĽgenHeaderFooter.js | 20 ++- server.js | 4 +- 13 files changed, 507 insertions(+), 145 deletions(-) diff --git a/public/Warenkorb/warenkorb.html b/public/Warenkorb/warenkorb.html index 762972d..011faa7 100644 --- a/public/Warenkorb/warenkorb.html +++ b/public/Warenkorb/warenkorb.html @@ -11,28 +11,144 @@
-

đź›’ Dein Warenkorb

- -
-
- Produkt 1 - -
- -
- -
-
- Produkt 2 -
- -
- -
-
- +
+

Dein Warenkorb

+
+
+ +
+ + diff --git a/public/bestellformular/bestellformular.html b/public/bestellformular/bestellformular.html index 793c685..ccff5aa 100644 --- a/public/bestellformular/bestellformular.html +++ b/public/bestellformular/bestellformular.html @@ -19,13 +19,13 @@

Bestellformular

- + - + - + @@ -37,12 +37,6 @@ -
- - - -
-
Bestellung absenden @@ -83,10 +82,32 @@ diff --git a/public/header_footer/header.html b/public/header_footer/header.html index 20ec0f6..c2db739 100644 --- a/public/header_footer/header.html +++ b/public/header_footer/header.html @@ -10,7 +10,7 @@ - 0 + 0 diff --git a/public/login/login.html b/public/login/login.html index 52d9e7a..bcc3c12 100644 --- a/public/login/login.html +++ b/public/login/login.html @@ -51,6 +51,8 @@ if (response.ok) { const data = await response.json(); sessionStorage.setItem("user_id", data.id) + sessionStorage.setItem("vorname", data.name) + sessionStorage.setItem("nachname", data.lower_name) alert('Login erfolgreich!'); window.location.href = '/'; // Redirect to home page after login } else { diff --git a/public/registrieren/registrieren.html b/public/registrieren/registrieren.html index e2a34b5..d28221b 100644 --- a/public/registrieren/registrieren.html +++ b/public/registrieren/registrieren.html @@ -76,6 +76,8 @@ if (response.ok) { const data = await response.json(); sessionStorage.setItem("user_id", data.id) + sessionStorage.setItem("vorname", data.name) + sessionStorage.setItem("nachname", data.lower_name) alert('Nutzer erfolgreich hinzugefügt! Ihre Kundennummer: ' + data.id) window.location.href= '/' } else { diff --git a/public/shop/shop.html b/public/shop/shop.html index 37ae415..d24e94f 100644 --- a/public/shop/shop.html +++ b/public/shop/shop.html @@ -27,35 +27,65 @@ diff --git a/public/shop/shop_lkw.html b/public/shop/shop_lkw.html index a8b105e..1ded1b7 100644 --- a/public/shop/shop_lkw.html +++ b/public/shop/shop_lkw.html @@ -29,36 +29,65 @@ diff --git a/public/shop/shop_motorrad.html b/public/shop/shop_motorrad.html index 1570ecf..43f6382 100644 --- a/public/shop/shop_motorrad.html +++ b/public/shop/shop_motorrad.html @@ -26,34 +26,65 @@ diff --git a/public/shop/shop_oldtimer.html b/public/shop/shop_oldtimer.html index 15f6f1f..c659798 100644 --- a/public/shop/shop_oldtimer.html +++ b/public/shop/shop_oldtimer.html @@ -29,34 +29,65 @@ diff --git a/public/shop/shop_sportwagen.html b/public/shop/shop_sportwagen.html index 97d720c..a87fde4 100644 --- a/public/shop/shop_sportwagen.html +++ b/public/shop/shop_sportwagen.html @@ -29,38 +29,67 @@ - + \ No newline at end of file diff --git a/public/startseite/startseite.html b/public/startseite/startseite.html index 93f859d..171b85f 100644 --- a/public/startseite/startseite.html +++ b/public/startseite/startseite.html @@ -30,40 +30,66 @@ diff --git a/scripts/einfügenHeaderFooter.js b/scripts/einfügenHeaderFooter.js index 08ad09d..a48657a 100644 --- a/scripts/einfügenHeaderFooter.js +++ b/scripts/einfügenHeaderFooter.js @@ -9,6 +9,9 @@ document.addEventListener("DOMContentLoaded", () => { }) .then(data => { headerTarget.innerHTML = data; + + // 🚀 WICHTIG: Jetzt den Warenkorb zählen, nachdem der Header geladen ist! + zeigeWarenkorbAnzahl(); }) .catch(error => { headerTarget.innerHTML = ` @@ -38,4 +41,19 @@ document.addEventListener("DOMContentLoaded", () => { console.error(error); }); } -}); + + window.zeigeWarenkorbAnzahl = function() { + const warenkorb = JSON.parse(localStorage.getItem('warenkorb')) || []; + let anzahl = 0; + + warenkorb.forEach(produkt => { + anzahl += produkt.quantity; + }); + + const anzahlElement = document.getElementById('cart-count'); + if (anzahlElement) { + anzahlElement.textContent = anzahl; + } + console.log('Warenkorb-Anzahl:', anzahl); + } +}); \ No newline at end of file diff --git a/server.js b/server.js index 59b3e21..7b339bf 100644 --- a/server.js +++ b/server.js @@ -163,8 +163,10 @@ app.post('/api/user/login', (req, res) => { req.session.userId = user.id; req.session.email = user.email; + req.session.vorname = user.name; + req.session.nachname = user.lower_name; - res.json({message: 'Login erfolgreich', id: user.id}) + res.json({message: 'Login erfolgreich', id: user.id, name: user.name, lower_name: user.lower_name}) }) })