Files
familienarchiv/frontend/src/lib/relationshipLabels.ts
Marcel b658a13247 feat(stammbaum): show inferred relationship in the document drawer
- New presentational RelationshipBadge component (labelFromA → arrow →
  labelFromB) wired into DocumentMetadataDrawer's Personen column,
  rendered after the receivers block when both endpoints are family
  members.
- DocumentTopBar gains an optional inferredRelationship prop and
  passes it through.
- documents/[id]/+page.server.ts loads the badge: only when sender is
  a family member, exactly one receiver, and that receiver is also a
  family member; 404 (no path) → null.
- relationshipLabels.ts maps the backend label keys (parent/child/...)
  to localised strings, so the server load returns badge-ready strings.

Refs #358.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 19:32:17 +02:00

45 lines
1.4 KiB
TypeScript

import * as m from '$lib/paraglide/messages.js';
/**
* Maps a backend inferred-label key (parent, uncle_aunt, ...) to its
* localised string. Unknown keys fall back to "distant".
*/
export function inferredRelationshipLabel(key: string): string {
switch (key) {
case 'parent':
return m.relation_inferred_parent();
case 'child':
return m.relation_inferred_child();
case 'spouse':
return m.relation_inferred_spouse();
case 'sibling':
return m.relation_inferred_sibling();
case 'grandparent':
return m.relation_inferred_grandparent();
case 'grandchild':
return m.relation_inferred_grandchild();
case 'great_grandparent':
return m.relation_inferred_great_grandparent();
case 'great_grandchild':
return m.relation_inferred_great_grandchild();
case 'uncle_aunt':
return m.relation_inferred_uncle_aunt();
case 'niece_nephew':
return m.relation_inferred_niece_nephew();
case 'great_uncle_aunt':
return m.relation_inferred_great_uncle_aunt();
case 'great_niece_nephew':
return m.relation_inferred_great_niece_nephew();
case 'inlaw_parent':
return m.relation_inferred_inlaw_parent();
case 'inlaw_child':
return m.relation_inferred_inlaw_child();
case 'sibling_inlaw':
return m.relation_inferred_sibling_inlaw();
case 'cousin_1':
return m.relation_inferred_cousin_1();
default:
return m.relation_inferred_distant();
}
}