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

@@ -1,42 +1,57 @@
'use client';
import { useTranslations } from 'next-intl';
import { useEffect } from 'react';
import { LabCaseCommentsPanel } from '@/components/ui/lab/LabCaseCommentsPanel';
import { treatmentsApi } from '@/lib/api/treatments';
import type { TreatmentDetailDraft } from '@/types/treatment';
import { notificationsApi } from '@/lib/api/notifications';
import { notifyTabBadgesChanged } from '@/lib/tabBadgeUtils';
interface DetailLabCaseCommentsSectionProps {
detail: TreatmentDetailDraft;
labCaseId: string;
canPost: boolean;
deferSubmit?: boolean;
composerValue?: string;
onComposerValueChange?: (value: string) => void;
onError?: (message: string) => void;
onMarkRead?: (labCaseId: string) => void;
onActivityChange?: () => void;
}
export function DetailLabCaseCommentsSection({
detail,
labCaseId,
canPost,
deferSubmit = false,
composerValue,
onComposerValueChange,
onError,
onMarkRead,
onActivityChange,
}: DetailLabCaseCommentsSectionProps) {
const t = useTranslations('treatment');
const caseId = detail.labCaseId;
if (!caseId) return null;
useEffect(() => {
if (!labCaseId) return;
void notificationsApi.markCaseRead(labCaseId).then(() => {
notifyTabBadgesChanged();
onMarkRead?.(labCaseId);
});
}, [labCaseId, onMarkRead]);
return (
<div className="space-y-2 border-t border-border/60 pt-4">
<div>
<p className="text-xs font-medium text-text-secondary">{t('labCaseCommentsTitle')}</p>
<p className="text-[11px] text-text-muted mt-0.5">{t('labCaseCommentsHint')}</p>
</div>
<div className="border-t border-border/60 pt-4">
<LabCaseCommentsPanel
caseId={caseId}
caseId={labCaseId}
canPost={canPost}
canToggleVisibility={false}
deferSubmit={deferSubmit}
composerValue={composerValue}
onComposerValueChange={onComposerValueChange}
loadComments={async () => {
const response = await treatmentsApi.listLabCaseComments(caseId);
const response = await treatmentsApi.listLabCaseComments(labCaseId);
return response.data;
}}
onPost={async (body) => {
const response = await treatmentsApi.addLabCaseComment(caseId, { body });
const response = await treatmentsApi.addLabCaseComment(labCaseId, { body });
notifyTabBadgesChanged();
onActivityChange?.();
return response.data;
}}
onError={onError}