mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-20 22:24:28 +01:00
fix
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
import HeatMap from '@uiw/react-heat-map'
|
||||
import { Habit } from '@/lib/types'
|
||||
import { getDateInTimezone } from '@/lib/utils'
|
||||
import { useSettings } from '@/hooks/useSettings'
|
||||
|
||||
interface HabitHeatmapProps {
|
||||
habits: Habit[]
|
||||
@@ -24,9 +26,12 @@ export default function HabitHeatmap({ habits }: HabitHeatmapProps) {
|
||||
count
|
||||
}))
|
||||
|
||||
const { settings } = useSettings()
|
||||
|
||||
// Get start date (30 days ago)
|
||||
const startDate = new Date()
|
||||
startDate.setDate(startDate.getDate() - 30)
|
||||
const now = getDateInTimezone(new Date(), settings.system.timezone)
|
||||
const startDate = now
|
||||
startDate.setDate(now.getDate() - 30)
|
||||
|
||||
return (
|
||||
<div className="p-4 bg-white rounded-lg shadow">
|
||||
|
||||
@@ -5,7 +5,7 @@ import { toast } from '@/hooks/use-toast'
|
||||
import { ToastAction } from '@/components/ui/toast'
|
||||
import { Undo2 } from 'lucide-react'
|
||||
import { Habit } from '@/lib/types'
|
||||
import { getTodayInTimezone } from '@/lib/utils'
|
||||
import { getDateInTimezone, getTodayInTimezone } from '@/lib/utils'
|
||||
|
||||
export function useHabits() {
|
||||
const [habits, setHabits] = useState<Habit[]>([])
|
||||
@@ -21,7 +21,7 @@ export function useHabits() {
|
||||
}
|
||||
|
||||
const addHabit = async (habit: Omit<Habit, 'id'>) => {
|
||||
const newHabit = { ...habit, id: Date.now().toString() }
|
||||
const newHabit = { ...habit, id: getDateInTimezone(new Date(), settings.system.timezone).getTime().toString() }
|
||||
const newHabits = [...habits, newHabit]
|
||||
setHabits(newHabits)
|
||||
await saveHabitsData({ habits: newHabits })
|
||||
@@ -74,7 +74,7 @@ export function useHabits() {
|
||||
}
|
||||
|
||||
const undoComplete = async (habit: Habit) => {
|
||||
const today = new Date().toISOString().split('T')[0]
|
||||
const today = getTodayInTimezone(settings.system.timezone)
|
||||
const updatedHabit = {
|
||||
...habit,
|
||||
completions: habit.completions.filter(date => date !== today)
|
||||
|
||||
Reference in New Issue
Block a user