diff --git a/data/games.js b/data/games.js index 09db2ab..607f4a2 100644 --- a/data/games.js +++ b/data/games.js @@ -1,8 +1,233 @@ const games = [ { + id: 'a7k3m9q2', + createdAt: '2026-02-05', + updatedAt: '2026-02-05', + + title: '크라이스타', + price: 0, + currency: '₩', + category: 'Games', + status: '판매중', + customTag: '', + + tags: ['Switch', 'KR'], + + images: ['/images/games/a7k3m9q2_01.jpg', '/images/games/a7k3m9q2_02.jpg', '/images/games/a7k3m9q2_03.jpg'], + + description: '개봉품, 한국 정식 발매판(KR), 상태 매우 양호', + + specs: { + purchaseDate: '', + condition: 'Excellent (개봉품, 상태 매우 양호)', + isVerified: true, + }, + fullDescription: ['크라이스타 (CRYSTAR) 닌텐도 스위치용 패키지입니다.', '한국 정식 발매판(KR) 제품입니다.', '', '사용 후 OPP에 넣어 보관·관리했으며', '전체적으로 상태가 매우 좋은 편입니다.', '', '', ''], + }, + { + id: 'fynzefa9', + createdAt: '2026-02-05', + updatedAt: '2026-02-05', + + title: '신 같은 너에게', + price: 45000, + currency: '₩', + category: 'Games', + status: '판매중', + customTag: '', + + tags: ['Switch', 'JP'], + + images: ['/images/games/fynzefa9_01.jpg', '/images/games/fynzefa9_02.jpg', '/images/games/fynzefa9_03.jpg'], + + description: '미개봉 새제품, 일본 내수용(JP), 한국어 미지원', + + specs: { + purchaseDate: '', + condition: 'Brand New (미개봉)', + isVerified: true, + }, + fullDescription: ['신 같은 너에게 (神様のような君へ) 닌텐도 스위치용 패키지입니다.', '일본 내수용(JP) 제품입니다.', '미개봉 새제품 상태입니다.', '', '※ 한국어는 지원하지 않습니다.', '', '', ''], + }, + { + id: '0xutijk8', + createdAt: '2026-02-05', + updatedAt: '2026-02-05', + + title: '드래곤볼 더 브레이커스 스페셜 에디션', + price: 10000, + currency: '₩', + category: 'Games', + status: '판매중', + customTag: '', + + tags: ['Switch', 'KR'], + + images: ['/images/games/0xutijk8_01.jpg', '/images/games/0xutijk8_02.jpg', '/images/games/0xutijk8_03.jpg'], + + description: '미개봉 새제품, 한국 정식 발매판(KR)', + + specs: { + purchaseDate: '', + condition: 'Brand New (미개봉)', + isVerified: true, + }, + fullDescription: ['드래곤볼 더 브레이커스 스페셜 에디션 닌텐도 스위치용 패키지입니다.', '한국 정식 발매판(KR) 제품입니다.', '미개봉 새제품 상태입니다.', '', '', '', '', ''], + }, + { + id: 'w5vyp5x2', + createdAt: '2026-02-05', + updatedAt: '2026-02-05', + + title: '페어리 펜서 F 리프레인 코드', + price: 25000, + currency: '₩', + category: 'Games', + status: '판매중', + customTag: '', + + tags: ['Switch', 'KR'], + + images: ['/images/games/w5vyp5x2_01.jpg', '/images/games/w5vyp5x2_02.jpg', '/images/games/w5vyp5x2_03.jpg'], + + description: '미개봉 새제품, 한국 정식 발매판(KR)', + + specs: { + purchaseDate: '', + condition: 'Brand New (미개봉)', + isVerified: true, + }, + fullDescription: ['페어리 펜서 F 리프레인 코드 닌텐도 스위치용 패키지입니다.', '한국 정식 발매판(KR) 제품입니다.', '미개봉 새제품 상태입니다.', '', '', '', '', ''], + }, + { + id: 'de41vs8u', + createdAt: '2026-02-05', + updatedAt: '2026-02-05', + + title: "포켓몬스터 Let's Go! 이브이", + price: 50000, + currency: '₩', + category: 'Games', + status: '판매중', + customTag: '', + + tags: ['Switch', 'Nintendo', 'JP', 'Pokemon'], + + images: ['/images/games/de41vs8u_01.jpg', '/images/games/de41vs8u_02.jpg', '/images/games/de41vs8u_03.jpg'], + + description: '개봉품, 일본 내수용(JP), 한국어 지원, 상태 매우 양호', + + specs: { + purchaseDate: '', + condition: 'Excellent (개봉품, 상태 매우 양호)', + isVerified: true, + }, + fullDescription: [ + "포켓몬스터 Let's Go! 이브이 (ポケットモンスター Let's Go! イーブイ) 닌텐도 스위치용 패키지입니다.", + '일본 내수용(JP) 제품입니다.', + '멀티랭기지 지원으로 한국어 플레이가 가능합니다.', + '', + '사용 후 OPP에 넣어 보관·관리했으며', + '전체적으로 상태가 매우 좋은 편입니다.', + '', + '', + '', + ], + }, + { + id: 'z69xbqg7', + createdAt: '2026-02-05', + updatedAt: '2026-02-05', + + title: '젤다의 전설 꿈꾸는 섬', + price: 55000, + currency: '₩', + category: 'Games', + status: '판매중', + customTag: '', + + tags: ['Switch', 'Nintendo', 'JP'], + + images: ['/images/games/z69xbqg7_01.jpg', '/images/games/z69xbqg7_02.jpg', '/images/games/z69xbqg7_03.jpg'], + description: '개봉품, 일본 내수용(JP), 한국어 지원, 상태 매우 양호', + + specs: { + purchaseDate: '', + condition: 'Excellent (개봉품, 상태 매우 양호)', + isVerified: true, + }, + fullDescription: ['젤다의 전설 꿈꾸는 섬 (ゼルダの伝説 夢をみる島) 닌텐도 스위치용 패키지입니다.', '일본 내수용(JP) 제품입니다.', '멀티랭기지 지원으로 한국어 플레이가 가능합니다.', '', '사용 후 OPP에 넣어 보관·관리했으며', '전체적으로 상태가 매우 좋은 편입니다.', '', '', ''], + }, + { + id: 'q0422roj', + createdAt: '2026-02-05', + updatedAt: '2026-02-05', + + title: 'LOOPERS', + price: 25000, + currency: '₩', + category: 'Games', + status: '판매중', + customTag: '', + + tags: ['Switch', 'Key', 'JP', 'Kinetic Novel'], + + images: ['/images/games/q0422roj_01.jpg', '/images/games/q0422roj_02.jpg', '/images/games/q0422roj_03.jpg'], + description: '개봉품, 일본 내수용(JP), 한국어 미지원, 상태 매우 양호', + + specs: { + purchaseDate: '', + condition: 'Excellent (개봉품, 상태 매우 양호)', + isVerified: true, + }, + fullDescription: [ + 'LOOPERS (ルーパーズ) 닌텐도 스위치용 패키지입니다.', + '일본 내수용(JP) 제품입니다.', + '엔젤비트(Angel Beats!) 등으로 유명한 Key 제작 작품입니다.', + '장르는 키네틱 노벨입니다.', + '', + '사용 후 OPP에 넣어 보관·관리했으며', + '전체적으로 상태가 매우 좋은 편입니다.', + '', + '※ 한국어는 지원하지 않습니다.', + '', + '', + '', + ], + }, + { + // [1] 시스템 및 메타 정보 (가장 먼저 확인하게 되는 고유값) + id: 'i3zgj4zl', + createdAt: '2026-02-02', + updatedAt: '2026-02-02', + + // [2] 기본 판매 정보 (리스트 카드에 바로 노출될 핵심 정보) + title: '플로럴 플로우러브', + price: 60000, + currency: '₩', + category: 'Games', + status: '판매중', + customTag: '완전생산한정판', // 카드 위에 띄울 뱃지용 + + // [3] 분류 및 필터 정보 (중복 선택 및 검색용) + tags: ['Switch', '한정판', 'JP'], + + // [4] 시각 및 요약 정보 + images: ['/images/games/i3zgj4zl_01.jpg', '/images/games/i3zgj4zl_02.jpg', '/images/games/i3zgj4zl_03.jpg', '/images/games/i3zgj4zl_04.jpg'], + description: '미개봉 새제품, 한정판, 일본 내수용(JP), 한글미지원', + + // [5] 상세 스펙 및 본문 (데이터 양이 가장 많으므로 하단 배치) + specs: { + purchaseDate: '', + condition: 'Brand New (미개봉)', + isVerified: true, + }, + fullDescription: ['플로럴 플로우러브 (フローラル・フローラブ) 닌텐도 스위치용 패키지입니다.', '일본 내수용(JP) 완전생산한정판 제품입니다.', '미개봉 새제품 상태입니다.', '한글은 지원하지 않으며 일본어로 플레이 가능합니다.', '', '', '', '', '', '', '', '', '', ''], + }, + { id: 'nm4uzduj', - createdAt: '2026-02-04', - updatedAt: '2026-02-04', + createdAt: '2026-02-01', + updatedAt: '2026-02-01', title: '닌텐도 게임앤워치 젤다의 전설', price: 80000, @@ -21,27 +246,12 @@ const games = [ condition: 'Brand New (미개봉)', isVerified: true, }, - fullDescription: [ - '닌텐도 Game & Watch 젤다의 전설 에디션입니다.', - '일본 내수용 제품입니다.', - '미개봉 새제품 상태입니다.', - '소장용으로 보관하기 좋은 상태입니다.', - '', - '※ 게임&워치는 한국어에 대응하지 않습니다.', - '', - '', - '', - '', - '', - '', - '', - '', - ], + fullDescription: ['닌텐도 Game & Watch 젤다의 전설 에디션입니다.', '일본 내수용 제품입니다.', '미개봉 새제품 상태입니다.', '소장용으로 보관하기 좋은 상태입니다.', '', '※ 게임&워치는 한국어에 대응하지 않습니다.', '', '', '', '', '', '', '', ''], }, { id: 'vzwe916n', - createdAt: '2026-02-04', - updatedAt: '2026-02-04', + createdAt: '2026-02-01', + updatedAt: '2026-02-01', title: '닌텐도 게임앤워치 슈퍼마리오 브라더스', price: 80000, @@ -60,66 +270,7 @@ const games = [ condition: 'Brand New (미개봉)', isVerified: true, }, - fullDescription: [ - '닌텐도 Game & Watch 슈퍼 마리오 에디션입니다.', - '한국 정식 발매판으로 국내 유통된 제품입니다.', - '미개봉 새제품 상태입니다.', - '소장용으로 보관하기 좋은 상태입니다.', - '', - '※ 게임&워치는 한국어에 대응하지 않습니다.', - '', - '', - '', - '', - '', - '', - '', - '', - ], - }, - { - // [1] 시스템 및 메타 정보 (가장 먼저 확인하게 되는 고유값) - id: 'i3zgj4zl', - createdAt: '2025-01-22', - updatedAt: '2025-01-22', - - // [2] 기본 판매 정보 (리스트 카드에 바로 노출될 핵심 정보) - title: '플로럴 플로우러브', - price: 60000, - currency: '₩', - category: 'Games', - status: '판매중', - customTag: '완전생산한정판', // 카드 위에 띄울 뱃지용 - - // [3] 분류 및 필터 정보 (중복 선택 및 검색용) - tags: ['Switch', 'Limited Edition', 'JP'], - - // [4] 시각 및 요약 정보 - images: ['/images/games/i3zgj4zl_01.jpg', '/images/games/i3zgj4zl_02.jpg', '/images/games/i3zgj4zl_03.jpg', '/images/games/i3zgj4zl_04.jpg'], - description: '미개봉 새제품, 한정판, 일본 내수용(JP), 한글미지원', - - // [5] 상세 스펙 및 본문 (데이터 양이 가장 많으므로 하단 배치) - specs: { - purchaseDate: '', - condition: 'Brand New (미개봉)', - isVerified: true, - }, - fullDescription: [ - '플로럴 플로우러브 (フローラル・フローラブ) 닌텐도 스위치용 패키지입니다.', - '일본 내수용(JP) 완전생산한정판 제품입니다.', - '미개봉 새제품 상태입니다.', - '한글은 지원하지 않으며 일본어로 플레이 가능합니다.', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - ], + fullDescription: ['닌텐도 Game & Watch 슈퍼 마리오 에디션입니다.', '한국 정식 발매판으로 국내 유통된 제품입니다.', '미개봉 새제품 상태입니다.', '소장용으로 보관하기 좋은 상태입니다.', '', '※ 게임&워치는 한국어에 대응하지 않습니다.', '', '', '', '', '', '', '', ''], }, ]; export default games; diff --git a/images/assets/favicon/android-chrome-192x192.png b/images/assets/favicon/android-chrome-192x192.png deleted file mode 100755 index c56c926..0000000 Binary files a/images/assets/favicon/android-chrome-192x192.png and /dev/null differ diff --git a/images/assets/favicon/android-chrome-512x512.png b/images/assets/favicon/android-chrome-512x512.png deleted file mode 100755 index 439ee16..0000000 Binary files a/images/assets/favicon/android-chrome-512x512.png and /dev/null differ diff --git a/images/assets/favicon/apple-touch-icon.png b/images/assets/favicon/apple-touch-icon.png deleted file mode 100755 index 2ea2814..0000000 Binary files a/images/assets/favicon/apple-touch-icon.png and /dev/null differ diff --git a/images/assets/favicon/favicon-16x16.png b/images/assets/favicon/favicon-16x16.png deleted file mode 100755 index 2aead02..0000000 Binary files a/images/assets/favicon/favicon-16x16.png and /dev/null differ diff --git a/images/assets/favicon/favicon-32x32.png b/images/assets/favicon/favicon-32x32.png deleted file mode 100755 index d26ca4b..0000000 Binary files a/images/assets/favicon/favicon-32x32.png and /dev/null differ diff --git a/images/assets/favicon/favicon.ico b/images/assets/favicon/favicon.ico deleted file mode 100755 index d22ce91..0000000 Binary files a/images/assets/favicon/favicon.ico and /dev/null differ diff --git a/images/assets/favicon/site.webmanifest b/images/assets/favicon/site.webmanifest deleted file mode 100755 index 45dc8a2..0000000 --- a/images/assets/favicon/site.webmanifest +++ /dev/null @@ -1 +0,0 @@ -{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} \ No newline at end of file diff --git a/images/games/0xutijk8_01.jpg b/images/games/0xutijk8_01.jpg new file mode 100644 index 0000000..7c052ca Binary files /dev/null and b/images/games/0xutijk8_01.jpg differ diff --git a/images/games/0xutijk8_02.jpg b/images/games/0xutijk8_02.jpg new file mode 100644 index 0000000..0069797 Binary files /dev/null and b/images/games/0xutijk8_02.jpg differ diff --git a/images/games/0xutijk8_03.jpg b/images/games/0xutijk8_03.jpg new file mode 100644 index 0000000..3d37ee6 Binary files /dev/null and b/images/games/0xutijk8_03.jpg differ diff --git a/images/games/a7k3m9q2_01.jpg b/images/games/a7k3m9q2_01.jpg new file mode 100644 index 0000000..cf29d4e Binary files /dev/null and b/images/games/a7k3m9q2_01.jpg differ diff --git a/images/games/a7k3m9q2_02.jpg b/images/games/a7k3m9q2_02.jpg new file mode 100644 index 0000000..fae40af Binary files /dev/null and b/images/games/a7k3m9q2_02.jpg differ diff --git a/images/games/a7k3m9q2_03.jpg b/images/games/a7k3m9q2_03.jpg new file mode 100644 index 0000000..202d656 Binary files /dev/null and b/images/games/a7k3m9q2_03.jpg differ diff --git a/images/games/de41vs8u_01.jpg b/images/games/de41vs8u_01.jpg new file mode 100644 index 0000000..dd45050 Binary files /dev/null and b/images/games/de41vs8u_01.jpg differ diff --git a/images/games/de41vs8u_02.jpg b/images/games/de41vs8u_02.jpg new file mode 100644 index 0000000..b512e29 Binary files /dev/null and b/images/games/de41vs8u_02.jpg differ diff --git a/images/games/de41vs8u_03.jpg b/images/games/de41vs8u_03.jpg new file mode 100644 index 0000000..8706323 Binary files /dev/null and b/images/games/de41vs8u_03.jpg differ diff --git a/images/games/fynzefa9_01.jpg b/images/games/fynzefa9_01.jpg new file mode 100644 index 0000000..8a6ba4c Binary files /dev/null and b/images/games/fynzefa9_01.jpg differ diff --git a/images/games/fynzefa9_02.jpg b/images/games/fynzefa9_02.jpg new file mode 100644 index 0000000..325feee Binary files /dev/null and b/images/games/fynzefa9_02.jpg differ diff --git a/images/games/fynzefa9_03.jpg b/images/games/fynzefa9_03.jpg new file mode 100644 index 0000000..6bc9427 Binary files /dev/null and b/images/games/fynzefa9_03.jpg differ diff --git a/images/games/q0422roj_01.jpg b/images/games/q0422roj_01.jpg new file mode 100644 index 0000000..161b28d Binary files /dev/null and b/images/games/q0422roj_01.jpg differ diff --git a/images/games/q0422roj_02.jpg b/images/games/q0422roj_02.jpg new file mode 100644 index 0000000..d82d98b Binary files /dev/null and b/images/games/q0422roj_02.jpg differ diff --git a/images/games/q0422roj_03.jpg b/images/games/q0422roj_03.jpg new file mode 100644 index 0000000..5d67038 Binary files /dev/null and b/images/games/q0422roj_03.jpg differ diff --git a/images/games/w5vyp5x2_01.jpg b/images/games/w5vyp5x2_01.jpg new file mode 100644 index 0000000..c33df87 Binary files /dev/null and b/images/games/w5vyp5x2_01.jpg differ diff --git a/images/games/w5vyp5x2_02.jpg b/images/games/w5vyp5x2_02.jpg new file mode 100644 index 0000000..20343df Binary files /dev/null and b/images/games/w5vyp5x2_02.jpg differ diff --git a/images/games/w5vyp5x2_03.jpg b/images/games/w5vyp5x2_03.jpg new file mode 100644 index 0000000..a158a49 Binary files /dev/null and b/images/games/w5vyp5x2_03.jpg differ diff --git a/images/games/z69xbqg7_01.jpg b/images/games/z69xbqg7_01.jpg new file mode 100644 index 0000000..6d6e822 Binary files /dev/null and b/images/games/z69xbqg7_01.jpg differ diff --git a/images/games/z69xbqg7_02.jpg b/images/games/z69xbqg7_02.jpg new file mode 100644 index 0000000..62fedc8 Binary files /dev/null and b/images/games/z69xbqg7_02.jpg differ diff --git a/images/games/z69xbqg7_03.jpg b/images/games/z69xbqg7_03.jpg new file mode 100644 index 0000000..db989b6 Binary files /dev/null and b/images/games/z69xbqg7_03.jpg differ diff --git a/index.html b/index.html index c730eca..a26203e 100644 --- a/index.html +++ b/index.html @@ -15,12 +15,7 @@ - - - - - - + sori.inventory @@ -88,8 +83,10 @@
- sori.inventory logo - +
+ inventory_2 +
+
@@ -133,6 +130,15 @@
+ +
+
+
+ Total Results + 0 +
+
+
diff --git a/scripts/config.js b/scripts/config.js index a2042ee..34b619c 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -64,3 +64,11 @@ export const TAG_STYLES = { }; export const TAG_DEFAULT_STYLE = 'bg-indigo-100 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-400'; + +export const SEARCH_CONFIG = { + USE_TITLE: true, // 상품명 검색 + USE_CUSTOM_TAG: true, // 커스텀 태그 검색 + USE_TAGS: true, // 태그 배열 검색 + USE_DESCRIPTION: true, // 요약 설명 검색 + USE_FULL_DESCRIPTION: false, // 상세 설명 배열 검색 +}; \ No newline at end of file diff --git a/scripts/filters.js b/scripts/filters.js index cf279a6..8a0112e 100644 --- a/scripts/filters.js +++ b/scripts/filters.js @@ -1,11 +1,6 @@ /** 상태·카테고리·검색 필터 로직 및 UI */ import { state, productsData } from './state.js'; -import { - VISIBILITY_CONFIG, - STATUS_FILTERS, - STATUS_ORDER, - STATUS_COLOR, -} from './config.js'; +import { VISIBILITY_CONFIG, STATUS_FILTERS, STATUS_ORDER, STATUS_COLOR, SEARCH_CONFIG } from './config.js'; import { renderProducts } from './productList.js'; function getStatusChipClass(status, isActive) { @@ -46,13 +41,37 @@ function toggleStatusFilter(status) { export function applyFilters() { state.currentPage = 1; + const keyword = state.searchKeyword.toLowerCase(); + state.visibleProducts = productsData .filter((product) => { + // [1] 가시성 및 상태/카테고리 필터 if (product.status === '미판매' && !VISIBILITY_CONFIG.showUnlisted) return false; if (product.status === '판매완료' && !VISIBILITY_CONFIG.showSold) return false; + const statusMatch = state.activeStatuses.has(product.status); const categoryMatch = state.activeCategories.has('All') || state.activeCategories.has(product.category); - const searchMatch = state.searchKeyword === '' || product.title.toLowerCase().includes(state.searchKeyword); + + // [2] config 설정을 기반으로 한 동적 검색 매칭 + const searchMatch = + keyword === '' || + (() => { + const searchPool = []; + + if (SEARCH_CONFIG.USE_TITLE) searchPool.push(product.title); + + if (SEARCH_CONFIG.USE_CUSTOM_TAG && product.customTag) searchPool.push(product.customTag); + + if (SEARCH_CONFIG.USE_DESCRIPTION && product.description) searchPool.push(product.description); + + if (SEARCH_CONFIG.USE_TAGS && product.tags) searchPool.push(...product.tags); // 배열 요소를 풀어서 추가 + + if (SEARCH_CONFIG.USE_FULL_DESCRIPTION && product.fullDescription) searchPool.push(...product.fullDescription); + + // 검색 풀(Pool)에 있는 단어 중 키워드를 포함하는 게 하나라도 있는지 확인 + return searchPool.some((text) => String(text).toLowerCase().includes(keyword)); + })(); + return statusMatch && categoryMatch && searchMatch; }) .sort((a, b) => { @@ -60,9 +79,20 @@ export function applyFilters() { const bOrder = STATUS_ORDER[b.status] ?? 999; return aOrder - bOrder; }); + + renderTotalCount(state.visibleProducts.length); + renderProducts(state.currentPage); } +/** 총 개수를 화면에 표시하는 보조 함수 */ +function renderTotalCount(count) { + const totalCountElement = document.getElementById('total-count'); + if (totalCountElement) { + totalCountElement.textContent = count.toLocaleString(); // 3자리마다 콤마 + } +} + export function getCategories(products) { return ['All', ...new Set(products.map((p) => p.category))]; } @@ -115,3 +145,27 @@ export function bindCategoryFilter(products) { }); }); } + +// 로고 클릭 시 초기화 로직 +document.getElementById('logo-title')?.addEventListener('click', () => { + // 1. 검색어 초기화 + state.searchKeyword = ''; + const searchInput = document.getElementById('search-input'); // 검색창 ID가 있다면 + if (searchInput) searchInput.value = ''; + + // 2. 카테고리 초기화 (All 선택) + state.activeCategories.clear(); + state.activeCategories.add('All'); + + // 3. 상태 필터 초기화 (기본 활성화 상태로) + state.activeStatuses.clear(); + STATUS_FILTERS.filter(f => f.defaultActive).forEach(f => state.activeStatuses.add(f.key)); + + // 4. 필터 적용 및 UI 갱신 + applyFilters(); + renderStatusChips(); + renderCategoryChips(productsData); + + // 5. 페이지 최상단으로 스크롤 (선택 사항) + window.scrollTo({ top: 0, behavior: 'smooth' }); +}); \ No newline at end of file diff --git a/scripts/main.js b/scripts/main.js index d49a7ed..f039706 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -97,3 +97,4 @@ document.addEventListener('DOMContentLoaded', () => { // 데이터용 새 ID 생성기 const newId = Math.random().toString(36).substring(2, 10); console.log(`%c[NUMBER]: ${newId}`, 'color: #137fec; font-weight: bold; border: 1px solid #137fec; padding: 2px 5px; border-radius: 4px;'); + diff --git a/scripts/productList.js b/scripts/productList.js index e0d471b..f174adc 100644 --- a/scripts/productList.js +++ b/scripts/productList.js @@ -2,33 +2,49 @@ import { state } from './state.js'; import { ITEMS_PER_PAGE, STATUS_META } from './config.js'; -export function renderProducts(page) { +export function renderProducts(page = 1) { const grid = document.getElementById('product-grid'); + const paginationContainer = document.getElementById('pagination'); if (!grid) return; + + // 1. 결과가 0개인 경우 (안내 텍스트만 출력) + if (state.visibleProducts.length === 0) { + grid.classList.remove('grid'); // 중앙 정렬을 위해 그리드 해제 + grid.innerHTML = ` +
+ + search_off + +

검색 결과가 없습니다

+

+ 입력하신 검색어나 선택한 필터를 확인해 주세요. +

+
+ `; + + if (paginationContainer) paginationContainer.innerHTML = ''; + return; + } + + // 2. 결과가 있을 경우 (그리드 복구 및 초기화) + grid.classList.add('grid'); 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}

+

${product.title}

+

${product.description}

`; @@ -69,3 +85,24 @@ export function changePage(page) { renderProducts(page); window.scrollTo({ top: 0, behavior: 'smooth' }); } + +/** 모든 필터를 초기 상태로 되돌리는 함수 */ +function resetAllFilters() { + state.searchKeyword = ''; + const searchInput = document.getElementById('search-input'); + if (searchInput) searchInput.value = ''; + + state.activeCategories.clear(); + state.activeCategories.add('All'); + + // 상태 필터 초기화 (config에서 defaultActive인 것만) + import('./config.js').then(({ STATUS_FILTERS }) => { + state.activeStatuses.clear(); + STATUS_FILTERS.filter(f => f.defaultActive).forEach(f => state.activeStatuses.add(f.key)); + + // UI 전체 갱신 + applyFilters(); + renderStatusChips(); + renderCategoryChips(productsData); + }); +} \ No newline at end of file