import { db } from "@/lib/db"; import { isOverdue, isDueSoon, describeRecurrence } from "@/lib/tasks/schedule"; import { formatDate } from "@/lib/utils"; import { AddTaskButton } from "@/components/tasks/add-task-button"; import { CompleteTaskButton } from "@/components/tasks/complete-task-button"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent } from "@/components/ui/card"; import { CalendarDays, Leaf, Home, Wrench, CheckCircle2, AlertCircle, Clock } from "lucide-react"; import Link from "next/link"; export const metadata = { title: "Reminders" }; const CATEGORY_ICONS = { GARDEN: Leaf, HOME: Home, EQUIPMENT: Wrench, OTHER: Clock, }; const CATEGORY_LABELS = { GARDEN: "Garden", HOME: "Home", EQUIPMENT: "Equipment", OTHER: "Other", }; export default async function TasksPage() { const tasks = await db.task.findMany({ where: { active: true }, orderBy: { nextDue: "asc" }, include: { plant: { select: { id: true, commonName: true, variety: true } } }, }); const overdue = tasks.filter((t) => isOverdue(t.nextDue)); const upcoming = tasks.filter((t) => !isOverdue(t.nextDue) && isDueSoon(t.nextDue, 60)); const later = tasks.filter((t) => !isOverdue(t.nextDue) && !isDueSoon(t.nextDue, 60)); return (
{overdue.length > 0 ? `${overdue.length} overdue · ${upcoming.length} coming up` : `${upcoming.length} coming up in the next 60 days`}
No reminders yet
Add your first reminder to start tracking what needs doing.
{task.title}
{task.notes}
)}{describeRecurrence(task.recurrence, task.intervalDays, task.month)} {task.lastDone && ` · Last done ${formatDate(task.lastDone)}`}
{overdue ? `${Math.abs(daysUntil)}d overdue` : daysUntil === 0 ? "Today" : daysUntil === 1 ? "Tomorrow" : `In ${daysUntil} days`}
{formatDate(task.nextDue)}