diff --git a/geneit_app/src/App.tsx b/geneit_app/src/App.tsx
index afb7f0f..1bb55f3 100644
--- a/geneit_app/src/App.tsx
+++ b/geneit_app/src/App.tsx
@@ -37,6 +37,7 @@ import { FamilyCouplesListRoute } from "./routes/family/genealogy/FamilyCouplesL
import { FamilyTreeRoute } from "./routes/family/genealogy/FamilyTreeRoute";
import { FamilyMemberTreeRoute } from "./routes/family/genealogy/FamilyMemberTreeRoute";
import { GenealogyHomeRoute } from "./routes/family/genealogy/GenealogyHomeRoute";
+import { BaseGenealogyRoute } from "./widgets/genealogy/BaseGenealogyRoute";
interface AuthContext {
signedIn: boolean;
@@ -68,7 +69,7 @@ export function App(): React.ReactElement {
}>
} />
-
+ }>
} />
} />
diff --git a/geneit_app/src/widgets/genealogy/BaseGenealogyRoute.tsx b/geneit_app/src/widgets/genealogy/BaseGenealogyRoute.tsx
new file mode 100644
index 0000000..f2b1b3c
--- /dev/null
+++ b/geneit_app/src/widgets/genealogy/BaseGenealogyRoute.tsx
@@ -0,0 +1,73 @@
+import React from "react";
+import { Outlet } from "react-router-dom";
+import { CoupleApi, CouplesList } from "../../api/genealogy/CoupleApi";
+import { MemberApi, MembersList } from "../../api/genealogy/MemberApi";
+import { AsyncWidget } from "../AsyncWidget";
+import { useFamily } from "../BaseFamilyRoute";
+
+interface FamilyContext {
+ members: MembersList;
+ couples: CouplesList;
+ reloadMembersList: () => Promise;
+ reloadCouplesList: () => Promise;
+}
+
+const GenealogyContextK = React.createContext(null);
+
+export function BaseGenealogyRoute(): React.ReactElement {
+ const family = useFamily();
+
+ const [members, setMembers] = React.useState(null);
+ const [couples, setCouples] = React.useState(null);
+
+ const loadKey = React.useRef(1);
+
+ const loadPromise = React.useRef<() => void>();
+
+ const load = async () => {
+ setMembers(await MemberApi.GetEntireList(family.familyId));
+ setCouples(await CoupleApi.GetEntireList(family.familyId));
+ };
+
+ const onReload = async () => {
+ loadKey.current += 1;
+ setMembers(null);
+ setCouples(null);
+
+ return new Promise((res, _rej) => {
+ loadPromise.current = () => res();
+ });
+ };
+
+ return (
+ {
+ if (loadPromise.current != null) {
+ loadPromise.current?.();
+ loadPromise.current = undefined;
+ }
+
+ return (
+
+
+
+ );
+ }}
+ />
+ );
+}
+
+export function useGenealogy(): FamilyContext {
+ return React.useContext(GenealogyContextK)!;
+}