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[] {
|
||||
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 {
|
||||
|
@ -128,6 +128,7 @@ export function FamilyMemberRoute(): React.ReactElement {
|
||||
<MemberPage
|
||||
member={member!}
|
||||
children={family.members.children(member!.id)}
|
||||
siblings={family.members.siblings(member!.id)}
|
||||
creating={false}
|
||||
editing={false}
|
||||
onRequestDelete={deleteMember}
|
||||
@ -206,6 +207,7 @@ export function MemberPage(p: {
|
||||
creating: boolean;
|
||||
shouldAllowLeaving?: boolean;
|
||||
children?: Member[];
|
||||
siblings?: Member[];
|
||||
onCancel?: () => void;
|
||||
onSave?: (m: Member) => void;
|
||||
onRequestEdit?: () => void;
|
||||
@ -628,6 +630,26 @@ export function MemberPage(p: {
|
||||
</PropertiesBox>
|
||||
</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>
|
||||
</div>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user