Unterkategorien erstellt. CSS noch WIP. Neue Api + neue Routen erstellte
This commit is contained in:
parent
15ab8a999d
commit
263afe76b3
8
public/header_footer/footer.html
Normal file
8
public/header_footer/footer.html
Normal file
@ -0,0 +1,8 @@
|
||||
<!-- Fußzeiele -->
|
||||
<footer class="footer">
|
||||
<p>© 2025 Autohändler Webshop – Alle Rechte vorbehalten</p>
|
||||
<p>
|
||||
<a href="/impressum">Impressum</a> |
|
||||
<a href="/datenschutz">Datenschutz</a>
|
||||
</p>
|
||||
</footer>
|
||||
@ -5,7 +5,8 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./Styles/login/login.css">
|
||||
<link href="https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="./Styles/header/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/footer.css">
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<body>
|
||||
@ -40,6 +41,17 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script src="./script.js"></script>
|
||||
|
||||
<!-- Fußzeiele -->
|
||||
<div id="footer"></div>
|
||||
|
||||
<script>
|
||||
fetch('/footer')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
document.getElementById('footer').innerHTML = data;
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./Styles/registrieren/registrieren.css">
|
||||
<link href="https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/footer.css">
|
||||
<title>Registrieren</title>
|
||||
</head>
|
||||
<body>
|
||||
@ -58,6 +60,16 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script src="./passwordValidation.js"></script>
|
||||
|
||||
<!-- Fußzeiele -->
|
||||
<div id="footer"></div>
|
||||
|
||||
<script>
|
||||
fetch('/footer')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
document.getElementById('footer').innerHTML = data;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -6,7 +6,8 @@
|
||||
<title>Shop</title>
|
||||
<link rel="stylesheet" href="./Styles/shop/shop.css">
|
||||
<link href="https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="./Styles/header/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/footer.css">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
@ -20,65 +21,50 @@
|
||||
.catch(error => console.error('Fehler beim Laden des Headers:', error));
|
||||
</script>
|
||||
|
||||
<!-- Hauptinhalt -->
|
||||
<section style="padding: 20px 30px; text-align: left; background: #fff;">
|
||||
<h1>Willkommen im Webshop</h1>
|
||||
</section>
|
||||
|
||||
<main>
|
||||
<div id="product-list" class="card-grid">
|
||||
<!-- Hier werden die Produkte dynamisch eingefügt -->
|
||||
</div>
|
||||
<section class="card-grid" id="latest-products">
|
||||
<!-- Dynamische Produkte (5 aktuelle Produkte) -->
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const apiUrl = 'http://localhost:3000/api/products';
|
||||
fetch('/api/products')
|
||||
.then(res => res.json())
|
||||
.then(products => {
|
||||
const container = document.getElementById('latest-products');
|
||||
container.innerHTML = ''; // sicherheitshalber leeren
|
||||
|
||||
// Hole die Produktdaten von der API
|
||||
fetch(apiUrl)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const productList = document.getElementById('product-list');
|
||||
|
||||
// Iteriere durch die Produkte und erstelle HTML für jedes Produkt
|
||||
data.forEach(product => {
|
||||
products.forEach(product => {
|
||||
const card = document.createElement('div');
|
||||
card.classList.add('card');
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.src = product.imageUrl || 'https://shop.porsche.com/_next/image?url=https%3A%2F%2Fassets-prod.porsche.com%2Fassets%2Fce81555c-4f59-485e-9f9b-7a448a4d91b3.webp&w=2560&q=75';
|
||||
// Bild aus DB
|
||||
img.alt = product.name;
|
||||
|
||||
const name = document.createElement('h3');
|
||||
name.textContent = product.name;
|
||||
|
||||
const price = document.createElement('p');
|
||||
price.textContent = `Preis: ${product.price}€`;
|
||||
|
||||
const description = document.createElement('p');
|
||||
description.textContent = product.description || '';
|
||||
|
||||
const button = document.createElement('button');
|
||||
button.classList.add('add-to-cart');
|
||||
button.textContent = 'Zum Warenkorb hinzufügen';
|
||||
button.addEventListener('click', () => {
|
||||
console.log(`${product.name} wurde zum Warenkorb hinzugefügt`);
|
||||
});
|
||||
|
||||
// Alles zur Karte hinzufügen
|
||||
card.appendChild(img);
|
||||
card.appendChild(name);
|
||||
card.appendChild(price);
|
||||
card.appendChild(description);
|
||||
card.appendChild(button);
|
||||
|
||||
productList.appendChild(card);
|
||||
card.innerHTML = `
|
||||
<img src="${product.image_url}" alt="${product.name}">
|
||||
<h3>${product.name}</h3>
|
||||
<p>Preis: ${product.price}€</p>
|
||||
<p>${product.description}</p>
|
||||
<button class="add-to-cart" data-id="${product.id}">Zum Warenkorb hinzufügen</button>
|
||||
`;
|
||||
container.appendChild(card);
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Fehler beim Laden der Produkte:', error);
|
||||
.catch(err => {
|
||||
console.error('Fehler beim Laden der neuesten Produkte:', err);
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Fußzeiele -->
|
||||
<div id="footer"></div>
|
||||
|
||||
<script>
|
||||
fetch('/footer')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
document.getElementById('footer').innerHTML = data;
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@ -3,10 +3,11 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Shop</title>
|
||||
<title>Shop - LKW's</title>
|
||||
<link rel="stylesheet" href="./Styles/shop/shop.css">
|
||||
<link href="https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="./Styles/header/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/footer.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@ -15,5 +16,18 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Fußzeiele -->
|
||||
<div id="footer"></div>
|
||||
|
||||
<script>
|
||||
fetch('/footer')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
document.getElementById('footer').innerHTML = data;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -3,15 +3,67 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Shop</title>
|
||||
<title>Shop - Motorräder</title>
|
||||
<link rel="stylesheet" href="./Styles/shop/shop.css">
|
||||
<link href="https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="./Styles/header/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/footer.css">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<div id="header-placeholder"></div>
|
||||
<script>
|
||||
fetch(href="/header")
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
document.getElementById('header-placeholder').innerHTML = data;
|
||||
})
|
||||
.catch(error => console.error('Fehler beim Laden des Headers:', error));
|
||||
</script>
|
||||
|
||||
<!-- Hauptinhalt -->
|
||||
</br>
|
||||
<h1>Unsere Motorrad Produkte</h1>
|
||||
<section class="card-grid" id="products_motorrad">
|
||||
<!-- Dynamische Produkte (5 aktuelle Produkte) -->
|
||||
</section>
|
||||
|
||||
|
||||
<script>
|
||||
fetch('/api/products/motorrad')
|
||||
.then(res => res.json())
|
||||
.then(products => {
|
||||
const container = document.getElementById('products_motorrad');
|
||||
container.innerHTML = ''; // sicherheitshalber leeren
|
||||
|
||||
products.forEach(product => {
|
||||
const card = document.createElement('div');
|
||||
card.classList.add('card');
|
||||
card.innerHTML = `
|
||||
<img src="${product.image_url}" alt="${product.name}">
|
||||
<h3>${product.name}</h3>
|
||||
<p>Preis: ${product.price}€</p>
|
||||
<p>${product.description}</p>
|
||||
<button class="add-to-cart" data-id="${product.id}">Zum Warenkorb hinzufügen</button>
|
||||
`;
|
||||
container.appendChild(card);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Fehler beim Laden der neuesten Produkte:', err);
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Fußzeiele -->
|
||||
<div id="footer"></div>
|
||||
|
||||
<script>
|
||||
fetch('/footer')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
document.getElementById('footer').innerHTML = data;
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -3,15 +3,29 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Shop</title>
|
||||
<title>Shop - Oldtimer</title>
|
||||
<link rel="stylesheet" href="./Styles/shop/shop.css">
|
||||
<link href="https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="./Styles/header/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/footer.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Fußzeiele -->
|
||||
<div id="footer"></div>
|
||||
|
||||
<script>
|
||||
fetch('/footer')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
document.getElementById('footer').innerHTML = data;
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -3,14 +3,30 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Shop</title>
|
||||
<title>Shop - Sportwagen</title>
|
||||
<link rel="stylesheet" href="./Styles/shop/shop.css">
|
||||
<link href="https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="./Styles/header/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/footer.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Fußzeiele -->
|
||||
<div id="footer"></div>
|
||||
|
||||
<script>
|
||||
fetch('/footer')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
document.getElementById('footer').innerHTML = data;
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -3,13 +3,13 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Modellauto</title>
|
||||
<title>Modellauto - Startseite</title>
|
||||
<link rel="stylesheet" href="./Styles/startseite/startseite.css">
|
||||
<link href="https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/header_footer.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/header.css">
|
||||
<link rel="stylesheet" href="./Styles/header_footer/footer.css">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Wrapper für die gesamte Seite -->
|
||||
<div class="wrapper">
|
||||
<!-- Header -->
|
||||
<div id="header-placeholder"></div>
|
||||
@ -38,7 +38,7 @@
|
||||
</section>
|
||||
|
||||
<script>
|
||||
fetch('/api/products/latest')
|
||||
fetch('/api/products/new')
|
||||
.then(res => res.json())
|
||||
.then(products => {
|
||||
const container = document.getElementById('latest-products');
|
||||
@ -88,11 +88,15 @@
|
||||
</section>
|
||||
|
||||
<!-- Fußzeiele -->
|
||||
<footer style="background: #222; color: #fff; padding: 30px 20px; text-align: center; margin-top: 40px;">
|
||||
<p>© 2025 Autohändler Webshop – Alle Rechte vorbehalten</p>
|
||||
<p><a href="/impressum" style="color: #ff6600; text-decoration: none;">Impressum</a> |
|
||||
<a href="/datenschutz" style="color: #ff6600; text-decoration: none;">Datenschutz</a></p>
|
||||
</footer>
|
||||
<div id="footer"></div>
|
||||
|
||||
<script>
|
||||
fetch('/footer')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
document.getElementById('footer').innerHTML = data;
|
||||
});
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
const path = require('path');
|
||||
const router = require('express').Router();
|
||||
|
||||
// Route - Startseite
|
||||
router.get('/', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../../../public/startseite/startseite.html'));
|
||||
})
|
||||
@ -9,20 +10,51 @@ router.get('/example', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../../../public/example/index.html'));
|
||||
})
|
||||
|
||||
// Route - Login
|
||||
router.get('/login', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../../../public/login/login.html'));
|
||||
})
|
||||
|
||||
// Route - Registrieren
|
||||
router.get('/registrieren', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../../../public/registrieren/registrieren.html'));
|
||||
})
|
||||
|
||||
// Route - Kopfzeile
|
||||
router.get('/header', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../../../public/header_footer/header_footer.html'));
|
||||
res.sendFile(path.join(__dirname, '../../../public/header_footer/header.html'));
|
||||
})
|
||||
|
||||
// Route - Fußzeile
|
||||
router.get('/footer', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../../../public/header_footer/footer.html'));
|
||||
})
|
||||
|
||||
// Route - Shop (Alle Produkte)
|
||||
router.get('/shop', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../../../public/shop/shop.html'));
|
||||
})
|
||||
|
||||
// Route - Shop_Motorrad (Filtern nach Motorrad Produkten)
|
||||
router.get('/shop/motorrad', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../../../public/shop/shop_motorrad.html'));
|
||||
})
|
||||
|
||||
// Route - Shop_Oldtimer (Filtern nach Oldtimer Produkten)
|
||||
router.get('/shop/oldtimer', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../../../public/shop/shop_oldtimer.html'));
|
||||
})
|
||||
|
||||
// Route - Shop_Sportwagen (Filtern nach Sportwagen Produkten)
|
||||
router.get('/shop/sportwagen', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../../../public/shop/shop_sportwagen.html'));
|
||||
})
|
||||
|
||||
// Route - Shop_LKW (Filtern nach LKW Produkten)
|
||||
router.get('/shop/lkw', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../../../public/shop/shop_lkw.html'));
|
||||
})
|
||||
|
||||
|
||||
|
||||
module.exports = router;
|
||||
17
server.js
17
server.js
@ -52,7 +52,7 @@ app.get('/api/products', (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/api/products/latest', async (req, res) => {
|
||||
app.get('/api/products/new', async (req, res) => {
|
||||
// SQL-Abfrage für Produktdaten
|
||||
const sql = 'SELECT * FROM webshop.product ORDER BY created_at DESC LIMIT 5';
|
||||
|
||||
@ -67,6 +67,21 @@ app.get('/api/products/latest', async (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/api/products/motorrad', async (req, res) => {
|
||||
// SQL-Abfrage für Produktdaten
|
||||
const sql = 'SELECT * FROM webshop.product_category WHERE id = 4';
|
||||
|
||||
// Abfrage ausführen
|
||||
db.query(sql, (err, results) => {
|
||||
if (err) {
|
||||
console.error('Fehler beim Abrufen der Produkte:', err);
|
||||
res.status(500).send('Fehler beim Abrufen der Produkte');
|
||||
return;
|
||||
}
|
||||
res.json(results); // Rückgabe der Produktdaten als JSON
|
||||
});
|
||||
});
|
||||
|
||||
const getIndexRoute = require('./scripts/routes/other/route-index');
|
||||
app.use('/', getIndexRoute);
|
||||
|
||||
|
||||
16
static/Styles/header_footer/footer.css
Normal file
16
static/Styles/header_footer/footer.css
Normal file
@ -0,0 +1,16 @@
|
||||
.footer {
|
||||
background: #222;
|
||||
color: #fff;
|
||||
padding: 30px 20px;
|
||||
text-align: center;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.footer a {
|
||||
color: #ff6600;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.footer a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user