diff --git a/src/components/ListView.tsx b/src/components/ListView.tsx new file mode 100644 index 0000000..08c4619 --- /dev/null +++ b/src/components/ListView.tsx @@ -0,0 +1,69 @@ +'use client'; + +import { useApp } from './AppProvider'; +import TaskCard from './TaskCard'; + +export default function ListView() { + const { tasks, projects, filterStatus, filterPriority, filterCompleted } = useApp(); + + // Add project info to each task + const tasksWithProject = tasks.map(task => { + const project = projects.find(p => p.id === task.projectId); + return { ...task, projectColor: project?.color, projectName: project?.name }; + }); + + // Apply client-side filters for status, priority, completed + const filteredTasks = tasksWithProject.filter(task => { + if (filterStatus && task.status !== filterStatus) return false; + if (filterPriority && task.priority !== filterPriority) return false; + if (filterCompleted === 'true' && !task.completed) return false; + if (filterCompleted === 'false' && task.completed) return false; + return true; + }); + + // Group by status + const todoTasks = filteredTasks.filter(t => t.status === 'todo'); + const inProgressTasks = filteredTasks.filter(t => t.status === 'in_progress'); + const doneTasks = filteredTasks.filter(t => t.status === 'done'); + + const renderSection = (title: string, tasks: typeof filteredTasks, icon: string) => { + if (tasks.length === 0 && filterStatus) return null; + return ( +
+

+ {icon} + {title} + ({tasks.length}) +

+
+ {tasks.map(task => ( + + ))} +
+
+ ); + }; + + return ( +
+ {filteredTasks.length === 0 ? ( +
+ 📝 +

No tasks yet

+

Create your first task to get started!

+
+ ) : ( + <> + {renderSection('To Do', todoTasks, '📋')} + {renderSection('In Progress', inProgressTasks, '🔄')} + {renderSection('Done', doneTasks, '✅')} + + )} +
+ ); +}