/** * @file dashboard/components/KanbanCardActions.tsx * @description Client component rendering the mobile status transition dropdown for a kanban card. */ "use client"; import { useState, useEffect, useRef } from "react"; import { MoreHorizontal, CornerDownRight } from "lucide-react"; import { KANBAN_COLUMNS, TaskStatus } from "@/types/tasks"; /** * Renders a mobile-only action menu component allowing users to move a task * between different kanban columns via a dropdown interface. * * @param {Object} props - The component props. * @param {TaskStatus} props.currentStatus - The current status category of the task. * @param {(newStatus: TaskStatus) => void} props.onMove - Callback function triggered when a new status column is selected. * @returns {JSX.Element} The rendered mobile card actions component. */ export default function KanbanCardActions({ currentStatus, onMove, }: { currentStatus: TaskStatus; onMove: (newStatus: TaskStatus) => void; }) { const [showMobileActions, setShowMobileActions] = useState(false); const dropdownRef = useRef(null); useEffect(() => { const handleClickOutside = (event: MouseEvent) => { if ( dropdownRef.current && !dropdownRef.current.contains(event.target as Node) ) { setShowMobileActions(false); } }; if (showMobileActions) { document.addEventListener("mousedown", handleClickOutside); } return () => { document.removeEventListener("mousedown", handleClickOutside); }; }, [showMobileActions]); /** * Handles clicking an action item to move the task to a target status category. * * @param {React.MouseEvent} e - The mouse event object. * @param {TaskStatus} targetStatus - The target status category to move the task to. */ const handleActionClick = (e: React.MouseEvent, targetStatus: TaskStatus) => { e.stopPropagation(); onMove(targetStatus); setShowMobileActions(false); }; return (
{KANBAN_COLUMNS.map((col) => { if (col.id === currentStatus) return null; return ( ); })}
); }