feature: treatment frontend wired with the newly implemented backend. no mocked data no more.

This commit is contained in:
2026-05-19 23:43:43 +03:30
parent f743046b38
commit 633c939560
13 changed files with 1199 additions and 528 deletions

View File

@@ -0,0 +1,40 @@
import type { LinkedOrganizationOption, TreatmentCaseSendInfo } from '@/types/treatment';
export function formatCaseSentLines(
sends: TreatmentCaseSendInfo[] | undefined,
fallback?: {
organizationIds: string[];
sentAt: string | null;
orgs?: LinkedOrganizationOption[];
},
): string[] {
if (sends?.length) {
return sends.map((s) => {
const at = new Date(s.sentAt).toLocaleString();
return `Sent to ${s.organizationName} at ${at}`;
});
}
if (fallback?.sentAt && fallback.organizationIds.length > 0) {
const at = new Date(fallback.sentAt).toLocaleString();
const nameById = new Map(fallback.orgs?.map((o) => [o.id, o.name]) ?? []);
return fallback.organizationIds.map((id) => {
const name = nameById.get(id) ?? 'organization';
return `Sent to ${name} at ${at}`;
});
}
return [];
}
export function formatCaseSentSummary(
sends: TreatmentCaseSendInfo[] | undefined,
fallback?: {
organizationIds: string[];
sentAt: string | null;
orgs?: LinkedOrganizationOption[];
},
): string | null {
const lines = formatCaseSentLines(sends, fallback);
return lines.length > 0 ? lines.join(' · ') : null;
}