This commit is contained in:
2025-12-11 21:06:25 +01:00
parent c49ea2598d
commit ec3ddc3a5c
227 changed files with 3496 additions and 2083 deletions

View File

@@ -1,4 +1,3 @@
import type { Team, TeamJoinRequest } from '@gridpilot/racing';
import type { DriverDTO } from '@gridpilot/racing/application/dto/DriverDTO';
import { EntityMappers } from '@gridpilot/racing/application/mappers/EntityMappers';
import {
@@ -34,7 +33,9 @@ export interface TeamAdminViewModel {
/**
* Load join requests plus driver DTOs for a team.
*/
export async function loadTeamAdminViewModel(team: Team): Promise<TeamAdminViewModel> {
export async function loadTeamAdminViewModel(
team: TeamAdminTeamSummaryViewModel,
): Promise<TeamAdminViewModel> {
const requests = await loadTeamJoinRequests(team.id);
return {
team: {
@@ -48,10 +49,18 @@ export async function loadTeamAdminViewModel(team: Team): Promise<TeamAdminViewM
};
}
export async function loadTeamJoinRequests(teamId: string): Promise<TeamAdminJoinRequestViewModel[]> {
export async function loadTeamJoinRequests(
teamId: string,
): Promise<TeamAdminJoinRequestViewModel[]> {
const getRequestsUseCase = getGetTeamJoinRequestsUseCase();
await getRequestsUseCase.execute({ teamId });
const presenterVm = getRequestsUseCase.presenter.getViewModel();
const presenter = new (await import('./TeamJoinRequestsPresenter')).TeamJoinRequestsPresenter();
await getRequestsUseCase.execute({ teamId }, presenter);
const presenterVm = presenter.getViewModel();
if (!presenterVm) {
return [];
}
const driverRepo = getDriverRepository();
const allDrivers = await driverRepo.findAll();
@@ -64,14 +73,29 @@ export async function loadTeamJoinRequests(teamId: string): Promise<TeamAdminJoi
}
}
return presenterVm.requests.map((req) => ({
id: req.requestId,
teamId: req.teamId,
driverId: req.driverId,
requestedAt: new Date(req.requestedAt),
message: req.message,
driver: driversById[req.driverId],
}));
return presenterVm.requests.map((req: {
requestId: string;
teamId: string;
driverId: string;
requestedAt: string;
message?: string;
}): TeamAdminJoinRequestViewModel => {
const base: TeamAdminJoinRequestViewModel = {
id: req.requestId,
teamId: req.teamId,
driverId: req.driverId,
requestedAt: new Date(req.requestedAt),
};
const message = req.message;
const driver = driversById[req.driverId];
return {
...base,
...(message !== undefined ? { message } : {}),
...(driver !== undefined ? { driver } : {}),
};
});
}
/**