Can set member photo

This commit is contained in:
2023-08-10 12:10:09 +02:00
parent 10e8f339cc
commit d1e55d574e
12 changed files with 450 additions and 35 deletions

View File

@ -106,6 +106,14 @@ export class Member implements MemberDataApi {
? this.last_name ?? ""
: `${firstName} ${this.last_name ?? ""}`;
}
get hasPhoto(): boolean {
return this.photo_id !== null;
}
get photoURL(): string {
return `${APIClient.backendURL()}/photo/${this.signed_photo_id}`;
}
}
export class MembersList {
@ -174,6 +182,19 @@ export class MemberApi {
});
}
/**
* Set a new photo for a member
*/
static async SetMemberPhoto(m: Member, b: Blob): Promise<void> {
const fd = new FormData();
fd.append("photo", b);
await APIClient.exec({
uri: `/family/${m.family_id}/member/${m.id}/photo`,
method: "PUT",
formData: fd,
});
}
/**
* Delete a family member
*/