From b9249afca6056364598cd1bf08ebdebb77655fd1 Mon Sep 17 00:00:00 2001 From: cear0004 Date: Mon, 21 Oct 2024 10:47:57 +1100 Subject: [PATCH] Commented the kanban column. --- .../src/components/kanbans/kanban-column.tsx | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/kanbans/kanban-column.tsx b/frontend/src/components/kanbans/kanban-column.tsx index 6ff0ecf..4dee0f4 100644 --- a/frontend/src/components/kanbans/kanban-column.tsx +++ b/frontend/src/components/kanbans/kanban-column.tsx @@ -2,6 +2,19 @@ import { useEffect, useState } from "react"; import KanbanCard from "./kanban-task-card"; import { KanbanBoard, KanbanTask, UserInfo } from "../../utilities/types"; +/** + * KanbanColumn component represents a single column in a Kanban board. + * It displays a list of tasks for a specific category. + * + * @param {Object} props - The component props + * @param {string} props.title - The title of the column + * @param {string} props.taskCategoryId - The ID of the task category + * @param {KanbanBoard} props.kanban - The entire Kanban board data + * @param {Function} props.setActiveTaskMethod - Function to set the active task + * @param {UserInfo | null} props.currentUser - The current user information + * @param {any} props.provided - Provided props from react-beautiful-dnd + * @param {any} props.snapshot - Snapshot from react-beautiful-dnd + */ export default function KanbanColumn({ title, taskCategoryId, @@ -19,19 +32,22 @@ export default function KanbanColumn({ provided: any; snapshot: any; }) { + // State to hold the tasks for this column const [tasks, setTasks] = useState([] as KanbanTask[]); + // Effect to filter and sort tasks when kanban.tasks or taskCategoryId changes useEffect(() => { const tasks = kanban.tasks.filter( (task) => task.taskCategory === parseInt(taskCategoryId) ); - // sort tasks by due date + // Sort tasks by due date tasks.sort((a, b) => { return new Date(a.dueDate).getTime() - new Date(b.dueDate).getTime(); }); setTasks(tasks); }, [kanban.tasks, taskCategoryId]); + // Render the column return (

{title}

@@ -47,15 +63,21 @@ export default function KanbanColumn({ }} > {provided.placeholder} - {tasks.map((task, index: number) => ( - - ))} + {tasks + .filter( + (task) => + task.name !== undefined && task.name !== "" && task.name !== null + ) + .map((task, index: number) => ( + // Render each task as a KanbanCard component + + ))}
);