'use client';
import { useSortable } from '@dnd-kit/sortable';
import { CSS } from '@dnd-kit/utilities';
import { Card, CardContent } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { Issue } from '@/lib/api/issues';
import { FolderKanban, FileText, CheckSquare } from 'lucide-react';
interface IssueCardProps {
issue: Issue;
}
export function IssueCard({ issue }: IssueCardProps) {
const { attributes, listeners, setNodeRef, transform, transition } =
useSortable({ id: issue.id });
const style = {
transform: CSS.Transform.toString(transform),
transition,
};
const priorityColors = {
Low: 'bg-gray-100 text-gray-700',
Medium: 'bg-blue-100 text-blue-700',
High: 'bg-orange-100 text-orange-700',
Critical: 'bg-red-100 text-red-700',
};
// Type icon components (replacing emojis with lucide icons)
const getTypeIcon = () => {
switch (issue.type) {
case 'Epic':
return ;
case 'Story':
return ;
case 'Task':
return ;
case 'Bug':
return 🐛;
default:
return null;
}
};
// Parent breadcrumb (for Story and Task)
const renderParentBreadcrumb = () => {
const item = issue as any;
// Story shows parent Epic
if (issue.type === 'Story' && item.epicId) {
return (
Epic
);
}
// Task shows parent Story
if (issue.type === 'Task' && item.storyId) {
return (
Story
);
}
return null;
};
// Child count badge (for Epic and Story)
const renderChildCount = () => {
const item = issue as any;
// Epic shows number of stories
if (issue.type === 'Epic' && item.childCount > 0) {
return (
{item.childCount} stories
);
}
// Story shows number of tasks
if (issue.type === 'Story' && item.childCount > 0) {
return (
{item.childCount} tasks
);
}
return null;
};
return (
{/* Header: Type icon + Child count */}
{getTypeIcon()}
{issue.type}
{renderChildCount()}
{/* Parent breadcrumb */}
{renderParentBreadcrumb()}
{/* Title */}
{issue.title}
{/* Description (if available) */}
{(issue as any).description && (
{(issue as any).description}
)}
{/* Footer: Priority + Hours */}
{issue.priority}
{(issue as any).estimatedHours && (
{(issue as any).estimatedHours}h
)}
);
}