Simplify couples interactions
This commit is contained in:
parent
ce5fb3077d
commit
c230f83926
@ -24,6 +24,7 @@ import { DateInput } from "../../widgets/forms/DateInput";
|
||||
import { MemberInput } from "../../widgets/forms/MemberInput";
|
||||
import { PropSelect } from "../../widgets/forms/SelectInput";
|
||||
import { UploadPhotoButton } from "../../widgets/forms/UploadPhotoButton";
|
||||
import { useQuery } from "../../hooks/useQuery";
|
||||
|
||||
/**
|
||||
* Create a new couple route
|
||||
@ -36,6 +37,13 @@ export function FamilyCreateCoupleRoute(): React.ReactElement {
|
||||
const n = useNavigate();
|
||||
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) => {
|
||||
try {
|
||||
const r = await CoupleApi.Create(m);
|
||||
@ -58,7 +66,7 @@ export function FamilyCreateCoupleRoute(): React.ReactElement {
|
||||
|
||||
return (
|
||||
<CouplePage
|
||||
couple={Couple.New(family.family.family_id)}
|
||||
couple={couple}
|
||||
creating={true}
|
||||
editing={true}
|
||||
onCancel={cancel}
|
||||
@ -463,6 +471,18 @@ export function CouplePage(p: {
|
||||
</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>
|
||||
</Grid>
|
||||
)}
|
||||
|
@ -637,6 +637,18 @@ export function MemberPage(p: {
|
||||
<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>
|
||||
</Grid>
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user