-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
99 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
apps/member/src/components/calendar/CalendarStatusSection/CalendarStatusSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Section from '@components/common/Section/Section'; | ||
import StatusCard from '@components/common/StatusCard/StatusCard'; | ||
import { useSchedule } from '@hooks/queries'; | ||
import { calculateDDay, findClosestEvent, transformEvents } from '@utils/date'; | ||
import { FcCalendar, FcLeave, FcOvertime, FcAlarmClock } from 'react-icons/fc'; | ||
import { useScheduleCollect } from '@hooks/queries/useScheduleCollect'; | ||
|
||
const CalendarStatusSection = () => { | ||
const { data: yearData } = useScheduleCollect(); | ||
const { data: monthData } = useSchedule(); | ||
|
||
const closestEvent = findClosestEvent(transformEvents(monthData.items)); | ||
const closestDDay = closestEvent?.startDate | ||
? `D-${calculateDDay(closestEvent.startDate)}` | ||
: '이번 달에 남은 일정이 없어요'; | ||
|
||
return ( | ||
<Section> | ||
<Section.Header | ||
title="모아보기" | ||
description="일정을 한 눈에 확인하세요" | ||
/> | ||
<Section.Body className="grid grid-cols-2 gap-4 md:grid-cols-4 break-keep"> | ||
<StatusCard | ||
icon={<FcCalendar size={32} />} | ||
label={`${yearData.totalScheduleCount}회`} | ||
description="이번 연도 동아리의 모든 일정 횟수에요." | ||
/> | ||
<StatusCard | ||
icon={<FcLeave size={32} />} | ||
label={`${yearData.totalEventCount}회`} | ||
description="이번 연도 총회, MT 등 중요도가 높은 행사 횟수에요." | ||
/> | ||
<StatusCard | ||
icon={<FcOvertime size={32} />} | ||
label={`${monthData.totalItems}회`} | ||
description="이번 달 동아리 일정 횟수에요." | ||
/> | ||
<StatusCard | ||
icon={<FcAlarmClock size={32} />} | ||
label={closestDDay} | ||
description="가장 가까운 일정까지 남은 일수에요." | ||
/> | ||
</Section.Body> | ||
</Section> | ||
); | ||
}; | ||
|
||
export default CalendarStatusSection; |
2 changes: 1 addition & 1 deletion
2
apps/member/src/components/common/StatusCard/StatusCard.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export interface StatusCardProps { | ||
icon: React.ReactNode; | ||
label: string; | ||
label: string | number; | ||
description: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { getScheduleCollect } from '@api/schedule'; | ||
import { QUERY_KEY } from '@constants/key'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
/** | ||
* 일정 모아보기를 조회합니다. | ||
*/ | ||
export const useScheduleCollect = () => { | ||
return useSuspenseQuery({ | ||
queryKey: [QUERY_KEY.SCHEDULE_COLLECT], | ||
queryFn: getScheduleCollect, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters