diff --git a/frontend/src/pages/pc/Schedule.jsx b/frontend/src/pages/pc/Schedule.jsx index ac940de..71276bf 100644 --- a/frontend/src/pages/pc/Schedule.jsx +++ b/frontend/src/pages/pc/Schedule.jsx @@ -1,11 +1,12 @@ import { useState } from 'react'; -import { motion } from 'framer-motion'; +import { motion, AnimatePresence } from 'framer-motion'; import { Clock, MapPin, Users, ChevronLeft, ChevronRight } from 'lucide-react'; import { schedules } from '../../data/dummy'; function Schedule() { const [currentDate, setCurrentDate] = useState(new Date()); const [selectedDate, setSelectedDate] = useState(null); + const [showYearMonthPicker, setShowYearMonthPicker] = useState(false); // 달력 관련 함수 const getDaysInMonth = (year, month) => new Date(year, month + 1, 0).getDate(); @@ -17,7 +18,6 @@ function Schedule() { const firstDay = getFirstDayOfMonth(year, month); const days = ['일', '월', '화', '수', '목', '금', '토']; - const monthNames = ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월']; // 스케줄이 있는 날짜 목록 const scheduleDates = schedules.map(s => s.date); @@ -29,17 +29,22 @@ function Schedule() { const prevMonth = () => { setCurrentDate(new Date(year, month - 1, 1)); - setSelectedDate(null); }; const nextMonth = () => { setCurrentDate(new Date(year, month + 1, 1)); - setSelectedDate(null); }; const selectDate = (day) => { const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`; - setSelectedDate(selectedDate === dateStr ? null : dateStr); + if (hasSchedule(day)) { + setSelectedDate(selectedDate === dateStr ? null : dateStr); + } + }; + + const selectYearMonth = (newYear, newMonth) => { + setCurrentDate(new Date(newYear, newMonth, 1)); + setShowYearMonthPicker(false); }; // 필터링된 스케줄 @@ -57,6 +62,10 @@ function Schedule() { }; }; + // 년도 범위 (현재 년도 기준 ±5년) + const currentYear = new Date().getFullYear(); + const yearRange = Array.from({ length: 11 }, (_, i) => currentYear - 5 + i); + return (
@@ -80,34 +89,88 @@ function Schedule() {
- {/* 달력 */} + {/* 달력 - 더 큰 사이즈 */} -
+
{/* 달력 헤더 */} -
+
+ -

- {year}년 {monthNames[month]} -

+ {/* 년/월 선택 팝업 */} + + {showYearMonthPicker && ( + + {/* 년도 선택 */} +
+

년도

+
+ {yearRange.map((y) => ( + + ))} +
+
+ {/* 월 선택 */} +
+

+
+ {Array.from({ length: 12 }, (_, i) => i).map((m) => ( + + ))} +
+
+
+ )} +
+ {/* 요일 헤더 */} -
+
{days.map((day, i) => (
hasEvent && selectDate(day)} - className={`aspect-square flex flex-col items-center justify-center rounded-lg text-sm transition-all - ${isSelected ? 'bg-primary text-white' : ''} + onClick={() => selectDate(day)} + disabled={!hasEvent} + className={`aspect-square flex flex-col items-center justify-center rounded-xl text-base font-medium transition-all + ${isSelected ? 'bg-primary text-white shadow-md' : ''} ${isToday && !isSelected ? 'ring-2 ring-primary' : ''} ${hasEvent && !isSelected ? 'hover:bg-primary/10 cursor-pointer' : ''} - ${!hasEvent ? 'cursor-default' : ''} + ${!hasEvent ? 'cursor-default opacity-60' : ''} ${dayOfWeek === 0 && !isSelected ? 'text-red-500' : ''} ${dayOfWeek === 6 && !isSelected ? 'text-blue-500' : ''} `} > {day} {hasEvent && ( - + )} ); })}
- {/* 범례 */} -
-
+ {/* 범례 및 전체보기 */} +
+
일정 있음
- {selectedDate && ( - - )} +