mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 21:32:18 +00:00
fix(links): name a related dose by its vaccine, not its catalogue slug
This commit is contained in:
1 parent
27b173eb26
commit
2f9628aa95
2 files changed
+36
No files matched your search
@@ -53,6 +53,35 @@ describe("<RelatedRecordsList>", () => {
|
||||
expect(html).not.toContain(">SPECIALIST<");
|
||||
});
|
||||
|
||||
it("names a dose labelled by its catalogue slug from the reader's bundle", () => {
|
||||
const html = render(
|
||||
<RelatedRecordsList
|
||||
related={[
|
||||
{
|
||||
kind: "vaccination",
|
||||
id: "v1",
|
||||
label: "tetanus",
|
||||
date: "2025-12-20T09:00:00.000Z",
|
||||
href: "/vaccinations?dose=v1",
|
||||
via: "direct",
|
||||
},
|
||||
{
|
||||
kind: "vaccination",
|
||||
id: "v2",
|
||||
label: "as-written-on-the-card",
|
||||
date: "2025-11-20T09:00:00.000Z",
|
||||
href: "/vaccinations?dose=v2",
|
||||
via: "direct",
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
expect(html).toContain(">Tetanus<");
|
||||
expect(html).not.toContain(">tetanus<");
|
||||
// A written name that is no catalogue slug stays as written.
|
||||
expect(html).toContain("as-written-on-the-card");
|
||||
});
|
||||
|
||||
it("says how a derived relation runs", () => {
|
||||
const html = render(<RelatedRecordsList related={RELATED} />);
|
||||
expect(html).toContain("through the efficacy target");
|
||||
|
||||
@@ -111,6 +111,13 @@ function rowLabel(t: Translate, row: RelatedLink): string {
|
||||
) {
|
||||
return encounterKindText(t, row.label as EncounterKind);
|
||||
}
|
||||
// A dose without a written name arrives as its catalogue slug ("tetanus"),
|
||||
// named here from the reader's bundle the way the dose picker names it.
|
||||
if (row.kind === "vaccination" && /^[a-z0-9_-]+$/.test(row.label)) {
|
||||
const key = `vaccinations.catalog.${row.label}`;
|
||||
const name = t(key);
|
||||
if (name !== key) return name;
|
||||
}
|
||||
return row.label;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user