Show siblings on member page
This commit is contained in:
parent
e4ca9f7e9e
commit
d0cfc0e981
@ -195,6 +195,16 @@ export class MembersList {
|
|||||||
children(id: number): Member[] {
|
children(id: number): Member[] {
|
||||||
return this.list.filter((m) => m.mother === id || m.father === id);
|
return this.list.filter((m) => m.mother === id || m.father === id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
siblings(id: number): Member[] {
|
||||||
|
const p = this.get(id);
|
||||||
|
return this.list.filter(
|
||||||
|
(m) =>
|
||||||
|
m.id !== p?.id &&
|
||||||
|
((m.mother && m.mother === p?.mother) ||
|
||||||
|
(m.father && m.father === p?.father))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MemberApi {
|
export class MemberApi {
|
||||||
|
@ -128,6 +128,7 @@ export function FamilyMemberRoute(): React.ReactElement {
|
|||||||
<MemberPage
|
<MemberPage
|
||||||
member={member!}
|
member={member!}
|
||||||
children={family.members.children(member!.id)}
|
children={family.members.children(member!.id)}
|
||||||
|
siblings={family.members.siblings(member!.id)}
|
||||||
creating={false}
|
creating={false}
|
||||||
editing={false}
|
editing={false}
|
||||||
onRequestDelete={deleteMember}
|
onRequestDelete={deleteMember}
|
||||||
@ -206,6 +207,7 @@ export function MemberPage(p: {
|
|||||||
creating: boolean;
|
creating: boolean;
|
||||||
shouldAllowLeaving?: boolean;
|
shouldAllowLeaving?: boolean;
|
||||||
children?: Member[];
|
children?: Member[];
|
||||||
|
siblings?: Member[];
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
onSave?: (m: Member) => void;
|
onSave?: (m: Member) => void;
|
||||||
onRequestEdit?: () => void;
|
onRequestEdit?: () => void;
|
||||||
@ -628,6 +630,26 @@ export function MemberPage(p: {
|
|||||||
</PropertiesBox>
|
</PropertiesBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Siblings */}
|
||||||
|
{p.siblings && (
|
||||||
|
<Grid item sm={12} md={6}>
|
||||||
|
<PropertiesBox title="Frères et sœurs">
|
||||||
|
{p.siblings.length === 0 ? (
|
||||||
|
<>Aucun frère ou sœur</>
|
||||||
|
) : (
|
||||||
|
p.siblings.map((c) => (
|
||||||
|
<RouterLink
|
||||||
|
key={c.id}
|
||||||
|
to={family.family.URL(`member/${c.id}`)}
|
||||||
|
>
|
||||||
|
<MemberItem member={c} />
|
||||||
|
</RouterLink>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</PropertiesBox>
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user