Skip to content

feat:web-31 캘린더 일정 조회 페이지#16

Open
kimbosung521 wants to merge 2 commits into
developfrom
feature-web-31
Open

feat:web-31 캘린더 일정 조회 페이지#16
kimbosung521 wants to merge 2 commits into
developfrom
feature-web-31

Conversation

@kimbosung521

Copy link
Copy Markdown

년도별 조회, 월별 조회

@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 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.

Comment thread src/apis/calendar.js Outdated
Comment on lines +3 to +6
const flattenCalendarGroups = (calendarGroups) =>
calendarGroups.flatMap(({ yearMonth, schedules }) =>
schedules.map((schedule) => ({ ...schedule, yearMonth }))
);

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

API 응답 데이터가 비어있거나 예상치 못한 구조(예: calendarGroups가 배열이 아니거나, 특정 그룹의 schedulesnull 또는 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 }));
  });
};

Comment thread src/apis/calendar.js Outdated
params: { year },
});

return flattenCalendarGroups(response.data.data);

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

response.data가 존재하지 않을 경우 response.data.data 접근 시 에러가 발생할 수 있습니다. 옵셔널 체이닝(?.)을 사용하여 안전하게 접근하도록 개선하는 것이 좋습니다.

Suggested change
return flattenCalendarGroups(response.data.data);
return flattenCalendarGroups(response.data?.data);

Comment thread src/apis/calendar.js Outdated
Comment on lines +22 to +25
return response.data.data.map((schedule) => ({
...schedule,
yearMonth: `${year}-${paddedMonth}`,
}));

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

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

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