This commit is contained in:
Lheorvine 2025-06-01 19:01:12 +02:00
parent 26c7ac9341
commit 07cda1b5ad
9 changed files with 0 additions and 56 deletions

View file

@ -12,7 +12,6 @@
--light-card: #ffffff;
}
/* Reset i podstawowe style */
* {
margin: 0;
padding: 0;
@ -31,7 +30,6 @@ body {
flex-direction: column;
}
/* Motyw ciemny - domyślny */
body.dark-theme {
background-color: var(--dark-primary);
color: var(--dark-text);
@ -93,7 +91,6 @@ body.dark-theme .order-card .list-group-item strong {
color: #d4af37;
}
/* Motyw jasny */
body.light-theme {
background-color: var(--light-primary);
color: var(--light-text);
@ -133,7 +130,6 @@ body.light-theme footer {
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
/* Wspólne style dla obu motywów */
.navbar {
padding: 1rem 0;
transition: background-color 0.3s ease;
@ -319,7 +315,6 @@ footer a:hover {
transform: scale(1.05);
}
/* Responsywność */
@media (max-width: 1200px) {
.books-grid {
grid-template-columns: repeat(4, 1fr);
@ -350,7 +345,6 @@ footer a:hover {
}
}
/* Koszyk */
#cart-items .card {
margin-bottom: 1.5rem;
}
@ -374,19 +368,16 @@ footer a:hover {
font-weight: bold;
}
/* Animacje dla ilości */
.quantity-change {
transition: opacity 0.15s ease, transform 0.15s ease;
}
/* Formularze */
.form-control, .form-select {
border-radius: 0;
padding: 0.75rem;
font-size: 1rem;
}
/* Responsywność */
@media (max-width: 768px) {
.navbar-brand {
font-size: 1.5rem;
@ -406,7 +397,6 @@ footer a:hover {
}
}
/* Animacje spinnera */
@keyframes spin {
to { transform: rotate(360deg); }
}
@ -416,7 +406,6 @@ footer a:hover {
color: var(--gold);
}
/* Alerty */
.alert {
border-radius: 0;
padding: 1rem;
@ -435,12 +424,10 @@ footer a:hover {
color: #0dcaf0;
}
/* Ikony w koszyku */
.bi {
vertical-align: middle;
}
/* Strona podziękowania */
.py-5 {
padding-top: 6rem !important;
padding-bottom: 6rem !important;
@ -456,7 +443,6 @@ footer a:hover {
margin-bottom: 3rem;
}
/* Układ dla strony profilu */
#order-history .card {
margin-bottom: 1.5rem;
}

View file

@ -5,7 +5,6 @@ document.addEventListener('DOMContentLoaded', function() {
const registerForm = document.getElementById('registerForm');
const logoutLink = document.getElementById('logoutLink');
// Sprawdź status uwierzytelnienia przy załadowaniu
checkAuthStatus();
if (loginForm) {

View file

@ -7,7 +7,6 @@ document.addEventListener('DOMContentLoaded', function() {
if (bookId) {
loadBookDetails(bookId);
// Dodaj obsługę przycisku "Dodaj do koszyka"
const addToCartBtn = document.querySelector('.btn-add-to-cart');
if (addToCartBtn) {
addToCartBtn.addEventListener('click', () => addToCart(bookId));

View file

@ -5,10 +5,8 @@ document.addEventListener('DOMContentLoaded', function() {
const searchInput = document.getElementById('searchInput');
const sortSelect = document.getElementById('sortSelect');
// Załaduj książki przy starcie
loadBooks();
// Dodaj event listeners
if (searchInput) {
searchInput.addEventListener('input', debounce(loadBooks, 300));
}
@ -96,7 +94,6 @@ function displayBooks(books) {
booksContainer.innerHTML += bookCard;
});
// Dodajemy nasłuchiwanie na przyciskach dodania do koszyka
document.querySelectorAll('.add-to-cart-btn').forEach(button => {
button.addEventListener('click', function() {
const bookId = this.dataset.bookId;

View file

@ -3,13 +3,10 @@ document.addEventListener('DOMContentLoaded', function() {
const checkoutBtn = document.getElementById('checkoutBtn');
const localPickupCheckbox = document.getElementById('localPickup');
// Załaduj zawartość koszyka
loadCart();
// Dodaj event listeners
if (localPickupCheckbox) {
localPickupCheckbox.addEventListener('change', function() {
// Pobierz aktualny stan koszyka i zaktualizuj podsumowanie
const cartItems = Array.from(document.querySelectorAll('.card.mb-3')).map(card => {
const bookId = card.querySelector('.decrease-btn').dataset.bookId;
const quantity = parseInt(card.querySelector('.quantity-display').textContent);
@ -60,7 +57,6 @@ async function loadCart() {
const cartItems = await response.json();
displayCartItems(cartItems);
// Ustaw checkbox jako odznaczony domyślnie (dostawa)
const localPickupCheckbox = document.getElementById('localPickup');
if (localPickupCheckbox) {
localPickupCheckbox.checked = false;
@ -124,7 +120,6 @@ function displayCartItems(cartItems) {
cartItemsContainer.innerHTML += itemElement;
});
// Dodaj event listeners dla przycisków
document.querySelectorAll('.decrease-btn').forEach(btn => {
btn.addEventListener('click', () => updateCartItemQuantity(btn.dataset.bookId, -1));
});
@ -157,7 +152,6 @@ async function updateCartItemQuantity(bookId, change) {
const currentQuantity = parseInt(quantityElement.textContent);
const newQuantity = currentQuantity + change;
// Jeśli nowa ilość jest mniejsza lub równa 0, usuń produkt
if (newQuantity <= 0) {
const cartItem = quantityElement.closest('.card');
cartItem.style.opacity = '0';
@ -166,13 +160,11 @@ async function updateCartItemQuantity(bookId, change) {
updateSummaryFromDOM();
}, 300);
// Dodatkowo wyślij żądanie usunięcia z serwera
await fetch(`/api/remove-from-cart/${bookId}`, {
method: 'DELETE',
credentials: 'include'
});
} else {
// Animacja zmiany ilości
quantityElement.textContent = newQuantity;
updateSummaryFromDOM();
}
@ -213,7 +205,6 @@ function updateSummary(cartItems) {
if (!productsValueEl || !deliveryValueEl || !totalValueEl) return;
// Oblicz wartość produktów
let productsValue = 0;
if (cartItems && cartItems.length > 0) {
productsValue = cartItems.reduce((total, item) => {
@ -223,7 +214,6 @@ function updateSummary(cartItems) {
productsValueEl.textContent = productsValue.toFixed(2) + ' PLN';
// Oblicz koszt dostawy: jeśli checkbox ZAZNACZONY to 0 (odbiór lokalny), w przeciwnym razie 12.99 (dostawa)
const deliveryCost = localPickupCheckbox && localPickupCheckbox.checked ? 12.99 : 0;
deliveryValueEl.textContent = deliveryCost.toFixed(2) + ' PLN';
@ -259,7 +249,6 @@ async function handleCheckout() {
}
try {
// Pobierz aktualną zawartość koszyka
const response = await fetch('/api/cart', {
credentials: 'include'
});
@ -270,18 +259,15 @@ async function handleCheckout() {
const cartItems = await response.json();
// Przygotuj dane do zamówienia
const checkoutData = {
items: cartItems.map(item => ({
book_id: item.book_id,
quantity: item.quantity
})),
total: parseFloat(document.getElementById('total-value').textContent),
// Odwrócona logika: checked = odbiór lokalny, unchecked = dostawa
delivery_type: localPickupCheckbox.checked ? "local" : "shipping"
};
// Wyślij zamówienie
const checkoutResponse = await fetch('/api/checkout', {
method: 'POST',
headers: {

View file

@ -1,11 +1,9 @@
(() => {
// Sprawdź czy jesteśmy na stronie głównej
const booksContainer = document.getElementById('books-container');
const searchInput = document.getElementById('searchInput');
const sortSelect = document.getElementById('sortSelect');
if (!booksContainer || !searchInput || !sortSelect) return;
// Funkcje specyficzne dla strony głównej
const createBookCard = (book) => `
<div class="col">
<div class="book-card h-100">
@ -42,11 +40,9 @@
}
};
// Event listeners tylko dla strony głównej
searchInput.addEventListener('input', loadBooks);
sortSelect.addEventListener('change', loadBooks);
// Inicjalizacja
document.addEventListener('DOMContentLoaded', loadBooks);
})();
@ -82,7 +78,6 @@ async function updateAuthUI() {
}
}
// Obsługa wylogowania
function setupLogout() {
document.getElementById('logoutLink')?.addEventListener('click', async (e) => {
e.preventDefault();
@ -91,7 +86,6 @@ function setupLogout() {
});
}
// Inicjalizacja na każdej stronie
document.addEventListener('DOMContentLoaded', () => {
updateAuthUI();
setupLogout();
@ -234,7 +228,6 @@ function renderBooks(books) {
</div>
`).join('');
// Dodaj obsługę przycisków "Dodaj do koszyka"
document.querySelectorAll('.add-to-cart').forEach(button => {
button.addEventListener('click', async (e) => {
e.preventDefault();
@ -290,18 +283,15 @@ function showError(message) {
`;
}
// Inicjalizacja przy pierwszym załadowaniu
document.addEventListener('DOMContentLoaded', () => {
if (document.getElementById('books-container')) {
loadBooks();
}
// Nasłuchiwanie wyszukiwania
document.getElementById('searchInput')?.addEventListener('input', (e) => {
loadBooks(e.target.value, document.getElementById('sortSelect')?.value || 'default');
});
// Nasłuchiwanie zmiany sortowania
document.getElementById('sortSelect')?.addEventListener('change', (e) => {
loadBooks(document.getElementById('searchInput')?.value || '', e.target.value);
});

View file

@ -51,7 +51,6 @@ function displayOrderHistory(orders) {
orders.forEach(order => {
const orderDate = new Date(order.data_zamowienia).toLocaleDateString();
// Poprawione mapowanie typów dostawy
let deliveryType = order.typ_dostawy || 'shipping';
let deliveryText = '';
@ -60,7 +59,6 @@ function displayOrderHistory(orders) {
} else if (deliveryType === 'shipping') {
deliveryText = 'Dostawa';
} else {
// Dla starych zamówień bez typu
deliveryText = 'Dostawa';
}

View file

@ -1,5 +1,3 @@
// static/js/theme.js
// Eksportuj funkcję setTheme
export function setTheme(theme) {
document.body.classList.remove('dark-theme', 'light-theme');
document.body.classList.add(theme + '-theme');
@ -29,11 +27,9 @@ function updateThemeColors(theme) {
}
document.addEventListener('DOMContentLoaded', function() {
// Przywróć zapisany motyw
const savedTheme = localStorage.getItem('theme') || 'dark';
setTheme(savedTheme);
// Obsługa przycisku zmiany motywu
const themeToggle = document.getElementById('theme-toggle');
if (themeToggle) {
themeToggle.addEventListener('click', function() {

View file

@ -1,6 +1,4 @@
// Funkcja do wyświetlania komunikatów
export function showMessage(type, message) {
// Utwórz kontener komunikatów jeśli nie istnieje
let messageContainer = document.getElementById('message-container');
if (!messageContainer) {
messageContainer = document.createElement('div');
@ -12,7 +10,6 @@ export function showMessage(type, message) {
document.body.appendChild(messageContainer);
}
// Utwórz element komunikatu
const messageElement = document.createElement('div');
messageElement.className = `alert alert-${type} alert-dismissible fade show`;
messageElement.role = 'alert';
@ -21,22 +18,18 @@ export function showMessage(type, message) {
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
`;
// Dodaj do kontenera
messageContainer.appendChild(messageElement);
// Automatyczne ukrycie po 5 sekundach
setTimeout(() => {
messageElement.classList.remove('show');
setTimeout(() => messageElement.remove(), 150);
}, 5000);
}
// Funkcja formatująca walutę
export function formatCurrency(amount) {
return parseFloat(amount).toFixed(2) + ' PLN';
}
// Funkcja do pobierania parametrów URL
export function getUrlParam(name) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(name);