@@ -3,6 +3,7 @@ import dayGridPlugin from '@fullcalendar/daygrid';
3
3
import interactionPlugin from '@fullcalendar/interaction' ;
4
4
import { useRef , useState , useEffect } from 'react' ;
5
5
import { useEventState } from '@/stores/myEventsStore' ;
6
+ import { getPersonalSchedule } from '@/apis/personalScheduleApi' ;
6
7
7
8
const Calendar : React . FC = ( ) => {
8
9
const [ calendarHeight , setCalendarHeight ] = useState < string | number > ( 'auto' ) ;
@@ -49,6 +50,8 @@ const Calendar: React.FC = () => {
49
50
}
50
51
} ;
51
52
53
+ const { events, addEvents } = useEventState ( ) ;
54
+
52
55
useEffect ( ( ) => {
53
56
const calendarApi = calendarRef ?. current ?. getApi ( ) ;
54
57
@@ -62,15 +65,19 @@ const Calendar: React.FC = () => {
62
65
window . addEventListener ( 'resize' , updateSize ) ;
63
66
updateSize ( ) ; // 컴포넌트 마운트 시 화면 크기에 따른 업데이트
64
67
68
+ const data = getPersonalSchedule ( ) ;
69
+ data . then ( ( schedule ) => {
70
+ schedule . map ( ( x ) => addEvents ( { ...x , start : x . start_date , end : x . end_date } ) ) ;
71
+ } ) ;
72
+
65
73
return ( ) => {
66
74
window . removeEventListener ( 'resize' , updateSize ) ;
67
75
if ( calendarApi ) {
68
76
calendarApi . off ( 'datesSet' , updateTitle ) ;
69
77
}
70
78
} ;
71
- } , [ updateSize ] ) ;
79
+ } , [ updateSize , addEvents ] ) ;
72
80
73
- const events = useEventState ( ) ;
74
81
return (
75
82
< div >
76
83
< FullCalendar
0 commit comments