Skip to content

Commit

Permalink
refactor: 이전 달력/다음 달력에 대한 값을 변수로 저장하여 대입하는 방식으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
wzrabbit committed Dec 26, 2023
1 parent 2471116 commit b1479c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
15 changes: 7 additions & 8 deletions frontend/src/components/my_calendar/MyCalendar/MyCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,19 @@ const MyCalendar = (props: MyCalendarProps) => {

const { teamPlaces } = useTeamPlace();

const prevCalendarYear = month === 0 ? year - 1 : year;
const prevCalendarMonth = month === 0 ? 11 : month - 1;
const nextCalendarYear = month === 11 ? year + 1 : year;
const nextCalendarMonth = month === 11 ? 0 : month + 1;

const schedules = useFetchMySchedules(
generateCalendarRangeByYearMonth(year, month),
);
usePrefetchMySchedules(
generateCalendarRangeByYearMonth(
month === 0 ? year - 1 : year,
month === 0 ? 11 : month - 1,
),
generateCalendarRangeByYearMonth(prevCalendarYear, prevCalendarMonth),
);
usePrefetchMySchedules(
generateCalendarRangeByYearMonth(
month === 11 ? year + 1 : year,
month === 11 ? 0 : month + 1,
),
generateCalendarRangeByYearMonth(nextCalendarYear, nextCalendarMonth),
);

const scheduleCircles = generateScheduleCirclesMatrix(year, month, schedules);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,22 @@ const TeamCalendar = (props: TeamCalendarProps) => {
handlers: { handleScheduleModalOpen },
} = useScheduleModal();

const prevCalendarYear = month === 0 ? year - 1 : year;
const prevCalendarMonth = month === 0 ? 11 : month - 1;
const nextCalendarYear = month === 11 ? year + 1 : year;
const nextCalendarMonth = month === 11 ? 0 : month + 1;

const schedules = useFetchSchedules(
teamPlaceId,
generateCalendarRangeByYearMonth(year, month),
);
usePrefetchSchedules(
teamPlaceId,
generateCalendarRangeByYearMonth(
month === 0 ? year - 1 : year,
month === 0 ? 11 : month - 1,
),
generateCalendarRangeByYearMonth(prevCalendarYear, prevCalendarMonth),
);
usePrefetchSchedules(
teamPlaceId,
generateCalendarRangeByYearMonth(
month === 11 ? year + 1 : year,
month === 11 ? 0 : month + 1,
),
generateCalendarRangeByYearMonth(nextCalendarYear, nextCalendarMonth),
);

const [clickedDate, setClickedDate] = useState(currentDate);
Expand Down

0 comments on commit b1479c6

Please sign in to comment.