added windows notifications and have avatar health/energy update with task completion
This commit is contained in:
31
lib/daily-reminder-status.ts
Normal file
31
lib/daily-reminder-status.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { hasCompletedDailyQuizToday } from "@/lib/daily-quiz-storage";
|
||||
import { getDailyTasks } from "@/lib/daily-tasks";
|
||||
import { getTodayDateKey, isHabitCompletedToday } from "@/lib/habits-storage";
|
||||
|
||||
export type DailyReminderStatus = {
|
||||
dateKey: string;
|
||||
quizCompleted: boolean;
|
||||
totalTasks: number;
|
||||
incompleteTaskCount: number;
|
||||
needsReminder: boolean;
|
||||
};
|
||||
|
||||
export async function getDailyReminderStatus(): Promise<DailyReminderStatus> {
|
||||
const dateKey = getTodayDateKey();
|
||||
const [quizCompleted, tasks] = await Promise.all([
|
||||
hasCompletedDailyQuizToday(),
|
||||
getDailyTasks(),
|
||||
]);
|
||||
|
||||
const incompleteTaskCount = tasks.filter(
|
||||
(task) => !isHabitCompletedToday(task, dateKey),
|
||||
).length;
|
||||
|
||||
return {
|
||||
dateKey,
|
||||
quizCompleted,
|
||||
totalTasks: tasks.length,
|
||||
incompleteTaskCount,
|
||||
needsReminder: !quizCompleted || incompleteTaskCount > 0,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user