feat: 동물약만 체크 시 검색어 없이 전체 조회 가능
- 동물약은 39건뿐이라 전체 조회해도 빠름 - 동물약만 체크 + 검색어 없음 → 전체 동물약 리스트 - 쿼리 조건 동적 생성 (animal_condition, search_condition)
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user