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

@@ -22,7 +22,10 @@ const treatmentInclude = {
orderBy: [{ sortOrder: 'asc' as const }],
include: {
attachments: { orderBy: [{ createdAt: 'asc' as const }] },
sends: { orderBy: [{ sentAt: 'asc' as const }] },
sends: {
orderBy: [{ sentAt: 'asc' as const }],
include: { organization: { select: { id: true, name: true } } },
},
},
},
};
@@ -332,7 +335,10 @@ export class TreatmentsService {
where: { id: caseId },
include: {
attachments: { orderBy: [{ createdAt: 'asc' }] },
sends: { orderBy: [{ sentAt: 'asc' }] },
sends: {
orderBy: [{ sentAt: 'asc' }],
include: { organization: { select: { id: true, name: true } } },
},
},
});
@@ -459,7 +465,7 @@ export class TreatmentsService {
mimeType: string;
sizeBytes: number;
}>;
sends: Array<{ organizationId: string; sentAt: Date }>;
sends: Array<{ organizationId: string; sentAt: Date; organization: { id: string; name: string } }>;
}>;
}) {
const documents = treatment.cases.flatMap((c) =>
@@ -491,7 +497,7 @@ export class TreatmentsService {
mimeType: string;
sizeBytes: number;
}>;
sends?: Array<{ organizationId: string; sentAt: Date }>;
sends?: Array<{ organizationId: string; sentAt: Date; organization?: { id: string; name: string } }>;
}) {
return {
id: c.id,
@@ -501,6 +507,12 @@ export class TreatmentsService {
notes: c.comment ?? null,
sentAt: c.sentAt?.toISOString() ?? null,
sendToOrganizationIds: c.sends?.map((s) => s.organizationId) ?? [],
sends:
c.sends?.map((s) => ({
organizationId: s.organizationId,
organizationName: s.organization?.name ?? 'Unknown organization',
sentAt: s.sentAt.toISOString(),
})) ?? [],
attachmentMetas: (c.attachments ?? []).map((a) => this.mapAttachment(a)),
};
}