Change all application routes
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
Pierre HUBERT 2024-05-15 19:36:57 +02:00
parent 299d52f5d7
commit 84ef4cac53
9 changed files with 64 additions and 61 deletions

View File

@ -67,33 +67,42 @@ export function App(): React.ReactElement {
<Route path="family/:familyId/*" element={<BaseFamilyRoute />}> <Route path="family/:familyId/*" element={<BaseFamilyRoute />}>
<Route path="" element={<FamilyHomeRoute />} /> <Route path="" element={<FamilyHomeRoute />} />
<Route path="members" element={<FamilyMembersListRoute />} /> <Route path="genealogy/*">
<Route <Route path="members" element={<FamilyMembersListRoute />} />
path="member/create" <Route
element={<FamilyCreateMemberRoute />} path="member/create"
/> element={<FamilyCreateMemberRoute />}
<Route path="member/:memberId" element={<FamilyMemberRoute />} /> />
<Route <Route
path="member/:memberId/edit" path="member/:memberId"
element={<FamilyEditMemberRoute />} element={<FamilyMemberRoute />}
/> />
<Route
path="member/:memberId/edit"
element={<FamilyEditMemberRoute />}
/>
<Route path="couples" element={<FamilyCouplesListRoute />} /> <Route path="couples" element={<FamilyCouplesListRoute />} />
<Route <Route
path="couple/create" path="couple/create"
element={<FamilyCreateCoupleRoute />} element={<FamilyCreateCoupleRoute />}
/> />
<Route path="couple/:coupleId" element={<FamilyCoupleRoute />} /> <Route
<Route path="couple/:coupleId"
path="couple/:coupleId/edit" element={<FamilyCoupleRoute />}
element={<FamilyEditCoupleRoute />} />
/> <Route
path="couple/:coupleId/edit"
element={<FamilyEditCoupleRoute />}
/>
<Route path="tree" element={<FamilyTreeRoute />} /> <Route path="tree" element={<FamilyTreeRoute />} />
<Route <Route
path="tree/:memberId" path="tree/:memberId"
element={<FamilyMemberTreeRoute />} element={<FamilyMemberTreeRoute />}
/> />
<Route path="*" element={<NotFoundRoute />} />
</Route>
<Route path="settings" element={<FamilySettingsRoute />} /> <Route path="settings" element={<FamilySettingsRoute />} />
<Route path="users" element={<FamilyUsersListRoute />} /> <Route path="users" element={<FamilyUsersListRoute />} />

View File

@ -60,7 +60,8 @@ export class Family implements FamilyAPI {
*/ */
memberURL(member: Member, edit?: boolean): string { memberURL(member: Member, edit?: boolean): string {
return ( return (
`/family/${this.family_id}/member/${member.id}` + (edit ? "/edit" : "") `/family/${this.family_id}/genealogy/member/${member.id}` +
(edit ? "/edit" : "")
); );
} }
@ -68,7 +69,7 @@ export class Family implements FamilyAPI {
* Get family tree URL for member * Get family tree URL for member
*/ */
familyTreeURL(member: Member | number): string { familyTreeURL(member: Member | number): string {
return `/family/${this.family_id}/tree/${ return `/family/${this.family_id}/genealogy/tree/${
typeof member === "number" ? member : member.id typeof member === "number" ? member : member.id
}`; }`;
} }
@ -78,7 +79,8 @@ export class Family implements FamilyAPI {
*/ */
coupleURL(member: Couple, edit?: boolean): string { coupleURL(member: Couple, edit?: boolean): string {
return ( return (
`/family/${this.family_id}/couple/${member.id}` + (edit ? "/edit" : "") `/family/${this.family_id}/genealogy/couple/${member.id}` +
(edit ? "/edit" : "")
); );
} }
} }

View File

@ -62,7 +62,7 @@ export function FamilyCreateCoupleRoute(): React.ReactElement {
const cancel = () => { const cancel = () => {
setShouldQuit(true); setShouldQuit(true);
n(family.family.URL("couples")); n(family.family.URL("genealogy/couples"));
}; };
return ( return (
@ -115,7 +115,7 @@ export function FamilyCoupleRoute(): React.ReactElement {
await CoupleApi.Delete(couple!); await CoupleApi.Delete(couple!);
snackbar("La fiche du couple a été supprimée avec succès !"); snackbar("La fiche du couple a été supprimée avec succès !");
n(family.family.URL("couples")); n(family.family.URL("genealogy/couples"));
await family.reloadCouplesList(); await family.reloadCouplesList();
} catch (e) { } catch (e) {
@ -486,7 +486,7 @@ export function CouplePage(p: {
<div style={{ display: "flex", justifyContent: "end" }}> <div style={{ display: "flex", justifyContent: "end" }}>
<RouterLink <RouterLink
to={family.family.URL( to={family.family.URL(
`member/create?mother=${couple.wife}&father=${couple.husband}` `genealogy/member/create?mother=${couple.wife}&father=${couple.husband}`
)} )}
> >
<Button>Nouveau</Button> <Button>Nouveau</Button>

View File

@ -63,7 +63,7 @@ export function FamilyCreateMemberRoute(): React.ReactElement {
await family.reloadMembersList(); await family.reloadMembersList();
setShouldQuit(true); setShouldQuit(true);
n(family.family.URL(`member/${r.id}`)); n(family.family.URL(`genealogy/member/${r.id}`));
snackbar(`La fiche pour ${r.fullName} a été créée avec succès !`); snackbar(`La fiche pour ${r.fullName} a été créée avec succès !`);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
@ -73,7 +73,7 @@ export function FamilyCreateMemberRoute(): React.ReactElement {
const cancel = () => { const cancel = () => {
setShouldQuit(true); setShouldQuit(true);
n(family.family.URL("members")); n(family.family.URL("genealogy/members"));
}; };
const member = Member.New(family.family.family_id); const member = Member.New(family.family.family_id);
@ -130,7 +130,7 @@ export function FamilyMemberRoute(): React.ReactElement {
await MemberApi.Delete(member!); await MemberApi.Delete(member!);
snackbar("La fiche de membre a été supprimée avec succès !"); snackbar("La fiche de membre a été supprimée avec succès !");
n(family.family.URL("members")); n(family.family.URL("genealogy/members"));
await family.reloadMembersList(); await family.reloadMembersList();
} catch (e) { } catch (e) {
@ -155,9 +155,7 @@ export function FamilyMemberRoute(): React.ReactElement {
editing={false} editing={false}
onrequestOpenTree={() => n(family.family.familyTreeURL(member!))} onrequestOpenTree={() => n(family.family.familyTreeURL(member!))}
onRequestDelete={deleteMember} onRequestDelete={deleteMember}
onRequestEdit={() => onRequestEdit={() => n(family.family.memberURL(member!, true))}
n(family.family.URL(`member/${member!.id}/edit`))
}
onForceReload={forceReload} onForceReload={forceReload}
/> />
)} )}
@ -199,7 +197,7 @@ export function FamilyEditMemberRoute(): React.ReactElement {
await family.reloadMembersList(); await family.reloadMembersList();
setShouldQuit(true); setShouldQuit(true);
n(family.family.URL(`member/${member!.id}`)); n(family.family.memberURL(member!));
} catch (e) { } catch (e) {
console.error(e); console.error(e);
alert("Échec de la mise à jour des informations du membre !"); alert("Échec de la mise à jour des informations du membre !");
@ -682,10 +680,7 @@ export function MemberPage(p: {
<>Aucun enfant</> <>Aucun enfant</>
) : ( ) : (
p.children.map((c) => ( p.children.map((c) => (
<RouterLink <RouterLink key={c.id} to={family.family.memberURL(c)}>
key={c.id}
to={family.family.URL(`member/${c.id}`)}
>
<MemberItem member={c} /> <MemberItem member={c} />
</RouterLink> </RouterLink>
)) ))
@ -694,7 +689,7 @@ export function MemberPage(p: {
<div style={{ display: "flex", justifyContent: "end" }}> <div style={{ display: "flex", justifyContent: "end" }}>
<RouterLink <RouterLink
to={family.family.URL( to={family.family.URL(
`member/create?${ `genealogy/member/create?${
member.sex === "F" ? "mother" : "father" member.sex === "F" ? "mother" : "father"
}=${member.id}` }=${member.id}`
)} )}
@ -714,10 +709,7 @@ export function MemberPage(p: {
<>Aucun frère ou sœur</> <>Aucun frère ou sœur</>
) : ( ) : (
p.siblings.map((c) => ( p.siblings.map((c) => (
<RouterLink <RouterLink key={c.id} to={family.family.memberURL(c)}>
key={c.id}
to={family.family.URL(`member/${c.id}`)}
>
<MemberItem member={c} /> <MemberItem member={c} />
</RouterLink> </RouterLink>
)) ))
@ -727,7 +719,7 @@ export function MemberPage(p: {
<div style={{ display: "flex", justifyContent: "end" }}> <div style={{ display: "flex", justifyContent: "end" }}>
<RouterLink <RouterLink
to={family.family.URL( to={family.family.URL(
`member/create?mother=${member.mother}&father=${member.father}` `genealogy/member/create?mother=${member.mother}&father=${member.father}`
)} )}
> >
<Button>Nouveau</Button> <Button>Nouveau</Button>

View File

@ -87,7 +87,7 @@ export function FamilyMemberTreeRoute(): React.ReactElement {
dense dense
member={member} member={member}
secondary={ secondary={
<RouterLink to={family.family.URL("tree")}> <RouterLink to={family.family.URL("genealogy/tree")}>
<IconButton> <IconButton>
<ClearIcon /> <ClearIcon />
</IconButton> </IconButton>

View File

@ -60,7 +60,7 @@ export function FamilyMembersListRoute(): React.ReactElement {
}} }}
> >
<FamilyPageTitle title="Membres de la famille" /> <FamilyPageTitle title="Membres de la famille" />
<RouterLink to={family.family.URL("member/create")}> <RouterLink to={family.family.URL("genealogy/member/create")}>
<Tooltip title="Créer la fiche d'un nouveau membre"> <Tooltip title="Créer la fiche d'un nouveau membre">
<Button startIcon={<AddIcon />}>Nouveau</Button> <Button startIcon={<AddIcon />}>Nouveau</Button>
</Tooltip> </Tooltip>

View File

@ -14,9 +14,9 @@ import {
} from "@mui/material"; } from "@mui/material";
import React from "react"; import React from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { DataApi } from "../../api/genealogy/DataApi";
import { FamilyApi } from "../../api/FamilyApi"; import { FamilyApi } from "../../api/FamilyApi";
import { ServerApi } from "../../api/ServerApi"; import { ServerApi } from "../../api/ServerApi";
import { DataApi } from "../../api/genealogy/DataApi";
import { useAlert } from "../../hooks/context_providers/AlertDialogProvider"; import { useAlert } from "../../hooks/context_providers/AlertDialogProvider";
import { useConfirm } from "../../hooks/context_providers/ConfirmDialogProvider"; import { useConfirm } from "../../hooks/context_providers/ConfirmDialogProvider";
import { useLoadingMessage } from "../../hooks/context_providers/LoadingMessageProvider"; import { useLoadingMessage } from "../../hooks/context_providers/LoadingMessageProvider";
@ -55,7 +55,7 @@ export function FamilySettingsRoute(): React.ReactElement {
return ( return (
<> <>
<FamilySettingsCard /> <FamilySettingsCard />
<FamilyExportCard /> {family.family.enable_genealogy && <GenealogyExportCard />}
<div style={{ textAlign: "center", marginTop: "50px" }}> <div style={{ textAlign: "center", marginTop: "50px" }}>
<Button <Button
size="small" size="small"
@ -191,7 +191,7 @@ function FamilySettingsCard(): React.ReactElement {
); );
} }
function FamilyExportCard(): React.ReactElement { function GenealogyExportCard(): React.ReactElement {
const loading = useLoadingMessage(); const loading = useLoadingMessage();
const confirm = useConfirm(); const confirm = useConfirm();
const alert = useAlert(); const alert = useAlert();
@ -254,7 +254,7 @@ function FamilyExportCard(): React.ReactElement {
<FamilyCard error={error} success={success}> <FamilyCard error={error} success={success}>
<CardContent> <CardContent>
<Typography gutterBottom variant="h5" component="div"> <Typography gutterBottom variant="h5" component="div">
Export / import des données de la famille Export / import des données de généalogie
</Typography> </Typography>
<p> <p>
Vous pouvez, à des fins de sauvegardes ou de transfert, exporter et Vous pouvez, à des fins de sauvegardes ou de transfert, exporter et

View File

@ -26,8 +26,8 @@ import {
} from "@mui/material"; } from "@mui/material";
import React from "react"; import React from "react";
import { Outlet, useLocation, useParams } from "react-router-dom"; import { Outlet, useLocation, useParams } from "react-router-dom";
import { CoupleApi, CouplesList } from "../api/genealogy/CoupleApi";
import { ExtendedFamilyInfo, FamilyApi } from "../api/FamilyApi"; import { ExtendedFamilyInfo, FamilyApi } from "../api/FamilyApi";
import { CoupleApi, CouplesList } from "../api/genealogy/CoupleApi";
import { MemberApi, MembersList } from "../api/genealogy/MemberApi"; import { MemberApi, MembersList } from "../api/genealogy/MemberApi";
import { useAlert } from "../hooks/context_providers/AlertDialogProvider"; import { useAlert } from "../hooks/context_providers/AlertDialogProvider";
import { useConfirm } from "../hooks/context_providers/ConfirmDialogProvider"; import { useConfirm } from "../hooks/context_providers/ConfirmDialogProvider";
@ -150,10 +150,10 @@ export function BaseFamilyRoute(): React.ReactElement {
<FamilyLink <FamilyLink
icon={<Icon path={mdiCrowd} size={1} />} icon={<Icon path={mdiCrowd} size={1} />}
label="Membres" label="Membres"
uri="members" uri="genealogy/members"
secondaryAction={ secondaryAction={
<Tooltip title="Créer une nouvelle fiche de membre"> <Tooltip title="Créer une nouvelle fiche de membre">
<RouterLink to={family!.URL("member/create")}> <RouterLink to={family!.URL("genealogy/member/create")}>
<IconButton> <IconButton>
<Icon path={mdiPlus} size={0.75} /> <Icon path={mdiPlus} size={0.75} />
</IconButton> </IconButton>
@ -165,10 +165,10 @@ export function BaseFamilyRoute(): React.ReactElement {
<FamilyLink <FamilyLink
icon={<Icon path={mdiHumanMaleFemale} size={1} />} icon={<Icon path={mdiHumanMaleFemale} size={1} />}
label="Couples" label="Couples"
uri="couples" uri="genealogy/couples"
secondaryAction={ secondaryAction={
<Tooltip title="Créer une nouvelle fiche de couple"> <Tooltip title="Créer une nouvelle fiche de couple">
<RouterLink to={family!.URL("couple/create")}> <RouterLink to={family!.URL("genealogy/couple/create")}>
<IconButton> <IconButton>
<Icon path={mdiPlus} size={0.75} /> <Icon path={mdiPlus} size={0.75} />
</IconButton> </IconButton>
@ -180,7 +180,7 @@ export function BaseFamilyRoute(): React.ReactElement {
<FamilyLink <FamilyLink
icon={<Icon path={mdiFamilyTree} size={1} />} icon={<Icon path={mdiFamilyTree} size={1} />}
label="Arbre" label="Arbre"
uri="tree" uri="genealogy/tree"
/> />
<Divider sx={{ my: 1 }} /> <Divider sx={{ my: 1 }} />

View File

@ -30,7 +30,7 @@ export function MemberInput(p: {
onClick={ onClick={
!p.editable !p.editable
? () => { ? () => {
n(family.family.URL(`member/${member.id}`)); n(family.family.memberURL(member));
} }
: undefined : undefined
} }