Files
gridpilot.gg/apps/website/lib/services/teams/TeamJoinService.ts
2025-12-17 22:17:02 +01:00

52 lines
1.6 KiB
TypeScript

import type { TeamsApiClient } from '../../api/teams/TeamsApiClient';
import type { TeamJoinRequestPresenter } from '../../presenters/TeamJoinRequestPresenter';
import type { TeamJoinRequestViewModel } from '../../view-models';
/**
* 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
) {}
/**
* 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;
}
}
/**
* 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;
}
}
}