Skip to content

Commit

Permalink
add service utils to delete team + invite members
Browse files Browse the repository at this point in the history
  • Loading branch information
juancwu committed Apr 23, 2024
1 parent 6198daa commit 1649e44
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/services/utils/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,41 @@ export async function createTeam(teamName: string) {
throw e;
}
}

// The following functions are team owners only. Regular members calling this will result in failure/rejection

/**
* Calls the cloud function that sends emails to the given members.
* @param members the email addresses of those members
*/
export async function inviteMembers(emails: string[]) {
try {
const fn = httpsCallable<unknown, CloudFunctionResponse<void>>(
functions,
"inviteMembers"
);
const { data } = await fn({ emails });
return data;
} catch (e) {
await handleError(e as Error, "invite_members_error");
throw e;
}
}


/**
* Calls the cloud function 'deleteTeam' that deletes the given team the requesting user owns
*/
export async function deleteTeam() {
try {
const fn = httpsCallable<unknown, CloudFunctionResponse<void>>(
functions,
"deleteTeam"
);
const { data } = await fn();
return data;
} catch (e) {
await handleError(e as Error, "delete_team_error");
throw e;
}
}

0 comments on commit 1649e44

Please sign in to comment.