featu: web-23 캘린더 일정 조회 페이지#25
Conversation
There was a problem hiding this comment.
Code Review
This pull request integrates admin calendar API endpoints into the admin schedule page, replacing local state-based operations with server-side fetching, creation, editing, and deletion of schedules. It also adds error handling using an alert modal. The review feedback suggests improving the robustness of the schedule update logic by comparing schedules using their unique calendarId instead of array indices, and ensuring that the UI is synchronized with the server even if some concurrent update requests fail during a bulk update.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const changedSchedules = updatedSchedules.filter( | ||
| (edited, index) => edited.title !== visibleSchedules[index]?.title | ||
| ); |
There was a problem hiding this comment.
updatedSchedules와 visibleSchedules를 인덱스(index) 기준으로 비교하여 변경 여부를 판단하고 있습니다.
하지만 React의 상태 변경이나 비동기 데이터 갱신 등으로 인해 visibleSchedules의 순서나 원소 개수가 변할 경우, 인덱스 기반 비교는 잘못된 객체를 비교하거나 undefined 참조 오류를 발생시킬 수 있어 안전하지 않습니다.
고유 식별자인 calendarId를 사용하여 원래 일정을 찾아 비교하는 것이 훨씬 안전하고 견고합니다.
| const changedSchedules = updatedSchedules.filter( | |
| (edited, index) => edited.title !== visibleSchedules[index]?.title | |
| ); | |
| const changedSchedules = updatedSchedules.filter((edited) => { | |
| const original = visibleSchedules.find((s) => s.calendarId === edited.calendarId); | |
| return original ? edited.title !== original.title : false; | |
| }); |
| try { | ||
| await Promise.all( | ||
| changedSchedules.map((schedule) => | ||
| updateCalendarSchedule(schedule.calendarId, { | ||
| title: schedule.title, | ||
| startDate: schedule.startDate, | ||
| endDate: schedule.endDate, | ||
| }) | ||
| ) | ||
| ); | ||
| await fetchMonthSchedules(); | ||
| } catch (error) { | ||
| console.error('[AdminSchedulePage] 일정 수정 실패', error); | ||
| setAlertMessage(SAVE_ERROR_MESSAGE); | ||
| } |
There was a problem hiding this comment.
Promise.all을 사용하여 여러 일정을 동시에 수정할 때, 하나라도 실패하면 전체가 거부(reject)되어 catch 블록으로 이동합니다. 이 경우 성공적으로 수정된 일부 일정이 있더라도 fetchMonthSchedules()가 호출되지 않아 화면의 데이터가 서버와 동기화되지 않는 문제가 발생할 수 있습니다.
오류가 발생하더라도 최종적으로 fetchMonthSchedules()를 호출하여 최신 상태를 반영할 수 있도록 finally 블록을 사용하거나 에러 핸들링을 보완하는 것이 좋습니다.
try {
await Promise.all(
changedSchedules.map((schedule) =>
updateCalendarSchedule(schedule.calendarId, {
title: schedule.title,
startDate: schedule.startDate,
endDate: schedule.endDate,
})
)
);
} catch (error) {
console.error('[AdminSchedulePage] 일정 수정 실패', error);
setAlertMessage(SAVE_ERROR_MESSAGE);
} finally {
await fetchMonthSchedules();
}
📌 작업 내용
🔗 관련 이슈
📸 스크린샷 / 화면 녹화
🧪 테스트 방법
✅ 체크리스트
npm run lint통과를 확인했습니다npm run format을 적용했습니다console.log를 제거했습니다develop인지 확인했습니다💬 리뷰어에게 한 마디
web-22는 web-10과 같이 작업부분이 겹쳐서 생략했습니다