46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import type { TeamsApiClient } from '../../api/teams/TeamsApiClient';
|
|
import { TeamJoinRequestViewModel } from '../../view-models';
|
|
|
|
type TeamJoinRequestDTO = {
|
|
id: string;
|
|
teamId: string;
|
|
driverId: string;
|
|
requestedAt: string;
|
|
message?: string;
|
|
};
|
|
|
|
/**
|
|
* Team Join Service
|
|
*
|
|
* Orchestrates team join/leave operations by coordinating API calls and view model creation.
|
|
* All dependencies are injected via constructor.
|
|
*/
|
|
export class TeamJoinService {
|
|
constructor(
|
|
private readonly apiClient: TeamsApiClient
|
|
) {}
|
|
|
|
/**
|
|
* Get team join requests with view model transformation
|
|
*/
|
|
async getJoinRequests(teamId: string, currentUserId: string, isOwner: boolean): Promise<TeamJoinRequestViewModel[]> {
|
|
const dto = await this.apiClient.getJoinRequests(teamId);
|
|
return dto.requests.map((r: TeamJoinRequestDTO) => new TeamJoinRequestViewModel(r, currentUserId, isOwner));
|
|
}
|
|
|
|
/**
|
|
* Approve a team join request
|
|
*/
|
|
async approveJoinRequest(teamId: string, requestId: string): Promise<void> {
|
|
// TODO: implement API call when endpoint is available
|
|
throw new Error('Not implemented: API endpoint for approving join requests');
|
|
}
|
|
|
|
/**
|
|
* Reject a team join request
|
|
*/
|
|
async rejectJoinRequest(teamId: string, requestId: string): Promise<void> {
|
|
// TODO: implement API call when endpoint is available
|
|
throw new Error('Not implemented: API endpoint for rejecting join requests');
|
|
}
|
|
} |