/** 상품 그리드·페이지네이션 렌더링 */ import { state } from './state.js'; import { ITEMS_PER_PAGE, STATUS_META } from './config.js'; export function renderProducts(page) { const grid = document.getElementById('product-grid'); if (!grid) return; grid.innerHTML = ''; const startIndex = (page - 1) * ITEMS_PER_PAGE; const pagedProducts = state.visibleProducts.slice(startIndex, startIndex + ITEMS_PER_PAGE); pagedProducts.forEach((product) => { const isSold = STATUS_META[product.status]?.soldOut === true; const cardHtml = `
${product.status}

${product.title}

${product.currency}${product.price.toLocaleString()}

${product.description}

`; grid.insertAdjacentHTML('beforeend', cardHtml); }); renderPagination(); } export function renderPagination() { const container = document.getElementById('pagination'); if (!container) return; const totalPages = Math.ceil(state.visibleProducts.length / ITEMS_PER_PAGE); const { currentPage } = state; let html = ``; for (let i = 1; i <= totalPages; i++) { html += ``; } html += ``; container.innerHTML = html; } export function changePage(page) { state.currentPage = page; renderProducts(page); window.scrollTo({ top: 0, behavior: 'smooth' }); }