'use client'; import { MessageSquare } from 'lucide-react'; import { useTranslations } from 'next-intl'; import { Badge } from '@/components/ui/shared/Badge'; import { FORM_SELECT_CLASS } from '@/components/shared/formSelectStyles'; import { LabCaseCommentsPanel } from '@/components/ui/lab/LabCaseCommentsPanel'; import { labTaskStatusSelectStyle, labTaskStatusVariant, } from '@/components/lab/labTaskStatusDisplay'; import { formatToothList, prosthesisTypeBadgeStyleFromCatalog, } from '@/components/treatment/prosthesisTypeDisplay'; import { tasksApi } from '@/lib/api/tasks'; import type { LabTaskListItem, LabTaskStatus } from '@/types/cases'; import type { ProsthesisCatalogEntry } from '@/types/treatment-catalog'; interface TaskRowProps { task: LabTaskListItem; locale: string; flatMode: boolean; canEdit: boolean; statusOptions: { value: LabTaskStatus; label: string }[]; updatingTaskId: string | null; commentsOpen: boolean; prosthesisCatalog: readonly ProsthesisCatalogEntry[]; onStatusUpdate: (taskId: string, status: LabTaskStatus) => void; onToggleComments: (taskId: string) => void; onCommentError: (message: string) => void; } function formatPatientName(patient: { firstName: string; lastName: string }) { return `${patient.firstName} ${patient.lastName}`.trim(); } export function TaskRow({ task, locale, flatMode, canEdit, statusOptions, updatingTaskId, commentsOpen, prosthesisCatalog, onStatusUpdate, onToggleComments, onCommentError, }: TaskRowProps) { const t = useTranslations('tasks'); const taskDate = new Intl.DateTimeFormat(locale, { year: 'numeric', month: 'short', day: 'numeric', }).format(new Date(task.createdAt)); return (
{task.stepOrder}. {task.stepLabel}
{flatMode && task.isImportant ? ({t('fromClinic', { name: task.clinic.name })} · {formatPatientName(task.patient)}{' '} · {t('teethLabel', { teeth: formatToothList(task.teeth) })}
) : null}{t('taskDate', { date: taskDate })} {task.lastStatusChangedBy ? ( <> · {t('lastUpdatedBy', { name: task.lastStatusChangedBy.name })} > ) : null}