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 048152c..9b8ae8b 100644 --- a/public/bestellformular/bestellformular.html +++ b/public/bestellformular/bestellformular.html @@ -20,13 +20,13 @@

Bestellformular

- + - + - + @@ -40,10 +40,8 @@
- - + +
@@ -79,6 +77,11 @@ max-width: 20%; padding-left: 2.5%; } + + #KundenNr, #Vorname, #Nachname{ + background-color: #F5F5F5; + border: none; + } Bestellung absenden @@ -86,10 +89,31 @@ diff --git a/public/header_footer/header.html b/public/header_footer/header.html index 40e272c..476eaf5 100644 --- a/public/header_footer/header.html +++ b/public/header_footer/header.html @@ -21,7 +21,7 @@ - 0 + 0 diff --git a/public/login/login.html b/public/login/login.html index 08c1c7b..92f7e6e 100644 --- a/public/login/login.html +++ b/public/login/login.html @@ -43,7 +43,7 @@ - +

@@ -71,6 +71,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 692e036..53f69e4 100644 --- a/public/registrieren/registrieren.html +++ b/public/registrieren/registrieren.html @@ -101,6 +101,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 eadd094..2d81b71 100644 --- a/public/shop/shop.html +++ b/public/shop/shop.html @@ -37,12 +37,35 @@

diff --git a/public/shop/shop_lkw.html b/public/shop/shop_lkw.html index 0f15d10..35e0038 100644 --- a/public/shop/shop_lkw.html +++ b/public/shop/shop_lkw.html @@ -39,39 +39,68 @@ diff --git a/public/shop/shop_motorrad.html b/public/shop/shop_motorrad.html index 5af6521..6dec727 100644 --- a/public/shop/shop_motorrad.html +++ b/public/shop/shop_motorrad.html @@ -38,38 +38,67 @@ diff --git a/public/shop/shop_oldtimer.html b/public/shop/shop_oldtimer.html index 2a6155d..1fdc1ca 100644 --- a/public/shop/shop_oldtimer.html +++ b/public/shop/shop_oldtimer.html @@ -37,7 +37,30 @@ - diff --git a/public/shop/shop_sportwagen.html b/public/shop/shop_sportwagen.html index bcc3e6d..52c44b4 100644 --- a/public/shop/shop_sportwagen.html +++ b/public/shop/shop_sportwagen.html @@ -38,42 +38,70 @@ - + \ No newline at end of file diff --git a/public/startseite/startseite.html b/public/startseite/startseite.html index 4200fdd..c9ec7b2 100644 --- a/public/startseite/startseite.html +++ b/public/startseite/startseite.html @@ -38,41 +38,66 @@ diff --git a/scripts/einfügenHeaderFooter.js b/scripts/einfügenHeaderFooter.js index 0d646ed..a9fb954 100644 --- a/scripts/einfügenHeaderFooter.js +++ b/scripts/einfügenHeaderFooter.js @@ -20,6 +20,11 @@ document.addEventListener("DOMContentLoaded", () => { .then(data => { // Header-Inhalt in die Seite einfügen headerTarget.innerHTML = data; + + // 🚀 WICHTIG: Jetzt den Warenkorb zählen, nachdem der Header geladen ist! + zeigeWarenkorbAnzahl(); + + zeigeLoginStatus(); }) .catch(error => { // Fehlerbehandlung: Fehlermeldung im Header-Bereich anzeigen @@ -54,4 +59,40 @@ 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); + } + + window.zeigeLoginStatus= function (){ + const userId = sessionStorage.getItem('user_id') + const loginBtn = document.querySelector('.login-btn') + + if (!loginBtn) return + + if (userId) { + loginBtn.textContent = 'Logout' + loginBtn.href = '#' + loginBtn.addEventListener('click', (e) => { + e.preventDefault() + sessionStorage.clear() + alert('Sie wurden ausgeloggt.') + location.reload() + }) + } else { + loginBtn.textContent = 'Login' + loginBtn.href= '/login' + } + } +}); \ No newline at end of file diff --git a/server.js b/server.js index ac0c8a7..6c97d50 100644 --- a/server.js +++ b/server.js @@ -168,8 +168,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}) }) })