Skip to content

featu: web-23 캘린더 일정 조회 페이지#25

Open
chlgusdn0203 wants to merge 1 commit into
developfrom
feature-web-23
Open

featu: web-23 캘린더 일정 조회 페이지#25
chlgusdn0203 wants to merge 1 commit into
developfrom
feature-web-23

Conversation

@chlgusdn0203

Copy link
Copy Markdown

📌 작업 내용

🔗 관련 이슈

📸 스크린샷 / 화면 녹화

🧪 테스트 방법

  1. 관리자 로그인 후
  2. /admin/schedule

✅ 체크리스트

  • npm run lint 통과를 확인했습니다
  • npm run format 을 적용했습니다
  • 디버깅용 console.log 를 제거했습니다
  • 사용하지 않는 import / 변수를 정리했습니다
  • 컨벤션 (README.md) 을 준수했습니다
  • base 브랜치가 develop 인지 확인했습니다

💬 리뷰어에게 한 마디

web-22는 web-10과 같이 작업부분이 겹쳐서 생략했습니다

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +147 to 149
const changedSchedules = updatedSchedules.filter(
(edited, index) => edited.title !== visibleSchedules[index]?.title
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

updatedSchedulesvisibleSchedules를 인덱스(index) 기준으로 비교하여 변경 여부를 판단하고 있습니다.

하지만 React의 상태 변경이나 비동기 데이터 갱신 등으로 인해 visibleSchedules의 순서나 원소 개수가 변할 경우, 인덱스 기반 비교는 잘못된 객체를 비교하거나 undefined 참조 오류를 발생시킬 수 있어 안전하지 않습니다.

고유 식별자인 calendarId를 사용하여 원래 일정을 찾아 비교하는 것이 훨씬 안전하고 견고합니다.

Suggested change
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;
});

Comment on lines +152 to +166
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);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant