프리티어 변경

필터링 AND OR 조건 추가
데이터 JSON 구조 변경
(오류 발생 리스트 형식 안나오는중)
This commit is contained in:
2026-02-22 15:11:22 +09:00
parent 42b5c0f047
commit c8e0aa46f9
11 changed files with 1206 additions and 908 deletions

View File

@@ -67,7 +67,7 @@ export function applyFilters() {
const statusMatch = state.activeStatuses.has(product.status);
const categoryMatch = state.activeCategories.has('All') || state.activeCategories.has(product.category);
const searchMatch = checkSearchMatch(product, keyword);
const tagMatch = state.activeTags.size === 0 || Array.from(state.activeTags).every((tag) => product.tags && product.tags.includes(tag));
const tagMatch = state.activeTags.size === 0 || (state.tagMode === 'AND' ? Array.from(state.activeTags).every((tag) => product.tags?.includes(tag)) : Array.from(state.activeTags).some((tag) => product.tags?.includes(tag)));
return statusMatch && categoryMatch && searchMatch && tagMatch;
})
@@ -195,8 +195,15 @@ export function renderTagChips() {
${hasActive ? 'bg-red-50 text-red-500 border-red-200 hover:bg-red-100' : 'bg-slate-50 text-slate-400 border-slate-200 opacity-60'}" title="태그 초기화">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>
</button>`;
const modeBtnHtml = `
<button id="tag-mode-btn" class="px-2 py-1 rounded-full text-[10px] font-bold border transition-colors
${state.tagMode === 'AND' ? 'bg-indigo-100 text-indigo-600 border-indigo-200' : 'bg-orange-100 text-orange-600 border-orange-200'}">
${state.tagMode}
</button>
`;
container.innerHTML =
modeBtnHtml +
resetBtnHtml +
sortedTags
.map((tag) => {
@@ -229,6 +236,11 @@ export function renderTagChips() {
applyFilters();
};
document.getElementById('tag-mode-btn').onclick = () => {
state.tagMode = state.tagMode === 'AND' ? 'OR' : 'AND';
applyFilters(); // 필터 재적용 및 UI 갱신
};
container.querySelectorAll('.tag-chip').forEach((chip) => {
chip.onclick = () => {
const tag = chip.dataset.tag;