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() { - {/* 범례 및 전체보기 */} -
+ {/* 범례 */} +
일정 있음
-