import { CheckSquare, Square, Clock, AlertCircle, ListTodo } from 'lucide-react'; interface Todo { task?: string; description?: string; content?: string; title?: string; text?: string; priority: 'high' | 'medium' | 'low'; status: 'pending' | 'in_progress' | 'completed'; [key: string]: any; // Allow other properties } interface TodoListProps { todos: Todo[]; } export function TodoList({ todos }: TodoListProps) { // Debug: Log the structure of the first todo if (todos && todos.length > 0) { console.log('Todo structure:', todos[0]); } if (!todos || todos.length === 0) { return (

No tasks in the todo list

); } const getPriorityColor = (priority: string) => { switch (priority) { case 'high': return 'text-red-600 bg-red-50 border-red-200'; case 'medium': return 'text-yellow-600 bg-yellow-50 border-yellow-200'; case 'low': return 'text-green-600 bg-green-50 border-green-200'; default: return 'text-gray-600 bg-gray-50 border-gray-200'; } }; const getStatusIcon = (status: string) => { switch (status) { case 'completed': return ; case 'in_progress': return ; case 'pending': return ; default: return ; } }; const getStatusColor = (status: string) => { switch (status) { case 'completed': return 'bg-green-50 border-green-200'; case 'in_progress': return 'bg-blue-50 border-blue-200'; case 'pending': return 'bg-gray-50 border-gray-200'; default: return 'bg-gray-50 border-gray-200'; } }; // Group todos by status const groupedTodos = { in_progress: todos.filter(t => t.status === 'in_progress'), pending: todos.filter(t => t.status === 'pending'), completed: todos.filter(t => t.status === 'completed') }; return (
{/* Summary stats */}
Todo List
{groupedTodos.in_progress.length > 0 && ( {groupedTodos.in_progress.length} in progress )} {groupedTodos.pending.length > 0 && ( {groupedTodos.pending.length} pending )} {groupedTodos.completed.length > 0 && ( {groupedTodos.completed.length} completed )}
{/* Todo items */}
{/* In Progress items first */} {groupedTodos.in_progress.map((todo, index) => ( ))} {/* Pending items */} {groupedTodos.pending.map((todo, index) => ( ))} {/* Completed items last */} {groupedTodos.completed.map((todo, index) => ( ))}
); } function TodoItem({ todo }: { todo: Todo }) { // Get the task text from various possible property names const getTaskText = (todo: Todo): string => { return todo.task || todo.description || todo.content || todo.title || todo.text || Object.entries(todo).find(([key, value]) => typeof value === 'string' && !['priority', 'status'].includes(key) )?.[1] || 'No task description'; }; const taskText = getTaskText(todo); const getPriorityColor = (priority: string) => { switch (priority) { case 'high': return 'text-red-600 bg-red-50 border-red-200'; case 'medium': return 'text-yellow-600 bg-yellow-50 border-yellow-200'; case 'low': return 'text-green-600 bg-green-50 border-green-200'; default: return 'text-gray-600 bg-gray-50 border-gray-200'; } }; const getStatusIcon = (status: string) => { switch (status) { case 'completed': return ; case 'in_progress': return ; case 'pending': return ; default: return ; } }; const getStatusColor = (status: string) => { switch (status) { case 'completed': return 'bg-green-50 border-green-200'; case 'in_progress': return 'bg-blue-50 border-blue-200'; case 'pending': return 'bg-gray-50 border-gray-200'; default: return 'bg-gray-50 border-gray-200'; } }; return (
{getStatusIcon(todo.status)}

{taskText}

{todo.priority}
); }