improvement: lab/clinic commiunication flow completely overhauled. no more shit.

This commit is contained in:
2026-07-13 22:53:23 +03:30
parent 2ad572f4c8
commit 27eae25f61
30 changed files with 1805 additions and 696 deletions

View File

@@ -0,0 +1,56 @@
import type { LabCaseActivityItem } from '@/types/lab-case-activity';
type ActivityLabelTranslator = (
key: string,
values?: Record<string, string | number>,
) => string;
export function formatLabCaseActivityLine(
activity: LabCaseActivityItem,
t: ActivityLabelTranslator,
locale: string,
): string {
const actor = activity.actorName ?? t('activityUnknownActor');
const date = new Date(activity.createdAt).toLocaleString(locale, {
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
});
switch (activity.type) {
case 'CASE_SENT':
return t('activityCaseSent', { date });
case 'CLINIC_COMMENT':
return t('activityClinicComment', {
actor,
preview: truncatePreview(activity.commentBody),
date,
});
case 'LAB_COMMENT':
return t('activityLabComment', {
actor,
preview: truncatePreview(activity.commentBody),
date,
});
case 'TASK_COMPLETED':
return t('activityTaskCompleted', {
step: activity.stepLabel ?? t('activityUnknownStep'),
actor,
date,
});
case 'CASE_IMPORTANT':
return t('activityCaseImportant', { actor, date });
case 'CASE_AMENDED':
return t('activityCaseAmended', { actor, date });
default:
return t('activityGeneric', { date });
}
}
function truncatePreview(text: string | null | undefined, max = 60): string {
const trimmed = text?.trim() ?? '';
if (!trimmed) return '…';
if (trimmed.length <= max) return trimmed;
return `${trimmed.slice(0, max - 1)}`;
}