Skip to content

Commit

Permalink
chore: Calendarをリファクタリング
Browse files Browse the repository at this point in the history
  • Loading branch information
AtsushiM committed Jan 29, 2025
1 parent 1c2384a commit e9a39e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 6 additions & 4 deletions packages/smarthr-ui/src/components/Calendar/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,22 @@ export const Calendar = forwardRef<HTMLDivElement, Props & ElementProps>(
}, [className])

const formattedFrom = useMemo(() => {
const day = dayjs(getFromDate(from))
const date = getFromDate(from)
const day = dayjs(date)

return {
day,
date: day.toDate(),
date,
year: day.year(),
}
}, [from])
const formattedTo = useMemo(() => {
const day = dayjs(getToDate(to))
const date = getToDate(to)
const day = dayjs(date)

return {
day,
date: day.toDate(),
date,
year: day.year(),
}
}, [to])
Expand Down
14 changes: 6 additions & 8 deletions packages/smarthr-ui/src/components/Calendar/CalendarTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,8 @@ export const CalendarTable: FC<Props & ElementProps> = ({
<tbody>
{current.months.map((week, weekIndex) => (
<tr key={weekIndex}>
{week.map((date, dateIndex) => {
if (!date) {
return <NullTd key={dateIndex} className={styles.td} />
}

return (
{week.map((date, dateIndex) =>
date ? (
<SelectTdButton
key={dateIndex}
date={date}
Expand All @@ -90,8 +86,10 @@ export const CalendarTable: FC<Props & ElementProps> = ({
onClick={onSelectDate}
styles={styles}
/>
)
})}
) : (
<NullTd key={dateIndex} className={styles.td} />
),
)}
</tr>
))}
</tbody>
Expand Down

0 comments on commit e9a39e5

Please sign in to comment.