Build tree couples

This commit is contained in:
2023-08-21 17:53:51 +02:00
parent c414defb19
commit 4d5bdaad57
4 changed files with 108 additions and 6 deletions

View File

@ -1,5 +1,6 @@
import { APIClient } from "./ApiClient";
import { DateValue, Member } from "./MemberApi";
import { ServerApi } from "./ServerApi";
interface CoupleApiInterface {
id: number;
@ -99,6 +100,10 @@ export class Couple implements CoupleApiInterface {
day: this.divorce_day,
};
}
otherPersonID(id: number): number | undefined {
return id === this.wife ? this.husband : this.wife;
}
}
export class CouplesList {
@ -137,6 +142,10 @@ export class CouplesList {
getAllOf(m: Member): Couple[] {
return this.filter((c) => c.husband === m.id || c.wife === m.id);
}
getFirstMariedOf(m: Member): Couple | undefined {
return this.getAllOf(m).find((c) => (c.state = "M"));
}
}
export class CoupleApi {