feat: 동물약만 체크 시 검색어 없이 전체 조회 가능

- 동물약은 39건뿐이라 전체 조회해도 빠름
- 동물약만 체크 + 검색어 없음 → 전체 동물약 리스트
- 쿼리 조건 동적 생성 (animal_condition, search_condition)
This commit is contained in:
thug0bin
2026-03-04 14:02:47 +09:00
parent a0cbb984e5
commit 2859dc43cc
2 changed files with 86 additions and 57 deletions

View File

@@ -695,19 +695,23 @@
function searchProducts() {
const search = document.getElementById('searchInput').value.trim();
if (!search) {
alert('검색어를 입력하세요');
return;
}
if (search.length < 2) {
alert('2글자 이상 입력하세요');
return;
const animalOnly = document.getElementById('animalOnly').checked;
// 동물약만 체크시 검색어 없어도 전체 조회 가능
if (!animalOnly) {
if (!search) {
alert('검색어를 입력하세요');
return;
}
if (search.length < 2) {
alert('2글자 이상 입력하세요');
return;
}
}
const tbody = document.getElementById('productsTableBody');
tbody.innerHTML = '<tr><td colspan="6" class="empty-state"><p>검색 중...</p></td></tr>';
const animalOnly = document.getElementById('animalOnly').checked;
const inStockOnly = document.getElementById('inStockOnly').checked;
let url = `/api/products?search=${encodeURIComponent(search)}`;
if (animalOnly) url += '&animal_only=1';