document.addEventListener('DOMContentLoaded', async () => { const urlParams = new URLSearchParams(window.location.search); const bookId = urlParams.get('id'); try { const response = await fetch(`/api/ksiazki/${bookId}`); if (!response.ok) throw new Error('Książka nie znaleziona'); const book = await response.json(); document.getElementById('book-title').textContent = book.tytul; document.getElementById('book-author').textContent = `Autor: ${book.autor}`; document.getElementById('book-price').textContent = `Cena: ${book.cena} PLN`; document.getElementById('book-description').textContent = book.opis || 'Brak opisu'; document.getElementById('book-cover').src = book.obraz_url || 'https://via.placeholder.com/400x600'; } catch (error) { console.error('Błąd:', error); document.getElementById('book-details').innerHTML = `