From 4619d101f0d4709f94d867153a5666e0434a32a5 Mon Sep 17 00:00:00 2001 From: caadiq Date: Fri, 9 Jan 2026 17:35:15 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=A0=84=EC=B2=B4=EB=B3=B4?= =?UTF-8?q?=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F?= =?UTF-8?q?=20=EB=82=A0=EC=A7=9C=20=EC=84=A0=ED=83=9D=20=EA=B8=B0=EB=B3=B8?= =?UTF-8?q?=EA=B0=92=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 전체보기 버튼 제거 - 월 이동 시 이번달이면 오늘, 다른 달이면 1일 자동 선택 - 같은 날짜 클릭 시 토글 제거 (항상 선택 유지) - 필터링 대상 줄여서 성능 개선 --- frontend/src/pages/pc/Schedule.jsx | 53 ++++++++++------ frontend/src/pages/pc/admin/AdminSchedule.jsx | 61 +++++++++++-------- 2 files changed, 68 insertions(+), 46 deletions(-) diff --git a/frontend/src/pages/pc/Schedule.jsx b/frontend/src/pages/pc/Schedule.jsx index 4401752..af1804b 100644 --- a/frontend/src/pages/pc/Schedule.jsx +++ b/frontend/src/pages/pc/Schedule.jsx @@ -158,19 +158,36 @@ function Schedule() { const prevMonth = () => { setSlideDirection(-1); - setCurrentDate(new Date(year, month - 1, 1)); - setSelectedDate(null); // 월 변경 시 초기화 + const newDate = new Date(year, month - 1, 1); + setCurrentDate(newDate); + // 이번달이면 오늘, 다른 달이면 1일 선택 + const today = new Date(); + if (newDate.getFullYear() === today.getFullYear() && newDate.getMonth() === today.getMonth()) { + setSelectedDate(getTodayKST()); + } else { + const firstDay = `${newDate.getFullYear()}-${String(newDate.getMonth() + 1).padStart(2, '0')}-01`; + setSelectedDate(firstDay); + } }; const nextMonth = () => { setSlideDirection(1); - setCurrentDate(new Date(year, month + 1, 1)); - setSelectedDate(null); // 월 변경 시 초기화 + const newDate = new Date(year, month + 1, 1); + setCurrentDate(newDate); + // 이번달이면 오늘, 다른 달이면 1일 선택 + const today = new Date(); + if (newDate.getFullYear() === today.getFullYear() && newDate.getMonth() === today.getMonth()) { + setSelectedDate(getTodayKST()); + } else { + const firstDay = `${newDate.getFullYear()}-${String(newDate.getMonth() + 1).padStart(2, '0')}-01`; + setSelectedDate(firstDay); + } }; + // 날짜 선택 (토글 없이 항상 선택) const selectDate = (day) => { const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`; - setSelectedDate(selectedDate === dateStr ? null : dateStr); + setSelectedDate(dateStr); }; const selectYear = (newYear) => { @@ -179,7 +196,16 @@ function Schedule() { }; const selectMonth = (newMonth) => { - setCurrentDate(new Date(year, newMonth, 1)); + const newDate = new Date(year, newMonth, 1); + setCurrentDate(newDate); + // 이번달이면 오늘, 다른 달이면 1일 선택 + const today = new Date(); + if (newDate.getFullYear() === today.getFullYear() && newDate.getMonth() === today.getMonth()) { + setSelectedDate(getTodayKST()); + } else { + const firstDay = `${year}-${String(newMonth + 1).padStart(2, '0')}-01`; + setSelectedDate(firstDay); + } setShowYearMonthPicker(false); setViewMode('yearMonth'); }; @@ -537,23 +563,12 @@ function Schedule() { - {/* 범례 및 전체보기 */} -
+ {/* 범례 */} +
일정 있음
-
diff --git a/frontend/src/pages/pc/admin/AdminSchedule.jsx b/frontend/src/pages/pc/admin/AdminSchedule.jsx index 1e8fe48..9eda0d5 100644 --- a/frontend/src/pages/pc/admin/AdminSchedule.jsx +++ b/frontend/src/pages/pc/admin/AdminSchedule.jsx @@ -302,15 +302,31 @@ function AdminSchedule() { // 월 이동 const prevMonth = () => { setSlideDirection(-1); - setCurrentDate(new Date(year, month - 1, 1)); - setSelectedDate(null); + const newDate = new Date(year, month - 1, 1); + setCurrentDate(newDate); + // 이번달이면 오늘, 다른 달이면 1일 선택 + const today = new Date(); + if (newDate.getFullYear() === today.getFullYear() && newDate.getMonth() === today.getMonth()) { + setSelectedDate(getTodayKST()); + } else { + const firstDay = `${newDate.getFullYear()}-${String(newDate.getMonth() + 1).padStart(2, '0')}-01`; + setSelectedDate(firstDay); + } setSchedules([]); // 이전 달 데이터 즉시 초기화 }; const nextMonth = () => { setSlideDirection(1); - setCurrentDate(new Date(year, month + 1, 1)); - setSelectedDate(null); + const newDate = new Date(year, month + 1, 1); + setCurrentDate(newDate); + // 이번달이면 오늘, 다른 달이면 1일 선택 + const today = new Date(); + if (newDate.getFullYear() === today.getFullYear() && newDate.getMonth() === today.getMonth()) { + setSelectedDate(getTodayKST()); + } else { + const firstDay = `${newDate.getFullYear()}-${String(newDate.getMonth() + 1).padStart(2, '0')}-01`; + setSelectedDate(firstDay); + } setSchedules([]); // 이전 달 데이터 즉시 초기화 }; @@ -326,20 +342,24 @@ function AdminSchedule() { // 월 선택 시 적용 후 닫기 const selectMonth = (newMonth) => { - setCurrentDate(new Date(year, newMonth, 1)); + const newDate = new Date(year, newMonth, 1); + setCurrentDate(newDate); + // 이번달이면 오늘, 다른 달이면 1일 선택 + const today = new Date(); + if (newDate.getFullYear() === today.getFullYear() && newDate.getMonth() === today.getMonth()) { + setSelectedDate(getTodayKST()); + } else { + const firstDay = `${year}-${String(newMonth + 1).padStart(2, '0')}-01`; + setSelectedDate(firstDay); + } setShowYearMonthPicker(false); setViewMode('yearMonth'); }; - // 날짜 선택 + // 날짜 선택 (토글 없이 항상 선택) const selectDate = (day) => { const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`; - setSelectedDate(selectedDate === dateStr ? null : dateStr); - }; - - // 전체보기 - const showAll = () => { - setSelectedDate(null); + setSelectedDate(dateStr); }; // 삭제 관련 상태 @@ -814,25 +834,12 @@ function AdminSchedule() { - {/* 범례 및 전체보기 */} -
+ {/* 범례 */} +
일정 있음
-