import { format } from 'date-fns' import { ArrowRight, Clock, User, UserCheck } from 'lucide-react' import { PRIORITY_CONFIG } from '../utils/api' import { useAuth } from '../contexts/AuthContext' import { useLanguage } from '../i18n/LanguageContext' export default function TaskCard({ task, onMove, showProject = true }) { const { t } = useLanguage() const { user: authUser } = useAuth() const priority = PRIORITY_CONFIG[task.priority] || PRIORITY_CONFIG.medium const projectName = typeof task.project === 'object' ? task.project?.name : task.projectName const nextStatus = { todo: 'in_progress', in_progress: 'done', } const nextLabel = { todo: t('tasks.start'), in_progress: t('tasks.complete'), } const dueDate = task.due_date || task.dueDate const isOverdue = dueDate && new Date(dueDate) < new Date() && task.status !== 'done' const creatorName = task.creator_user_name || task.creatorUserName // Determine if this task was assigned by someone else const createdByUserId = task.created_by_user_id || task.createdByUserId const isExternallyAssigned = authUser && createdByUserId && createdByUserId !== authUser.id const assignedName = task.assigned_name || task.assignedName return (
{/* Priority dot */}
{task.title}
{/* Assigned by label for externally-assigned tasks */} {isExternallyAssigned && creatorName && (
{t('tasks.from')} {creatorName}
)} {/* Assigned to label for tasks you delegated */} {!isExternallyAssigned && assignedName && (
{t('tasks.assignedTo')} {assignedName}
)}
{showProject && projectName && ( {projectName} )} {dueDate && ( {format(new Date(dueDate), 'MMM d')} )} {!isExternallyAssigned && creatorName && ( {creatorName} )}
{/* Quick action */} {onMove && nextStatus[task.status] && (
)}
) }