From fcfae8fb78c276620bcdd257c29e7f3145616c62 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 28 Apr 2026 11:34:24 +0200 Subject: [PATCH] refactor(stammbaum): use shared chipLabel/otherName from relationshipLabels in both components Addresses @felix blocker: removes the verbatim duplicate switch+2-line helper from StammbaumCard.svelte and StammbaumSidePanel.svelte; both now import from the shared $lib/relationshipLabels helper. Co-Authored-By: Claude Sonnet 4.6 --- .../src/lib/components/StammbaumCard.svelte | 34 ++----------------- .../lib/components/StammbaumSidePanel.svelte | 34 ++----------------- 2 files changed, 6 insertions(+), 62 deletions(-) diff --git a/frontend/src/lib/components/StammbaumCard.svelte b/frontend/src/lib/components/StammbaumCard.svelte index af54215f..620a456c 100644 --- a/frontend/src/lib/components/StammbaumCard.svelte +++ b/frontend/src/lib/components/StammbaumCard.svelte @@ -3,7 +3,7 @@ import { enhance } from '$app/forms'; import { m } from '$lib/paraglide/messages.js'; import RelationshipChip from '$lib/components/RelationshipChip.svelte'; import AddRelationshipForm from '$lib/components/AddRelationshipForm.svelte'; -import { inferredRelationshipLabel } from '$lib/relationshipLabels'; +import { chipLabel, otherName, inferredRelationshipLabel } from '$lib/relationshipLabels'; import type { components } from '$lib/generated/api'; type RelationshipDTO = components['schemas']['RelationshipDTO']; @@ -53,34 +53,6 @@ function relationTypeOrder(t: RelationType | undefined): number { return order[t ?? 'OTHER'] ?? 99; } -function chipLabel(rel: RelationshipDTO): string { - const viewpointIsSubject = rel.personId === personId; - switch (rel.relationType) { - case 'PARENT_OF': - return viewpointIsSubject ? m.relation_parent_of() : m.relation_child_of(); - case 'SPOUSE_OF': - return m.relation_spouse_of(); - case 'SIBLING_OF': - return m.relation_sibling_of(); - case 'FRIEND': - return m.relation_friend(); - case 'COLLEAGUE': - return m.relation_colleague(); - case 'EMPLOYER': - return m.relation_employer(); - case 'DOCTOR': - return m.relation_doctor(); - case 'NEIGHBOR': - return m.relation_neighbor(); - default: - return m.relation_other(); - } -} - -function otherName(rel: RelationshipDTO): string { - return rel.personId === personId ? rel.relatedPersonDisplayName : rel.personDisplayName; -} - function yearRange(rel: RelationshipDTO): string { const from = rel.fromYear; const to = rel.toYear; @@ -155,8 +127,8 @@ function yearRange(rel: RelationshipDTO): string {