mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-03-09 03:59:50 +01:00
fix: migrate atoms to normal functions
This commit is contained in:
15
lib/utils.ts
15
lib/utils.ts
@@ -6,6 +6,7 @@ import { DateTime, DateTimeFormatOptions } from "luxon"
|
||||
import { Formats } from "next-intl"
|
||||
import { datetime, RRule } from 'rrule'
|
||||
import { twMerge } from "tailwind-merge"
|
||||
import { PomodoroAtom } from "./atoms"
|
||||
import { DUE_MAP, INITIAL_DUE, RECURRENCE_RULE_MAP } from "./constants"
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
@@ -84,6 +85,20 @@ export function getCompletionsForToday({
|
||||
return getCompletionsForDate({ habit, date: getTodayInTimezone(timezone), timezone })
|
||||
}
|
||||
|
||||
export function getTodayCompletions({ selectedHabitId }: PomodoroAtom, { habits }: HabitsData, { system: { timezone } }: Settings): number {
|
||||
if (!selectedHabitId)
|
||||
return 0;
|
||||
|
||||
const selectedHabit = habits.find(h => h.id === selectedHabitId!);
|
||||
if (!selectedHabit)
|
||||
return 0;
|
||||
|
||||
return getCompletionsForToday({
|
||||
habit: selectedHabit,
|
||||
timezone: timezone
|
||||
});
|
||||
}
|
||||
|
||||
export function getCompletedHabitsForDate({
|
||||
habits,
|
||||
date,
|
||||
|
||||
Reference in New Issue
Block a user