From d0cfc0e9812514a6abce5843f3e42dd5df793e5d Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Wed, 16 Aug 2023 08:33:07 +0200 Subject: [PATCH] Show siblings on member page --- geneit_app/src/api/MemberApi.ts | 10 +++++++++ .../src/routes/family/FamilyMemberRoute.tsx | 22 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/geneit_app/src/api/MemberApi.ts b/geneit_app/src/api/MemberApi.ts index 3959cf6..b9a873f 100644 --- a/geneit_app/src/api/MemberApi.ts +++ b/geneit_app/src/api/MemberApi.ts @@ -195,6 +195,16 @@ export class MembersList { children(id: number): Member[] { return this.list.filter((m) => m.mother === id || m.father === id); } + + siblings(id: number): Member[] { + const p = this.get(id); + return this.list.filter( + (m) => + m.id !== p?.id && + ((m.mother && m.mother === p?.mother) || + (m.father && m.father === p?.father)) + ); + } } export class MemberApi { diff --git a/geneit_app/src/routes/family/FamilyMemberRoute.tsx b/geneit_app/src/routes/family/FamilyMemberRoute.tsx index a951eec..e5d792d 100644 --- a/geneit_app/src/routes/family/FamilyMemberRoute.tsx +++ b/geneit_app/src/routes/family/FamilyMemberRoute.tsx @@ -128,6 +128,7 @@ export function FamilyMemberRoute(): React.ReactElement { void; onSave?: (m: Member) => void; onRequestEdit?: () => void; @@ -628,6 +630,26 @@ export function MemberPage(p: { )} + + {/* Siblings */} + {p.siblings && ( + + + {p.siblings.length === 0 ? ( + <>Aucun frère ou sœur + ) : ( + p.siblings.map((c) => ( + + + + )) + )} + + + )} );