Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { http } from '@amalia/core/http/client';
import {
type CreateTeamRequest,
type LinkExistingTeamsRequest,
type SetTeamNameRequest,
type TeamContract,
type UnarchiveTeamRequest,
} from '@amalia/tenants/teams/types';
export class TeamsApiClient {
public static async createTeam(team: CreateTeamRequest): Promise<TeamContract> {
const { data } = await http.post<TeamContract>('/teams', team);
return data;
}
public static async getTeams(): Promise<TeamContract[]> {
const { data } = await http.get<TeamContract[]>('/teams');
return data;
}
// Will be removed when team detail view is refactored.
public static async getTeam(teamId: string): Promise<TeamContract> {
const { data } = await http.get<TeamContract>(`/teams/team/${teamId}`);
return data;
}
public static async setTeamName({
teamId,
...setTeamNameRequest
}: SetTeamNameRequest & { teamId: TeamContract['id'] }): Promise<void> {
await http.put(`/teams/${encodeURIComponent(teamId)}/name`, setTeamNameRequest);
}
public static async deleteTeam(teamId: TeamContract['id']) {
await http.delete(`/teams/${encodeURIComponent(teamId)}`);
}
public static async linkExistingTeams({
teamId,
...linkExistingTeamsRequest
}: LinkExistingTeamsRequest & { teamId: TeamContract['id'] }): Promise<void> {
await http.post(`/teams/${encodeURIComponent(teamId)}/link-existing-teams`, linkExistingTeamsRequest);
}
public static async unlinkFromParentTeam(teamId: TeamContract['id']): Promise<void> {
await http.delete(`/teams/${encodeURIComponent(teamId)}/parent-team`);
}
public static async archiveTeam(teamId: TeamContract['id']): Promise<{ archivedTeamsCount: number }> {
return (await http.post<{ archivedTeamsCount: number }>(`/teams/${encodeURIComponent(teamId)}/archive`)).data;
}
public static async unarchiveTeam({
teamId,
...unarchiveTeamRequest
}: UnarchiveTeamRequest & { teamId: TeamContract['id'] }): Promise<{ unarchivedTeamsCount: number }> {
return (
await http.post<{ unarchivedTeamsCount: number }>(
`/teams/${encodeURIComponent(teamId)}/unarchive`,
unarchiveTeamRequest,
)
).data;
}
}
|