Skip to content

Commit 8d2bfb8

Browse files
committed
fix: month count with year
1 parent 00aa569 commit 8d2bfb8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/components/MonthLogTable/MonthLogTable.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,11 @@ function MonthLogTable(props: MonthLogTableProps) {
184184
const { className, year, activityList, onSelect } = props
185185

186186
const getMonthDistanceText = useCallback(
187-
(month: number) => {
187+
(year: number, month: number) => {
188188
const monthActivityList = activityList.filter((a) => {
189-
return getMonth(parseISO(a.startDate)) === month
189+
const yearMatch = getYear(parseISO(a.startDate)) === year
190+
const monthMatch = getMonth(parseISO(a.startDate)) === month
191+
return yearMatch && monthMatch
190192
})
191193
const distance = monthActivityList.reduce(
192194
(acc, cur) => acc + cur.distance,
@@ -254,7 +256,7 @@ function MonthLogTable(props: MonthLogTableProps) {
254256
{format(new Date(year, month), 'MMM')}
255257
</div>
256258
<div className={styles.monthCount}>
257-
{getMonthDistanceText(month)}
259+
{getMonthDistanceText(year, month)}
258260
</div>
259261
</div>
260262
<div className={styles.weekListContainer}>

0 commit comments

Comments
 (0)