From 51dbd04f7d79a056f77d7a00b38f29569082368f Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Tue, 22 Aug 2023 11:55:57 +0200 Subject: [PATCH] Show couple state in basic family tree --- geneit_app/src/api/CoupleApi.ts | 8 ++++++++ geneit_app/src/widgets/BasicFamilyTree.tsx | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/geneit_app/src/api/CoupleApi.ts b/geneit_app/src/api/CoupleApi.ts index 9f651fc..41234bd 100644 --- a/geneit_app/src/api/CoupleApi.ts +++ b/geneit_app/src/api/CoupleApi.ts @@ -1,5 +1,6 @@ import { APIClient } from "./ApiClient"; import { DateValue, Member } from "./MemberApi"; +import { ServerApi } from "./ServerApi"; interface CoupleApiInterface { id: number; @@ -103,6 +104,13 @@ export class Couple implements CoupleApiInterface { otherPersonID(id: number): number | undefined { return id === this.wife ? this.husband : this.wife; } + + get stateFr(): string { + return ( + ServerApi.Config.couples_states.find((c) => c.code === this.state)?.fr ?? + "" + ); + } } export class CouplesList { diff --git a/geneit_app/src/widgets/BasicFamilyTree.tsx b/geneit_app/src/widgets/BasicFamilyTree.tsx index fa86411..df1fbfe 100644 --- a/geneit_app/src/widgets/BasicFamilyTree.tsx +++ b/geneit_app/src/widgets/BasicFamilyTree.tsx @@ -7,6 +7,7 @@ import { MemberPhoto } from "./MemberPhoto"; import { Member, fmtDate } from "../api/MemberApi"; import Icon from "@mdi/react"; import { mdiBabyCarriage, mdiCross } from "@mdi/js"; +import { Couple } from "../api/CoupleApi"; export function BasicFamilyTree(p: { tree: FamilyTreeNode; @@ -46,7 +47,7 @@ function FamilyTreeItem(p: { n: FamilyTreeNode }): React.ReactElement { marginLeft: "20px", }} > - + ))} @@ -62,6 +63,7 @@ function FamilyTreeItem(p: { n: FamilyTreeNode }): React.ReactElement { function BasicFamilyMemberItem(p: { member: Member; primary?: boolean; + couple?: Couple; }): React.ReactElement { return (
@@ -69,7 +71,7 @@ function BasicFamilyMemberItem(p: {
- {p.member.fullName}{" "} + {p.member.fullName} {p.couple?.state && `(${p.couple.stateFr}) `} {p.member?.dead && }