From 030c495c0156e0facd8bd07be1d894da55ddad06 Mon Sep 17 00:00:00 2001 From: caadiq Date: Wed, 7 Jan 2026 16:00:42 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AA=A8=EB=B0=94=EC=9D=BC=20=EC=9D=BC?= =?UTF-8?q?=EC=A0=95:=20=EB=8B=AC=EB=A0=A5=20=EC=A0=90=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C=20PC=20=EB=B2=84=EC=A0=84=EA=B3=BC=20=ED=86=B5?= =?UTF-8?q?=EC=9D=BC,=20=EB=A9=A4=EB=B2=84=20=EB=B0=B0=EC=A7=80=20?= =?UTF-8?q?=EC=B4=88=EB=A1=9D=EC=83=89,=20=EC=9B=94=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20=EC=8B=9C=20=EB=82=A0=EC=A7=9C=20=EC=84=A0=ED=83=9D=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/mobile/Schedule.jsx | 123 +++++++++++++++++-------- 1 file changed, 85 insertions(+), 38 deletions(-) diff --git a/frontend/src/pages/mobile/Schedule.jsx b/frontend/src/pages/mobile/Schedule.jsx index 0c53d8a..9ce2afe 100644 --- a/frontend/src/pages/mobile/Schedule.jsx +++ b/frontend/src/pages/mobile/Schedule.jsx @@ -13,7 +13,7 @@ function MobileSchedule() { const [isSearchMode, setIsSearchMode] = useState(false); const [searchTerm, setSearchTerm] = useState(''); const [showCalendar, setShowCalendar] = useState(false); - const [calendarViewDate, setCalendarViewDate] = useState(new Date()); // 달력 뷰 날짜 + const [calendarViewDate, setCalendarViewDate] = useState(() => new Date(selectedDate)); // 달력 뷰 날짜 const [calendarShowYearMonth, setCalendarShowYearMonth] = useState(false); // 달력 년월 선택 모드 // 달력 월 변경 함수 @@ -84,7 +84,17 @@ function MobileSchedule() { const changeMonth = (delta) => { const newDate = new Date(selectedDate); newDate.setMonth(newDate.getMonth() + delta); + + // 이번 달이면 오늘 날짜, 다른 달이면 1일 선택 + const today = new Date(); + if (newDate.getFullYear() === today.getFullYear() && newDate.getMonth() === today.getMonth()) { + newDate.setDate(today.getDate()); + } else { + newDate.setDate(1); + } + setSelectedDate(newDate); + setCalendarViewDate(newDate); }; // 캘린더가 열릴 때 배경 스크롤 방지 @@ -306,13 +316,20 @@ function MobileSchedule() { const month = String(date.getMonth() + 1).padStart(2, '0'); const day = String(date.getDate()).padStart(2, '0'); const dateStr = `${year}-${month}-${day}`; - const hasSchedule = schedules.some(s => s.date.split('T')[0] === dateStr); + + // 해당 날짜의 일정 목록 (최대 3개) + const daySchedules = schedules + .filter(s => s.date?.split('T')[0] === dateStr) + .slice(0, 3); return ( ); })} @@ -369,6 +397,8 @@ function MobileSchedule() { onShowYearMonthChange={setCalendarShowYearMonth} onSelectDate={(date) => { setSelectedDate(date); + setCalendarViewDate(date); + setCalendarShowYearMonth(false); setShowCalendar(false); }} /> @@ -571,7 +601,7 @@ function TimelineScheduleCard({ schedule, categoryColor, categories, delay = 0 } memberList.map((name, i) => ( {name.trim()} @@ -617,7 +647,7 @@ function CalendarPicker({ const scheduleDates = useMemo(() => { const dateMap = {}; schedules.forEach(schedule => { - const date = schedule.date; + const date = schedule.date.split('T')[0]; // YYYY-MM-DD 형식으로 통일 if (!dateMap[date]) { dateMap[date] = []; } @@ -627,11 +657,13 @@ function CalendarPicker({ return dateMap; }, [schedules, categories]); - const getScheduleColors = (date) => { - const dateStr = date.toISOString().split('T')[0]; - const colors = scheduleDates[dateStr] || []; - // 최대 3개까지만 표시 - return [...new Set(colors)].slice(0, 3); + // 날짜별 일정 목록 가져오기 (점 표시용, 최대 3개) + const getDaySchedules = (date) => { + const y = date.getFullYear(); + const m = String(date.getMonth() + 1).padStart(2, '0'); + const d = String(date.getDate()).padStart(2, '0'); + const dateStr = `${y}-${m}-${d}`; + return schedules.filter(s => s.date?.split('T')[0] === dateStr).slice(0, 3); }; const year = viewDate.getFullYear(); @@ -691,6 +723,13 @@ function CalendarPicker({ date.getFullYear() === today.getFullYear(); }; + // 선택된 날짜인지 확인 + const isSelected = (date) => { + return date.getDate() === selectedDate.getDate() && + date.getMonth() === selectedDate.getMonth() && + date.getFullYear() === selectedDate.getFullYear(); + }; + // 년월 선택 모드 - 외부에서 제어 가능 const [internalShowYearMonth, setInternalShowYearMonth] = useState(false); const showYearMonth = externalShowYearMonth !== undefined ? externalShowYearMonth : internalShowYearMonth; @@ -767,37 +806,45 @@ function CalendarPicker({ const dayOfWeek = index % 7; const isSunday = dayOfWeek === 0; const isSaturday = dayOfWeek === 6; - const scheduleColors = item.isCurrentMonth ? getScheduleColors(item.date) : []; + const daySchedules = item.isCurrentMonth ? getDaySchedules(item.date) : []; return ( ); })} @@ -882,10 +929,10 @@ function CalendarPicker({ ) : ( {/* 달력 헤더 - hideHeader일 때 숨김 */}