services refactor

This commit is contained in:
2025-12-17 22:17:02 +01:00
parent 26f7a2b6aa
commit 055a7f67b5
93 changed files with 7434 additions and 659 deletions

View File

@@ -1,16 +1,52 @@
import { api as api } from '../../api';
import { presentTeamJoinRequest } from '../../presenters';
import { TeamJoinRequestViewModel } from '../../view-models';
import type { TeamsApiClient } from '../../api/teams/TeamsApiClient';
import type { TeamJoinRequestPresenter } from '../../presenters/TeamJoinRequestPresenter';
import type { TeamJoinRequestViewModel } from '../../view-models';
export async function getTeamJoinRequests(teamId: string, currentUserId: string, isOwner: boolean): Promise<TeamJoinRequestViewModel[]> {
const dto = await api.teams.getJoinRequests(teamId);
return dto.requests.map(r => presentTeamJoinRequest(r, currentUserId, isOwner));
}
/**
* Team Join Service
*
* Orchestrates team join/leave operations by coordinating API calls and presentation logic.
* All dependencies are injected via constructor.
*/
export class TeamJoinService {
constructor(
private readonly apiClient: TeamsApiClient,
private readonly teamJoinRequestPresenter: TeamJoinRequestPresenter
) {}
export async function approveTeamJoinRequest(teamId: string, requestId: string): Promise<void> {
// TODO: implement API call
}
/**
* Get team join requests with presentation transformation
*/
async getJoinRequests(teamId: string, currentUserId: string, isOwner: boolean): Promise<TeamJoinRequestViewModel[]> {
try {
const dto = await this.apiClient.getJoinRequests(teamId);
return dto.requests.map(r => this.teamJoinRequestPresenter.present(r, currentUserId, isOwner));
} catch (error) {
throw error;
}
}
export async function rejectTeamJoinRequest(teamId: string, requestId: string): Promise<void> {
// TODO: implement API call
/**
* Approve a team join request
*/
async approveJoinRequest(teamId: string, requestId: string): Promise<void> {
try {
// TODO: implement API call when endpoint is available
throw new Error('Not implemented: API endpoint for approving join requests');
} catch (error) {
throw error;
}
}
/**
* Reject a team join request
*/
async rejectJoinRequest(teamId: string, requestId: string): Promise<void> {
try {
// TODO: implement API call when endpoint is available
throw new Error('Not implemented: API endpoint for rejecting join requests');
} catch (error) {
throw error;
}
}
}