view models
This commit is contained in:
@@ -1,52 +1,46 @@
|
||||
import type { TeamsApiClient } from '../../api/teams/TeamsApiClient';
|
||||
import type { TeamJoinRequestPresenter } from '../../presenters/TeamJoinRequestPresenter';
|
||||
import type { TeamJoinRequestViewModel } from '../../view-models';
|
||||
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 presentation logic.
|
||||
* 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,
|
||||
private readonly teamJoinRequestPresenter: TeamJoinRequestPresenter
|
||||
private readonly apiClient: TeamsApiClient
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get team join requests with presentation transformation
|
||||
* Get team join requests with view model 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;
|
||||
}
|
||||
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> {
|
||||
try {
|
||||
// TODO: implement API call when endpoint is available
|
||||
throw new Error('Not implemented: API endpoint for approving join requests');
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
// 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> {
|
||||
try {
|
||||
// TODO: implement API call when endpoint is available
|
||||
throw new Error('Not implemented: API endpoint for rejecting join requests');
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
// TODO: implement API call when endpoint is available
|
||||
throw new Error('Not implemented: API endpoint for rejecting join requests');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user