Skip to content

Commit

Permalink
fix: month count with year
Browse files Browse the repository at this point in the history
  • Loading branch information
kitayoshi committed Jul 6, 2024
1 parent 00aa569 commit 8d2bfb8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/MonthLogTable/MonthLogTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,11 @@ function MonthLogTable(props: MonthLogTableProps) {
const { className, year, activityList, onSelect } = props

const getMonthDistanceText = useCallback(
(month: number) => {
(year: number, month: number) => {
const monthActivityList = activityList.filter((a) => {
return getMonth(parseISO(a.startDate)) === month
const yearMatch = getYear(parseISO(a.startDate)) === year
const monthMatch = getMonth(parseISO(a.startDate)) === month
return yearMatch && monthMatch
})
const distance = monthActivityList.reduce(
(acc, cur) => acc + cur.distance,
Expand Down Expand Up @@ -254,7 +256,7 @@ function MonthLogTable(props: MonthLogTableProps) {
{format(new Date(year, month), 'MMM')}
</div>
<div className={styles.monthCount}>
{getMonthDistanceText(month)}
{getMonthDistanceText(year, month)}
</div>
</div>
<div className={styles.weekListContainer}>
Expand Down

0 comments on commit 8d2bfb8

Please sign in to comment.