website refactor

This commit is contained in:
2026-01-16 11:13:42 +01:00
parent d86aa4583b
commit d6b94e21df
30 changed files with 217 additions and 182 deletions

View File

@@ -1,5 +1,12 @@
import { TeamsApiClient } from '@/lib/api/teams/TeamsApiClient';
import type { TeamListItemDTO } from '@/lib/types/generated/TeamListItemDTO';
import type { CreateTeamInputDTO } from '@/lib/types/generated/CreateTeamInputDTO';
import type { CreateTeamOutputDTO } from '@/lib/types/generated/CreateTeamOutputDTO';
import type { UpdateTeamInputDTO } from '@/lib/types/generated/UpdateTeamInputDTO';
import type { UpdateTeamOutputDTO } from '@/lib/types/generated/UpdateTeamOutputDTO';
import type { GetDriverTeamOutputDTO } from '@/lib/types/generated/GetDriverTeamOutputDTO';
import type { GetTeamMembershipOutputDTO } from '@/lib/types/generated/GetTeamMembershipOutputDTO';
import type { GetTeamJoinRequestsOutputDTO } from '@/lib/types/generated/GetTeamJoinRequestsOutputDTO';
import { TeamMemberViewModel } from '@/lib/view-models/TeamMemberViewModel';
import { Result } from '@/lib/contracts/Result';
import { DomainError, Service } from '@/lib/contracts/services/Service';
@@ -37,7 +44,7 @@ export class TeamService implements Service {
}
}
async getTeamDetails(teamId: string, _: string): Promise<Result<unknown, DomainError>> {
async getTeamDetails(teamId: string, _: string): Promise<Result<any, DomainError>> {
try {
const result = await this.apiClient.getDetails(teamId);
if (!result) {
@@ -58,23 +65,48 @@ export class TeamService implements Service {
}
}
async getTeamJoinRequests(_: string): Promise<Result<unknown, DomainError>> {
return Result.err({ type: 'notImplemented', message: 'getTeamJoinRequests' });
async getTeamJoinRequests(teamId: string): Promise<Result<GetTeamJoinRequestsOutputDTO, DomainError>> {
try {
const result = await this.apiClient.getJoinRequests(teamId);
return Result.ok(result);
} catch (error: unknown) {
return Result.err({ type: 'unknown', message: (error as Error).message || 'Failed to fetch team join requests' });
}
}
async createTeam(__: unknown): Promise<Result<unknown, DomainError>> {
return Result.err({ type: 'notImplemented', message: 'createTeam' });
async createTeam(input: CreateTeamInputDTO): Promise<Result<CreateTeamOutputDTO, DomainError>> {
try {
const result = await this.apiClient.create(input);
return Result.ok(result);
} catch (error: unknown) {
return Result.err({ type: 'unknown', message: (error as Error).message || 'Failed to create team' });
}
}
async updateTeam(_: string, __: unknown): Promise<Result<unknown, DomainError>> {
return Result.err({ type: 'notImplemented', message: 'updateTeam' });
async updateTeam(teamId: string, input: UpdateTeamInputDTO): Promise<Result<UpdateTeamOutputDTO, DomainError>> {
try {
const result = await this.apiClient.update(teamId, input);
return Result.ok(result);
} catch (error: unknown) {
return Result.err({ type: 'unknown', message: (error as Error).message || 'Failed to update team' });
}
}
async getDriverTeam(_: string): Promise<Result<unknown, DomainError>> {
return Result.err({ type: 'notImplemented', message: 'getDriverTeam' });
async getDriverTeam(driverId: string): Promise<Result<GetDriverTeamOutputDTO | null, DomainError>> {
try {
const result = await this.apiClient.getDriverTeam(driverId);
return Result.ok(result);
} catch (error: unknown) {
return Result.err({ type: 'unknown', message: (error as Error).message || 'Failed to fetch driver team' });
}
}
async getMembership(_: string, __: string): Promise<Result<unknown, DomainError>> {
return Result.err({ type: 'notImplemented', message: 'getMembership' });
async getMembership(teamId: string, driverId: string): Promise<Result<GetTeamMembershipOutputDTO | null, DomainError>> {
try {
const result = await this.apiClient.getMembership(teamId, driverId);
return Result.ok(result);
} catch (error: unknown) {
return Result.err({ type: 'unknown', message: (error as Error).message || 'Failed to fetch team membership' });
}
}
}