/** * @file dashboard/KanbanCard.tsx * @description Client component rendering a single kanban card container with individual loading states and modular sub-components. */ "use client"; import { Loader2 } from "lucide-react"; import { KanbanCardProps, TaskStatus } from "@/types/tasks"; import KanbanCardActions from "./components/KanbanCardActions"; import KanbanCardAvatars from "./components/KanbanCardAvatars"; import KanbanCardDueDate from "./components/KanbanCardDueDate"; import KanbanCardPriority from "./components/KanbanCardPriority"; /** * Renders an interactive kanban card container handling drag-and-drop actions, loading states, * and assembling modular sub-components for priorities, due dates, avatars, and actions. * * @param {KanbanCardProps} props - The component props containing the task object, updating status flag, and status change handler. * @returns {JSX.Element} The rendered kanban card component. */ export default function KanbanCard({ task, isUpdating = false, onStatusChange, onDelete, }: KanbanCardProps) { /** * Initiates the drag action on a task card if not currently updating, storing its ID and status payload. * * @param {React.DragEvent} e - The drag event object. */ const handleDragStart = (e: React.DragEvent) => { if (isUpdating) { e.preventDefault(); return; } e.dataTransfer.setData("text/plain", task.id); e.dataTransfer.setData("sourceStatus", task.status); e.dataTransfer.effectAllowed = "move"; }; /** * Triggers the status change callback with the target task ID and new status if updates are permitted. * * @param {TaskStatus} newStatus - The target task status to transition to. */ const handleMove = (newStatus: TaskStatus) => { if (!onStatusChange || isUpdating) return; onStatusChange(task.id, newStatus); }; return (
{/* Loading Spinner */} {isUpdating && (
)} {/* --- Card Header --- */}

{task.title}

{/* Card Description */}

{task.description}

{/* --- Card Footer --- */}
onDelete?.(task.id)} />
); }