|
1 |
| -/* eslint-disable react-hooks/exhaustive-deps */ |
2 | 1 | import FullCalendar from '@fullcalendar/react';
|
3 |
| -// import { EventClickArg } from '@fullcalendar/core'; |
4 | 2 | import dayGridPlugin from '@fullcalendar/daygrid';
|
5 | 3 | import interactionPlugin from '@fullcalendar/interaction';
|
6 | 4 | import { useRef, useState, useEffect, useCallback } from 'react';
|
7 | 5 | import { useEventState } from '@/stores/myEventsStore';
|
8 | 6 | import { getPersonalSchedule } from '@/apis/personalScheduleApi';
|
9 | 7 | import { Events } from '../../utils/index.ts';
|
10 | 8 | import { formatDateRange, formatTime } from '../../utils/dateUtils';
|
11 |
| -/* |
12 |
| -type Event = { |
13 |
| - title: string; |
14 |
| - start: string; |
15 |
| - end: string; |
16 |
| - backgroundColor?: string; |
17 |
| - borderColor?: string; |
18 |
| - textColor?: string; |
19 |
| -}; |
20 |
| -*/ |
21 | 9 |
|
22 | 10 | interface EventInfo {
|
23 | 11 | timeText: string;
|
@@ -154,24 +142,23 @@ export default function Calendar() {
|
154 | 142 | }, [updateSize]);
|
155 | 143 |
|
156 | 144 | const [isLoaded, setIsLoaded] = useState(false); // 데이터 로딩 상태
|
157 |
| - |
158 | 145 | useEffect(() => {
|
159 | 146 | if (!isLoaded) {
|
160 | 147 | getPersonalSchedule().then((schedule) => {
|
161 |
| - const uniqueEvents = schedule.filter( |
162 |
| - (newEvent) => |
163 |
| - !events.some( |
164 |
| - (existingEvent) => existingEvent.start === newEvent.start_date && existingEvent.title === newEvent.title, |
165 |
| - ), |
| 148 | + const uniqueEvents = schedule.filter(newEvent => |
| 149 | + !events.some(existingEvent => |
| 150 | + existingEvent.start === newEvent.start_date && existingEvent.title === newEvent.title |
| 151 | + ) |
166 | 152 | );
|
167 | 153 | if (uniqueEvents.length > 0) {
|
168 | 154 | const eventsToAdd = convertEvents(uniqueEvents);
|
169 |
| - eventsToAdd.forEach((eventToAdd) => addEvents(eventToAdd)); |
| 155 | + eventsToAdd.forEach(eventToAdd => addEvents(eventToAdd)); |
170 | 156 | setIsLoaded(true);
|
171 | 157 | }
|
172 | 158 | });
|
173 | 159 | }
|
174 |
| - }, [events, addEvents]); |
| 160 | + }, [events, addEvents, isLoaded]); |
| 161 | + |
175 | 162 |
|
176 | 163 | return (
|
177 | 164 | <div>
|
@@ -214,6 +201,7 @@ export default function Calendar() {
|
214 | 201 | <div className="mt-10">{selectedDate && <EventCards events={selectedEvents} date={selectedDate} />}</div>
|
215 | 202 | </div>
|
216 | 203 | );
|
| 204 | + |
217 | 205 | }
|
218 | 206 |
|
219 | 207 | function renderEventContent(eventInfo: EventInfo) {
|
|
0 commit comments