/** * Tasks Widget - displays task summary and list */ import { useState, useEffect } from "react"; import { CheckCircle, Circle, Clock, AlertCircle } from "lucide-react"; import type { WidgetProps } from "@mosaic/shared"; interface Task { id: string; title: string; status: string; priority: string; dueDate?: string; } // eslint-disable-next-line no-empty-pattern export function TasksWidget({}: WidgetProps): React.JSX.Element { const [tasks, setTasks] = useState([]); const [isLoading, setIsLoading] = useState(true); // Mock data for now - will fetch from API later useEffect(() => { setIsLoading(true); // Simulate API call setTimeout(() => { setTasks([ { id: "1", title: "Complete project documentation", status: "IN_PROGRESS", priority: "HIGH", dueDate: "2024-02-01", }, { id: "2", title: "Review pull requests", status: "NOT_STARTED", priority: "MEDIUM", dueDate: "2024-02-02", }, { id: "3", title: "Update dependencies", status: "COMPLETED", priority: "LOW", dueDate: "2024-01-30", }, ]); setIsLoading(false); }, 500); }, []); const getPriorityIcon = (priority: string): React.JSX.Element => { switch (priority) { case "HIGH": return ; case "MEDIUM": return ; case "LOW": return ; default: return ; } }; const getStatusIcon = (status: string): React.JSX.Element => { return status === "COMPLETED" ? ( ) : ( ); }; const stats = { total: tasks.length, inProgress: tasks.filter((t) => t.status === "IN_PROGRESS").length, completed: tasks.filter((t) => t.status === "COMPLETED").length, }; if (isLoading) { return (
Loading tasks...
); } return (
{/* Summary stats */}
{stats.total}
Total
{stats.inProgress}
In Progress
{stats.completed}
Done
{/* Task list */}
{tasks.length === 0 ? (
No tasks yet
) : ( tasks.slice(0, 5).map((task) => (
{getStatusIcon(task.status)}
{task.title}
{task.dueDate && (
Due: {new Date(task.dueDate).toLocaleDateString()}
)}
{getPriorityIcon(task.priority)}
)) )}
); }