Sort children by birth day
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
26df996f8a
commit
d07bc200c4
@ -1,5 +1,5 @@
|
||||
import { Couple, CouplesList } from "../api/CoupleApi";
|
||||
import { Member, MembersList } from "../api/MemberApi";
|
||||
import { Member, MembersList, dateTimestamp } from "../api/MemberApi";
|
||||
|
||||
export interface CoupleInformation {
|
||||
couple: Couple;
|
||||
@ -67,13 +67,25 @@ export function buildDescendingTree(
|
||||
member_couples.push({
|
||||
couple: c,
|
||||
member: pair!,
|
||||
down: c_children.map((c) => buildDescendingTree(c.id, members, couples)),
|
||||
down: sortChildren(
|
||||
c_children.map((c) => buildDescendingTree(c.id, members, couples))
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
member: member,
|
||||
down: children.map((c) => buildDescendingTree(c.id, members, couples)),
|
||||
down: sortChildren(
|
||||
children.map((c) => buildDescendingTree(c.id, members, couples))
|
||||
),
|
||||
couples: member_couples,
|
||||
};
|
||||
}
|
||||
|
||||
function sortChildren(n: FamilyTreeNode[]): FamilyTreeNode[] {
|
||||
n.sort(
|
||||
(a, b) =>
|
||||
dateTimestamp(a.member.dateOfBirth) - dateTimestamp(b.member.dateOfBirth)
|
||||
);
|
||||
return n;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user