-
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.
✨ feat: implement a component for calculating weeks and days #17
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { formatDateToYYYYMMDD, formatDate } from '@shared/utils/date'; | ||
import { createDateRange } from '@shared/utils/createDateRange'; | ||
import { Text, Flex, Button } from '@jdesignlab/react'; | ||
import { selectorStyle, scheduleListStyle } from '../../styles/sidebarStyle'; | ||
import { useQueryWorkspace } from '../../hooks/useQueryWorkspace'; | ||
|
||
export const ScheduleList = () => { | ||
const { data } = useQueryWorkspace(); | ||
if (!data) { | ||
return ( | ||
<Flex justify="center" items="center" style={{ height: '100%' }}> | ||
<Text color="info">🥹 스터디 데이터가 존재하지 않습니다.</Text> | ||
</Flex> | ||
); | ||
} | ||
const startDate = data.challengeInfo.duration.start; | ||
const endDate = data.challengeInfo.duration.end; | ||
const range = createDateRange(startDate, endDate, data.challengeInfo.isDaily); | ||
|
||
return ( | ||
<ol css={scheduleListStyle} role="listbox"> | ||
{range.map((rangeItem) => { | ||
const formatDateByYMD = formatDateToYYYYMMDD(rangeItem.date); | ||
const formatDateByKo = formatDate(rangeItem.date, 'ko'); | ||
const turn = rangeItem.order.toString(); | ||
return ( | ||
<li css={selectorStyle} key={formatDateByYMD}> | ||
<Button variant="unstyled" onClick={() => {}} type="button"> | ||
<Text variant="heading" color="primary-400"> | ||
{`Lesson ${turn}`} | ||
</Text> | ||
<Text variant="label" size="sm" color="blueGrey-base"> | ||
~{formatDateByKo} | ||
</Text> | ||
</Button> | ||
</li> | ||
); | ||
})} | ||
</ol> | ||
); | ||
}; |
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