import { useSortable } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; import { Card as CardType } from '../../types/kanban'; import MessageSquareIcon from '../icons/MessageSquareIcon'; import CheckSquareIcon from '../icons/CheckSquareIcon'; import ChevronLeftIcon from '../icons/ChevronLeftIcon'; import { Link } from 'react-router-dom'; interface KanbanCardProps { card: CardType; onOpenModal: () => void; } export function KanbanCard({ card, onOpenModal }: KanbanCardProps) { const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: `CARD_${card.id}`, }); const style = { transform: CSS.Transform.toString(transform), transition, opacity: isDragging ? 0.5 : 1, }; // Calculate checklist progress const checklists = (card as any).checklists || []; const totalItems = checklists.reduce( (sum: number, checklist: any) => sum + checklist.items.length, 0 ); const completedItems = checklists.reduce( (sum: number, checklist: any) => sum + checklist.items.filter((item: any) => item.state === 'complete').length, 0 ); const hasChecklists = totalItems > 0; // Calculate comment count const comments = (card as any).comments || []; const commentCount = comments.length; const hasComments = commentCount > 0; // Get labels const labels = (card as any).labels || []; const hasLabels = labels.length > 0; // Get epic const epic = (card as any).epic; const hasEpic = epic !== null && epic !== undefined; // Get parent card name const parentCardName = card.parent_card_name; const hasParent = !!parentCardName; return (
{card.description}
)} {/* Badges */}