improvement: notify counter badge added to treatment and tasks tabs for upadted and edited cases.
This commit is contained in:
@@ -35,6 +35,9 @@ import type { LabDispatchAttentionItem } from '@/components/treatment/labDispatc
|
||||
import { collectLabDispatchAttention } from '@/components/treatment/labDispatchAttention';
|
||||
import { canEditTreatment, canViewTreatment, canAccessDashboardRoute } from '@/components/shared/permissions';
|
||||
import { scrollWithinMainScrollContainer } from '@/components/shared/scrollWithinMain';
|
||||
import { useMarkTabReadOnVisit } from '@/lib/hooks/useTabBadgeCounts';
|
||||
import { notificationsApi } from '@/lib/api/notifications';
|
||||
import { notifyTabBadgesChanged } from '@/lib/tabBadgeUtils';
|
||||
import { getUserFacingError } from '@/components/shared/formatApiError';
|
||||
import { useToast } from '@/lib/hooks/useToast';
|
||||
import type { Organization } from '@/types/organization';
|
||||
@@ -275,6 +278,7 @@ export function TreatmentWorkspace({
|
||||
const { showError, showSuccess, messages: toastMessages } = useToast();
|
||||
const canView = canViewTreatment(currentOrganization);
|
||||
const canEdit = canEditTreatment(currentOrganization);
|
||||
useMarkTabReadOnVisit();
|
||||
|
||||
const [stripHidden, setStripHidden] = useState(false);
|
||||
const todayStart = useMemo(() => startOfLocalDay(new Date()), []);
|
||||
@@ -346,6 +350,18 @@ export function TreatmentWorkspace({
|
||||
[labCaseDrafts],
|
||||
);
|
||||
|
||||
const activeSentLabCaseId = useMemo(() => {
|
||||
const match = labCaseDrafts.find(
|
||||
(lc) => lc.detailClientId === activeDetailId && lc.sentAt && lc.id,
|
||||
);
|
||||
return match?.id ?? null;
|
||||
}, [labCaseDrafts, activeDetailId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!activeSentLabCaseId) return;
|
||||
void notificationsApi.markCaseRead(activeSentLabCaseId).then(() => notifyTabBadgesChanged());
|
||||
}, [activeSentLabCaseId]);
|
||||
|
||||
const isDirty = useMemo(
|
||||
() => isDetailsDirty(details, savedSnapshot),
|
||||
[details, savedSnapshot],
|
||||
@@ -1205,6 +1221,7 @@ export function TreatmentWorkspace({
|
||||
return [orgId, ...prev.filter((id) => id !== orgId)].slice(0, 10);
|
||||
});
|
||||
showSuccess(t('successCaseSent'));
|
||||
notifyTabBadgesChanged();
|
||||
} catch (error: unknown) {
|
||||
showError(getUserFacingError(error, tErrors, t('errorSendCase')));
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user