feat:web-31 캘린더 일정 조회 페이지#16
Conversation
There was a problem hiding this comment.
Code Review
This pull request integrates API endpoints for fetching visitor calendar schedules by year and month, replacing static data in the schedule page. It also refactors the calendar view to simplify schedule visibility logic and adjust styling. The review feedback suggests adding defensive programming practices in the API module, specifically using optional chaining and array checks, to prevent potential runtime errors when processing API responses.
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 flattenCalendarGroups = (calendarGroups) => | ||
| calendarGroups.flatMap(({ yearMonth, schedules }) => | ||
| schedules.map((schedule) => ({ ...schedule, yearMonth })) | ||
| ); |
There was a problem hiding this comment.
API 응답 데이터가 비어있거나 예상치 못한 구조(예: calendarGroups가 배열이 아니거나, 특정 그룹의 schedules가 null 또는 undefined인 경우)로 올 때 런타임 에러가 발생할 수 있습니다. 안전한 데이터 처리를 위해 Array.isArray 검사를 추가하여 방어적으로 코드를 작성하는 것이 좋습니다.
const flattenCalendarGroups = (calendarGroups) => {
if (!Array.isArray(calendarGroups)) return [];
return calendarGroups.flatMap(({ yearMonth, schedules }) => {
if (!Array.isArray(schedules)) return [];
return schedules.map((schedule) => ({ ...schedule, yearMonth }));
});
};| params: { year }, | ||
| }); | ||
|
|
||
| return flattenCalendarGroups(response.data.data); |
| return response.data.data.map((schedule) => ({ | ||
| ...schedule, | ||
| yearMonth: `${year}-${paddedMonth}`, | ||
| })); |
There was a problem hiding this comment.
API 응답의 response.data?.data가 배열이 아니거나 null/undefined인 경우 .map 호출 시 에러가 발생할 수 있습니다. 안전하게 빈 배열([])을 기본값으로 사용하도록 방어적 코드를 추가하는 것이 좋습니다.
const schedules = response.data?.data;
if (!Array.isArray(schedules)) return [];
return schedules.map((schedule) => ({
...schedule,
yearMonth: year + '-' + paddedMonth,
}));
년도별 조회, 월별 조회