import React from "react"; import { format } from "date-fns"; import { ClipboardDocumentListIcon, ClockIcon, ArrowPathIcon, CalendarDaysIcon, } from "@heroicons/react/24/outline"; import { Task } from "../../entities/Task"; import { Project } from "../../entities/Project"; import useFetchTasks from "../../hooks/useFetchTasks"; import useFetchProjects from "../../hooks/useFetchProjects"; import useManageTasks from "../../hooks/useManageTasks"; import NewTask from "./NewTask"; import TaskList from "./TaskList"; const TasksToday: React.FC = () => { const { tasks, metrics, isLoading: loadingTasks, isError: errorTasks, mutate: mutateTasks, } = useFetchTasks({ type: "today", }); const { projects, isLoading: loadingProjects, isError: errorProjects, } = useFetchProjects(); const { updateTask, deleteTask } = useManageTasks(); const handleTaskUpdate = (updatedTask: Task): void => { if (updatedTask.id === undefined) { console.error("Error updating task: Task ID is undefined."); return; } updateTask(updatedTask.id, updatedTask) .then(() => { mutateTasks(); }) .catch((error) => { console.error("Error updating task:", error); }); }; const handleTaskDelete = (taskId: number): void => { deleteTask(taskId) .then(() => { mutateTasks(); }) .catch((error) => { console.error("Error deleting task:", error); }); }; if (loadingTasks || loadingProjects) { return
Loading...
; } if (errorTasks) { returnError loading tasks.
; } if (errorProjects) { returnError loading projects.
; } return (Backlog
{metrics.total_open_tasks}
Stale
{metrics.tasks_pending_over_month}
In Progress
{metrics.tasks_in_progress_count}
Due Today
{metrics.tasks_due_today.length}
No tasks available for today.
)}