@@ -6,7 +6,7 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
6
6
import { Badge } from '@/components/ui/badge'
7
7
import { Button } from '@/components/ui/button'
8
8
import { Check , Circle , CircleCheck } from 'lucide-react'
9
- import { d2s , getNow , t2d , getCompletedHabitsForDate , isHabitDue , getISODate } from '@/lib/utils'
9
+ import { d2s , getNow , t2d , getCompletedHabitsForDate , isHabitDue , getISODate , getCompletionsForToday , getCompletionsForDate } from '@/lib/utils'
10
10
import { useAtom } from 'jotai'
11
11
import { useHabits } from '@/hooks/useHabits'
12
12
import { habitsAtom , settingsAtom , completedHabitsMapAtom } from '@/lib/atoms'
@@ -87,9 +87,8 @@ export default function HabitCalendar() {
87
87
date : selectedDate
88
88
} ) )
89
89
. map ( ( habit ) => {
90
- const habitsForDate = completedHabitsMap . get ( getISODate ( { dateTime : selectedDate , timezone : settings . system . timezone } ) ) || [ ]
91
- const completionsToday = habitsForDate . filter ( ( h : Habit ) => h . id === habit . id ) . length
92
- const isCompleted = completionsToday >= ( habit . targetCompletions || 1 )
90
+ const completions = getCompletionsForDate ( { habit, date : selectedDate , timezone : settings . system . timezone } )
91
+ const isCompleted = completions >= ( habit . targetCompletions || 1 )
93
92
return (
94
93
< li key = { habit . id } className = "flex items-center justify-between gap-2" >
95
94
< span >
@@ -99,7 +98,7 @@ export default function HabitCalendar() {
99
98
< div className = "flex items-center gap-2" >
100
99
{ habit . targetCompletions && (
101
100
< span className = "text-sm text-muted-foreground" >
102
- { completionsToday } /{ habit . targetCompletions }
101
+ { completions } /{ habit . targetCompletions }
103
102
</ span >
104
103
) }
105
104
< button
@@ -116,8 +115,8 @@ export default function HabitCalendar() {
116
115
className = "absolute h-4 w-4 rounded-full overflow-hidden"
117
116
style = { {
118
117
background : `conic-gradient(
119
- currentColor ${ ( completionsToday / ( habit . targetCompletions ?? 1 ) ) * 360 } deg,
120
- transparent ${ ( completionsToday / ( habit . targetCompletions ?? 1 ) ) * 360 } deg 360deg
118
+ currentColor ${ ( completions / ( habit . targetCompletions ?? 1 ) ) * 360 } deg,
119
+ transparent ${ ( completions / ( habit . targetCompletions ?? 1 ) ) * 360 } deg 360deg
121
120
)` ,
122
121
mask : 'radial-gradient(transparent 50%, black 51%)' ,
123
122
WebkitMask : 'radial-gradient(transparent 50%, black 51%)'
0 commit comments