/** * @file dashboard/components/KanbanBoardHeader.tsx * @description Component rendering the top title header with an integrated delete drop zone that appears during drag-and-drop interactions, plus a link to the trash bin view. */ "use client"; import { useState, useEffect } from "react"; import { Plus, Sparkles, Trash2 } from "lucide-react"; import Link from "next/link"; /** * Renders the dashboard header featuring a workspace title, subtitle, new task action button, * a dynamic delete drop zone during drag operations, and a trash navigation link with a counter badge. * * @param {Object} props - The component props. * @param {(taskId: string) => void} props.onTaskDelete - Callback function invoked when a task is dropped into the delete zone. * @param {number} props.trashCount - The current count of items in the trash bin. * @returns {JSX.Element} The rendered kanban board header component. */ export default function KanbanBoardHeader({ onTaskDelete, trashCount, }: { onTaskDelete: (taskId: string) => void; trashCount: number; }) { const [isDragging, setIsDragging] = useState(false); const [isOver, setIsOver] = useState(false); useEffect(() => { const handleDragStart = () => setIsDragging(true); const handleDragEnd = () => { setIsDragging(false); setIsOver(false); }; window.addEventListener("dragstart", handleDragStart); window.addEventListener("dragend", handleDragEnd); return () => { window.removeEventListener("dragstart", handleDragStart); window.removeEventListener("dragend", handleDragEnd); }; }, []); return (
Workspace

Dashboard

Manage your tasks and keep track of your progress.

{isDragging ? (
{ e.preventDefault(); e.dataTransfer.dropEffect = "move"; setIsOver(true); }} onDragLeave={() => setIsOver(false)} onDrop={(e) => { e.preventDefault(); setIsOver(false); setIsDragging(false); const taskId = e.dataTransfer.getData("text/plain"); if (taskId) { onTaskDelete(taskId); } }} className={`flex items-center gap-2 px-4 py-2.5 rounded-xl font-medium text-sm border-2 border-dashed cursor-pointer select-none transition-all duration-300 ease-out transform ${ isOver ? "bg-destructive border-destructive scale-110 shadow-lg animate-pulse" : "bg-destructive/10 border-destructive/40 text-destructive scale-100 opacity-90 hover:opacity-100 animate-in fade-in zoom-in-95 duration-200" }`} > Drop to Delete
) : ( )} {/* Icon */} {/* Badge */} {trashCount > 0 && ( {trashCount} )}
); }