Simplify couples interactions

This commit is contained in:
Pierre HUBERT 2023-08-16 14:57:28 +02:00
parent ce5fb3077d
commit c230f83926
2 changed files with 33 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import { DateInput } from "../../widgets/forms/DateInput";
import { MemberInput } from "../../widgets/forms/MemberInput"; import { MemberInput } from "../../widgets/forms/MemberInput";
import { PropSelect } from "../../widgets/forms/SelectInput"; import { PropSelect } from "../../widgets/forms/SelectInput";
import { UploadPhotoButton } from "../../widgets/forms/UploadPhotoButton"; import { UploadPhotoButton } from "../../widgets/forms/UploadPhotoButton";
import { useQuery } from "../../hooks/useQuery";
/** /**
* Create a new couple route * Create a new couple route
@ -36,6 +37,13 @@ export function FamilyCreateCoupleRoute(): React.ReactElement {
const n = useNavigate(); const n = useNavigate();
const family = useFamily(); const family = useFamily();
const params = useQuery();
const couple = Couple.New(family.family.family_id);
const wife = Number(params.get("wife"));
const husband = Number(params.get("husband"));
if (wife) couple.wife = wife;
if (husband) couple.husband = husband;
const create = async (m: Couple) => { const create = async (m: Couple) => {
try { try {
const r = await CoupleApi.Create(m); const r = await CoupleApi.Create(m);
@ -58,7 +66,7 @@ export function FamilyCreateCoupleRoute(): React.ReactElement {
return ( return (
<CouplePage <CouplePage
couple={Couple.New(family.family.family_id)} couple={couple}
creating={true} creating={true}
editing={true} editing={true}
onCancel={cancel} onCancel={cancel}
@ -463,6 +471,18 @@ export function CouplePage(p: {
</RouterLink> </RouterLink>
)) ))
)} )}
{couple.wife && couple.husband && (
<div style={{ display: "flex", justifyContent: "end" }}>
<RouterLink
to={family.family.URL(
`member/create?mother=${couple.wife}&father=${couple.husband}`
)}
>
<Button>Nouveau</Button>
</RouterLink>
</div>
)}
</PropertiesBox> </PropertiesBox>
</Grid> </Grid>
)} )}

View File

@ -637,6 +637,18 @@ export function MemberPage(p: {
<CoupleItem key={c.id} currMemberId={member.id} couple={c} /> <CoupleItem key={c.id} currMemberId={member.id} couple={c} />
)) ))
)} )}
<div style={{ display: "flex", justifyContent: "end" }}>
<RouterLink
to={family.family.URL(
`couple/create?${member.sex === "F" ? "wife" : "husband"}=${
member.id
}`
)}
>
<Button>Nouveau</Button>
</RouterLink>
</div>
</PropertiesBox> </PropertiesBox>
</Grid> </Grid>
)} )}