41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
'use client';
|
|
|
|
import { useTranslations } from 'next-intl';
|
|
import { formatCaseSentLines } from '@/components/treatment/caseSendLabel';
|
|
import type { LabCaseSendInfo, LinkedOrganizationOption } from '@/types/treatment';
|
|
|
|
interface CaseSentLabelProps {
|
|
treatmentCase: {
|
|
sends?: LabCaseSendInfo[];
|
|
sendToOrganizationIds?: string[];
|
|
destinationOrganizationId?: string | null;
|
|
sentAt?: string | null;
|
|
};
|
|
orgs?: LinkedOrganizationOption[];
|
|
className?: string;
|
|
}
|
|
|
|
export function CaseSentLabel({ treatmentCase, orgs, className = 'text-xs text-text-muted' }: CaseSentLabelProps) {
|
|
const t = useTranslations('treatment');
|
|
const organizationIds =
|
|
treatmentCase.sendToOrganizationIds ??
|
|
(treatmentCase.destinationOrganizationId ? [treatmentCase.destinationOrganizationId] : []);
|
|
const lines = formatCaseSentLines(treatmentCase.sends, {
|
|
organizationIds,
|
|
sentAt: treatmentCase.sentAt ?? null,
|
|
orgs,
|
|
}, t);
|
|
|
|
if (lines.length === 0) return null;
|
|
|
|
return (
|
|
<div className={className}>
|
|
{lines.map((line, i) => (
|
|
<span key={`${line}-${i}`} className="block">
|
|
{line}
|
|
</span>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|