fix(admin-schedule): 카테고리 필터를 공개 페이지와 통일
- categoryCounts를 선택 날짜와 무관하게 해당 달 전체 기준으로 변경 - 달력 점도 카테고리 필터 반영 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
70fb6527fe
commit
c0ac18060d
1 changed files with 7 additions and 13 deletions
|
|
@ -348,7 +348,7 @@ function Schedules() {
|
||||||
overscan: 5, // 버퍼 아이템 수
|
overscan: 5, // 버퍼 아이템 수
|
||||||
});
|
});
|
||||||
|
|
||||||
// 카테고리별 카운트 맵 (useMemo로 미리 계산) - 선택된 날짜 기준
|
// 카테고리별 카운트 맵 (선택 날짜와 무관하게 해당 달 전체 기준)
|
||||||
const categoryCounts = useMemo(() => {
|
const categoryCounts = useMemo(() => {
|
||||||
// 검색어가 있을 때만 검색 결과 사용, 아니면 기존 schedules 사용
|
// 검색어가 있을 때만 검색 결과 사용, 아니면 기존 schedules 사용
|
||||||
const source = isSearchMode && searchTerm ? searchResults : schedules;
|
const source = isSearchMode && searchTerm ? searchResults : schedules;
|
||||||
|
|
@ -356,14 +356,6 @@ function Schedules() {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
|
|
||||||
source.forEach((s) => {
|
source.forEach((s) => {
|
||||||
// 검색 모드에서 검색어가 있을 때는 전체 대상
|
|
||||||
// 그 외에는 선택된 날짜 기준으로 필터링
|
|
||||||
if (!(isSearchMode && searchTerm) && selectedDate) {
|
|
||||||
const sDate = getScheduleDate(s);
|
|
||||||
const scheduleDate = formatDate(sDate);
|
|
||||||
if (scheduleDate !== selectedDate) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const catId = getCategoryId(s);
|
const catId = getCategoryId(s);
|
||||||
counts.set(catId, (counts.get(catId) || 0) + 1);
|
counts.set(catId, (counts.get(catId) || 0) + 1);
|
||||||
total++;
|
total++;
|
||||||
|
|
@ -371,7 +363,7 @@ function Schedules() {
|
||||||
|
|
||||||
counts.set('total', total);
|
counts.set('total', total);
|
||||||
return counts;
|
return counts;
|
||||||
}, [schedules, searchResults, isSearchMode, searchTerm, selectedDate]);
|
}, [schedules, searchResults, isSearchMode, searchTerm]);
|
||||||
|
|
||||||
// 정렬된 카테고리 목록 (메모이제이션으로 깜빡임 방지)
|
// 정렬된 카테고리 목록 (메모이제이션으로 깜빡임 방지)
|
||||||
const sortedCategories = useMemo(() => {
|
const sortedCategories = useMemo(() => {
|
||||||
|
|
@ -641,12 +633,14 @@ function Schedules() {
|
||||||
const isToday =
|
const isToday =
|
||||||
new Date().toDateString() === new Date(year, month, day).toDateString();
|
new Date().toDateString() === new Date(year, month, day).toDateString();
|
||||||
|
|
||||||
// 해당 날짜의 일정 목록 (점 표시용, 최대 3개)
|
// 해당 날짜의 일정 목록 (점 표시용, 최대 3개) - 카테고리 필터 반영
|
||||||
const daySchedules = schedules
|
const daySchedules = schedules
|
||||||
.filter((s) => {
|
.filter((s) => {
|
||||||
const scheduleDate = s.date ? s.date.split('T')[0] : '';
|
const scheduleDate = s.date ? s.date.split('T')[0] : '';
|
||||||
const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
|
const matchesDate = scheduleDate === dateStr;
|
||||||
return scheduleDate === dateStr;
|
const matchesCategory =
|
||||||
|
selectedCategories.length === 0 || selectedCategories.includes(s.category_id);
|
||||||
|
return matchesDate && matchesCategory;
|
||||||
})
|
})
|
||||||
.slice(0, 3);
|
.slice(0, 3);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue