diff --git a/src/routes/tasks.index.tsx b/src/routes/tasks.index.tsx index 38b4b13..e729a45 100644 --- a/src/routes/tasks.index.tsx +++ b/src/routes/tasks.index.tsx @@ -18,7 +18,7 @@ import { import { Switch } from "@/components/ui/switch"; import { Label } from "@/components/ui/label"; import { Plus, Search, Calendar as CalIcon, AlertCircle } from "lucide-react"; -import { format, isBefore, startOfDay, isSameDay, addDays } from "date-fns"; +import { format, isBefore, startOfDay, isSameDay, addDays, differenceInCalendarDays } from "date-fns"; import { TaskDetailPanel } from "@/components/tasks/task-detail-panel"; import { NewTaskDialog } from "@/components/tasks/new-task-dialog"; import { cn } from "@/lib/utils"; @@ -280,6 +280,22 @@ function TasksPage() { {items.map((t) => { const ids = assigneesByTask[t.id] || []; const c = t.case_id ? casesById[t.case_id] : null; + const assigneeNames = ids + .map((uid) => profilesById[uid]) + .filter(Boolean) + .map((p) => p.full_name || p.email); + let countdown: { label: string; tone: string } | null = null; + if (t.due_date && t.status !== "complete") { + const days = differenceInCalendarDays(startOfDay(new Date(t.due_date)), startOfDay(new Date())); + if (days < 0) + countdown = { + label: `${Math.abs(days)}d overdue`, + tone: "text-destructive", + }; + else if (days === 0) countdown = { label: "Due today", tone: "text-orange-600" }; + else if (days === 1) countdown = { label: "Due tomorrow", tone: "text-orange-600" }; + else countdown = { label: `in ${days}d`, tone: "text-muted-foreground" }; + } return (
{t.title}
- {c && ( -
- {c.case_number} — {c.title} -
- )} +
+ {c && ( + + {c.case_number} — {c.title} + + )} + {assigneeNames.length > 0 && ( + + Assigned: {assigneeNames.slice(0, 2).join(", ")} + {assigneeNames.length > 2 ? ` +${assigneeNames.length - 2}` : ""} + + )} + {!assigneeNames.length && Unassigned} +
{t.due_date && ( -
- - {format(new Date(t.due_date), "MMM d")} +
+
+ + {format(new Date(t.due_date), "MMM d, yyyy")} +
+ {countdown && ( +
+ {countdown.label} +
+ )}
)}