/** * FederatedTaskCard Component * Displays a task from a federated instance with provenance indicator */ import { TaskStatus, TaskPriority } from "@mosaic/shared"; import type { FederatedTask } from "./types"; import { ProvenanceIndicator } from "./ProvenanceIndicator"; interface FederatedTaskCardProps { federatedTask: FederatedTask; compact?: boolean; onClick?: () => void; } /** * Get PDA-friendly status text and color */ function getStatusDisplay(status: TaskStatus): { text: string; colorClass: string } { switch (status) { case TaskStatus.NOT_STARTED: return { text: "Not Started", colorClass: "bg-gray-100 text-gray-700" }; case TaskStatus.IN_PROGRESS: return { text: "In Progress", colorClass: "bg-blue-100 text-blue-700" }; case TaskStatus.COMPLETED: return { text: "Completed", colorClass: "bg-green-100 text-green-700" }; case TaskStatus.PAUSED: return { text: "Paused", colorClass: "bg-yellow-100 text-yellow-700" }; case TaskStatus.ARCHIVED: return { text: "Archived", colorClass: "bg-gray-100 text-gray-600" }; default: return { text: "Unknown", colorClass: "bg-gray-100 text-gray-700" }; } } /** * Get priority text and color */ function getPriorityDisplay(priority: TaskPriority): { text: string; colorClass: string } { switch (priority) { case TaskPriority.LOW: return { text: "Low", colorClass: "text-gray-600" }; case TaskPriority.MEDIUM: return { text: "Medium", colorClass: "text-blue-600" }; case TaskPriority.HIGH: return { text: "High", colorClass: "text-orange-600" }; default: return { text: "Unknown", colorClass: "text-gray-600" }; } } /** * Format date for display */ function formatDate(date: Date | null): string | null { if (!date) { return null; } return new Intl.DateTimeFormat("en-US", { year: "numeric", month: "short", day: "numeric", }).format(new Date(date)); } export function FederatedTaskCard({ federatedTask, compact = false, onClick, }: FederatedTaskCardProps): React.JSX.Element { const { task, provenance } = federatedTask; const status = getStatusDisplay(task.status); const priority = getPriorityDisplay(task.priority); const dueDate = formatDate(task.dueDate); const paddingClass = compact ? "p-3" : "p-4"; const clickableClass = onClick ? "cursor-pointer hover:border-gray-300" : ""; return (
{/* Header with title and provenance */}

{task.title}

{task.description &&

{task.description}

}
{/* Metadata row */}
{/* Status badge */} {status.text} {/* Priority */} {priority.text} {/* Target date */} {dueDate && Target: {dueDate}}
); }