import { format, isPast, endOfDay } from 'date-fns'; import { useNavigate } from 'react-router-dom'; import { CheckCircle2 } from 'lucide-react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { cn } from '@/lib/utils'; interface DashboardTodo { id: number; title: string; due_date: string; priority: string; category?: string; } interface TodoWidgetProps { todos: DashboardTodo[]; } const priorityColors: Record = { low: 'bg-green-500/10 text-green-400 border-green-500/20', medium: 'bg-yellow-500/10 text-yellow-400 border-yellow-500/20', high: 'bg-red-500/10 text-red-400 border-red-500/20', }; const dotColors: Record = { high: 'bg-red-400', medium: 'bg-yellow-400', low: 'bg-green-400', }; export default function TodoWidget({ todos }: TodoWidgetProps) { const navigate = useNavigate(); return (
Upcoming Todos
{todos.length === 0 ? (

All caught up.

) : (
{todos.slice(0, 5).map((todo) => { const isOverdue = isPast(endOfDay(new Date(todo.due_date))); return (
navigate('/todos', { state: { todoId: todo.id } })} className="flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-white/5 transition-colors duration-150 cursor-pointer" >
{todo.title} {format(new Date(todo.due_date), 'MMM d')} {isOverdue && ' overdue'} {todo.priority}
); })}
)} ); }