2026-06-28 21:45:33 +03:30
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { useTranslations } from 'next-intl';
|
2026-07-13 01:03:26 +03:30
|
|
|
import { isDetailTypeSelected } from '@/components/treatment/treatmentDetailRules';
|
2026-06-28 21:45:33 +03:30
|
|
|
import { CaseSentLabel } from '@/components/ui/treatment/CaseSentLabel';
|
2026-07-12 21:08:29 +03:30
|
|
|
import { labNotSentBadgeClass, labSentBadgeClass } from '@/components/treatment/treatmentStatusStyles';
|
2026-06-28 21:45:33 +03:30
|
|
|
import type { LinkedOrganizationOption, PastTreatmentDetail } from '@/types/treatment';
|
|
|
|
|
|
|
|
|
|
interface DetailLabSendBadgeProps {
|
|
|
|
|
detail: Pick<
|
|
|
|
|
PastTreatmentDetail,
|
|
|
|
|
'treatmentType' | 'sentAt' | 'sends' | 'destinationOrganizationId'
|
|
|
|
|
>;
|
|
|
|
|
labDependentCodes: Set<string>;
|
|
|
|
|
orgs?: LinkedOrganizationOption[];
|
|
|
|
|
className?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function DetailLabSendBadge({
|
|
|
|
|
detail,
|
|
|
|
|
labDependentCodes,
|
|
|
|
|
orgs,
|
|
|
|
|
className = '',
|
|
|
|
|
}: DetailLabSendBadgeProps) {
|
|
|
|
|
const t = useTranslations('treatment');
|
|
|
|
|
|
2026-07-13 01:03:26 +03:30
|
|
|
if (!isDetailTypeSelected(detail) || !labDependentCodes.has(detail.treatmentType)) {
|
2026-06-28 21:45:33 +03:30
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (detail.sentAt) {
|
|
|
|
|
return (
|
|
|
|
|
<CaseSentLabel
|
|
|
|
|
treatmentCase={detail}
|
|
|
|
|
orgs={orgs}
|
|
|
|
|
className={`${labSentBadgeClass} ${className}`.trim()}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<span className={`${labNotSentBadgeClass} ${className}`.trim()}>{t('detailNotSentToLab')}</span>
|
|
|
|
|
);
|
|
|
|
|
}
|