Shared marriage events; deterministic parent ordering
- Partnership life events (marriage/divorce/engagement) now attach to the
couple's relationship, not each person. The add-event form asks for the
spouse, finds-or-creates the partnership, and writes ONE event on it — shown
on both partners' pages ("· with <spouse>"), entered once. Event values
(RELI/OCCU detail) now render too.
- Family-view pedigree orders parents deterministically (father on top, mother
below, stable fallback when gender is unknown) instead of by which link was
created first.
Frontend only — no migration.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -86,8 +86,18 @@ export default function FamilyViewPage() {
|
||||
}, [search, treeId]);
|
||||
|
||||
const byId = useMemo(() => new Map(people.map((p) => [p.id, p])), [people]);
|
||||
// Order parents deterministically: father (male) on top, mother below, with a
|
||||
// stable fallback when gender is unknown (so it doesn't depend on which link
|
||||
// happened to be created first).
|
||||
const parentRank = (id: string) => {
|
||||
const g = byId.get(id)?.gender;
|
||||
return g === "male" ? 0 : g === "female" ? 1 : 2;
|
||||
};
|
||||
const parentsOf = (id: string) =>
|
||||
rels.filter((r) => r.type === "parent_child" && r.person_to_id === id).map((r) => r.person_from_id);
|
||||
rels
|
||||
.filter((r) => r.type === "parent_child" && r.person_to_id === id)
|
||||
.map((r) => r.person_from_id)
|
||||
.sort((a, b) => parentRank(a) - parentRank(b));
|
||||
const childrenOf = (id: string) =>
|
||||
rels.filter((r) => r.type === "parent_child" && r.person_from_id === id).map((r) => r.person_to_id);
|
||||
const partnersOf = (id: string) =>
|
||||
|
||||
Reference in New Issue
Block a user