import React from 'react'; import { Clock, CheckCircle, Circle, AlertCircle, Pause, X, ArrowRight, ChevronUp, Minus, Flag } from 'lucide-react'; import { cn } from '../lib/utils'; import Tooltip from './Tooltip'; const TaskCard = ({ task, onClick, showParent = false, className = '' }) => { const getStatusConfig = (status) => { switch (status) { case 'done': return { icon: CheckCircle, bgColor: 'bg-green-50 dark:bg-green-950', borderColor: 'border-green-200 dark:border-green-800', iconColor: 'text-green-600 dark:text-green-400', textColor: 'text-green-900 dark:text-green-100', statusText: 'Done' }; case 'in-progress': return { icon: Clock, bgColor: 'bg-blue-50 dark:bg-blue-950', borderColor: 'border-blue-200 dark:border-blue-800', iconColor: 'text-blue-600 dark:text-blue-400', textColor: 'text-blue-900 dark:text-blue-100', statusText: 'In Progress' }; case 'review': return { icon: AlertCircle, bgColor: 'bg-amber-50 dark:bg-amber-950', borderColor: 'border-amber-200 dark:border-amber-800', iconColor: 'text-amber-600 dark:text-amber-400', textColor: 'text-amber-900 dark:text-amber-100', statusText: 'Review' }; case 'deferred': return { icon: Pause, bgColor: 'bg-gray-50 dark:bg-gray-800', borderColor: 'border-gray-200 dark:border-gray-700', iconColor: 'text-gray-500 dark:text-gray-400', textColor: 'text-gray-700 dark:text-gray-300', statusText: 'Deferred' }; case 'cancelled': return { icon: X, bgColor: 'bg-red-50 dark:bg-red-950', borderColor: 'border-red-200 dark:border-red-800', iconColor: 'text-red-600 dark:text-red-400', textColor: 'text-red-900 dark:text-red-100', statusText: 'Cancelled' }; case 'pending': default: return { icon: Circle, bgColor: 'bg-slate-50 dark:bg-slate-800', borderColor: 'border-slate-200 dark:border-slate-700', iconColor: 'text-slate-500 dark:text-slate-400', textColor: 'text-slate-900 dark:text-slate-100', statusText: 'Pending' }; } }; const config = getStatusConfig(task.status); const Icon = config.icon; const getPriorityIcon = (priority) => { switch (priority) { case 'high': return (
); case 'medium': return (
); case 'low': return (
); default: return (
); } }; return (
{/* Header with Task ID, Title, and Priority */}
{/* Task ID and Title */}
{task.id}

{task.title}

{showParent && task.parentId && ( Task {task.parentId} )}
{/* Priority Icon */}
{getPriorityIcon(task.priority)}
{/* Footer with Dependencies and Status */}
{/* Dependencies */}
{task.dependencies && Array.isArray(task.dependencies) && task.dependencies.length > 0 && ( `Task ${dep}`).join(', ')}`}>
Depends on: {task.dependencies.join(', ')}
)}
{/* Status Badge */}
{config.statusText}
{/* Subtask Progress (if applicable) */} {task.subtasks && task.subtasks.length > 0 && (
Progress: st.status === 'done').length} of ${task.subtasks.length} subtasks completed`}>
st.status === 'done').length / task.subtasks.length) * 100)}%` }} />
st.status === 'done').length} completed, ${task.subtasks.filter(st => st.status === 'pending').length} pending, ${task.subtasks.filter(st => st.status === 'in-progress').length} in progress`}> {task.subtasks.filter(st => st.status === 'done').length}/{task.subtasks.length}
)}
); }; export default TaskCard;