Display the list of family users

This commit is contained in:
2023-07-09 17:02:43 +02:00
parent 099e517688
commit addaca1b0e
11 changed files with 171 additions and 15 deletions

View File

@ -26,7 +26,7 @@ export class APIClient {
*/
static async exec(args: {
uri: string;
method: "GET" | "POST" | "DELETE";
method: "GET" | "POST" | "DELETE" | "PATCH";
allowFail?: boolean;
jsonData?: any;
}): Promise<APIResponse> {

View File

@ -62,6 +62,15 @@ export enum JoinFamilyResult {
Success,
}
export interface FamilyUser {
user_id: number;
family_id: number;
time_create: number;
is_admin: boolean;
user_name: string;
user_mail: string;
}
export class FamilyApi {
/**
* Create a new family
@ -142,4 +151,29 @@ export class FamilyApi {
uri: `/family/${id}/renew_invitation_code`,
});
}
/**
* Get the users of a family
*/
static async GetUsersList(id: number): Promise<FamilyUser[]> {
return (
await APIClient.exec({
method: "GET",
uri: `/family/${id}/users`,
})
).data;
}
/**
* Update a user of the family
*/
static async UpdateUser(user: FamilyUser): Promise<void> {
await APIClient.exec({
method: "PATCH",
uri: `/family/${user.family_id}/user/${user.user_id}`,
jsonData: {
is_admin: user.is_admin,
},
});
}
}