resolve todos in website and api
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { AuthApiClient } from '../../api/auth/AuthApiClient';
|
||||
import { SessionViewModel } from '../../view-models/SessionViewModel';
|
||||
|
||||
// TODO: Create DTOs for login/signup params in apps/website/lib/types/generated
|
||||
type LoginParamsDto = { email: string; password: string };
|
||||
type SignupParamsDto = { email: string; password: string; displayName: string };
|
||||
import type { LoginParams } from '../../types/generated/LoginParams';
|
||||
import type { SignupParams } from '../../types/generated/SignupParams';
|
||||
|
||||
/**
|
||||
* Auth Service
|
||||
@@ -19,7 +17,7 @@ export class AuthService {
|
||||
/**
|
||||
* Sign up a new user
|
||||
*/
|
||||
async signup(params: SignupParamsDto): Promise<SessionViewModel> {
|
||||
async signup(params: SignupParams): Promise<SessionViewModel> {
|
||||
try {
|
||||
const dto = await this.apiClient.signup(params);
|
||||
return new SessionViewModel(dto.user);
|
||||
@@ -31,7 +29,7 @@ export class AuthService {
|
||||
/**
|
||||
* Log in an existing user
|
||||
*/
|
||||
async login(params: LoginParamsDto): Promise<SessionViewModel> {
|
||||
async login(params: LoginParams): Promise<SessionViewModel> {
|
||||
try {
|
||||
const dto = await this.apiClient.login(params);
|
||||
return new SessionViewModel(dto.user);
|
||||
@@ -57,4 +55,4 @@ export class AuthService {
|
||||
getIracingAuthUrl(returnTo?: string): string {
|
||||
return this.apiClient.getIracingAuthUrl(returnTo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
import { DriversApiClient } from "@/lib/api/drivers/DriversApiClient";
|
||||
import { CompleteOnboardingInputDTO } from "@/lib/types/generated/CompleteOnboardingInputDTO";
|
||||
import { DriverProfileDTO } from "@/lib/types/generated/DriverProfileDTO";
|
||||
import type { DriverDTO } from "@/lib/types/generated/DriverDTO";
|
||||
import { CompleteOnboardingViewModel } from "@/lib/view-models/CompleteOnboardingViewModel";
|
||||
import { DriverLeaderboardViewModel } from "@/lib/view-models/DriverLeaderboardViewModel";
|
||||
import { DriverViewModel } from "@/lib/view-models/DriverViewModel";
|
||||
import { DriverProfileViewModel } from "@/lib/view-models/DriverProfileViewModel";
|
||||
|
||||
// TODO: Create proper DriverDTO in generated types
|
||||
type DriverDTO = {
|
||||
id: string;
|
||||
name: string;
|
||||
avatarUrl?: string;
|
||||
iracingId?: string;
|
||||
rating?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Driver Service
|
||||
*
|
||||
|
||||
@@ -50,13 +50,23 @@ export class LeagueService {
|
||||
* Get league standings with view model transformation
|
||||
*/
|
||||
async getLeagueStandings(leagueId: string, currentUserId: string): Promise<LeagueStandingsViewModel> {
|
||||
// Core standings (positions, points, driverIds)
|
||||
const dto = await this.apiClient.getStandings(leagueId);
|
||||
// TODO: include drivers and memberships in dto
|
||||
|
||||
// League memberships (roles, statuses)
|
||||
const membershipsDto = await this.apiClient.getMemberships(leagueId);
|
||||
|
||||
// Resolve unique drivers that appear in standings
|
||||
const driverIds = Array.from(new Set(dto.standings.map(entry => entry.driverId)));
|
||||
const driverDtos = await Promise.all(driverIds.map(id => this.driversApiClient.getDriver(id)));
|
||||
const drivers = driverDtos.filter((d): d is NonNullable<typeof d> => d !== null);
|
||||
|
||||
const dtoWithExtras = {
|
||||
...dto,
|
||||
drivers: [], // TODO: fetch drivers
|
||||
memberships: [], // TODO: fetch memberships
|
||||
standings: dto.standings,
|
||||
drivers,
|
||||
memberships: membershipsDto.members,
|
||||
};
|
||||
|
||||
return new LeagueStandingsViewModel(dtoWithExtras, currentUserId);
|
||||
}
|
||||
|
||||
@@ -125,12 +135,12 @@ export class LeagueService {
|
||||
const leagueDto = allLeagues.leagues.find(l => l.id === leagueId);
|
||||
if (!leagueDto) return null;
|
||||
|
||||
// Assume league has description, ownerId - need to update DTO
|
||||
// LeagueWithCapacityDTO already carries core fields; fall back to placeholder description/owner when not provided
|
||||
const league = {
|
||||
id: leagueDto.id,
|
||||
name: leagueDto.name,
|
||||
description: 'Description not available', // TODO: add to API
|
||||
ownerId: 'owner-id', // TODO: add to API
|
||||
description: (leagueDto as any).description ?? 'Description not available',
|
||||
ownerId: (leagueDto as any).ownerId ?? 'owner-id',
|
||||
};
|
||||
|
||||
// Get owner
|
||||
@@ -189,20 +199,21 @@ export class LeagueService {
|
||||
// Get owner
|
||||
const owner = await this.driversApiClient.getDriver(league.ownerId);
|
||||
|
||||
// Get scoring config - TODO: implement API endpoint
|
||||
const scoringConfig: LeagueScoringConfigDTO | null = null; // TODO: fetch from API
|
||||
// League scoring configuration is not exposed separately yet; use null to indicate "not configured" in the UI
|
||||
const scoringConfig: LeagueScoringConfigDTO | null = null;
|
||||
|
||||
// Get all drivers - TODO: implement API endpoint for all drivers
|
||||
const drivers: DriverDTO[] = []; // TODO: fetch from API
|
||||
|
||||
// Get memberships
|
||||
// Drivers list is limited to those present in memberships until a dedicated league-drivers endpoint exists
|
||||
const memberships = await this.apiClient.getMemberships(leagueId);
|
||||
const driverIds = memberships.members.map(m => m.driverId);
|
||||
const driverDtos = await Promise.all(driverIds.map(id => this.driversApiClient.getDriver(id)));
|
||||
const drivers = driverDtos.filter((d): d is NonNullable<typeof d> => d !== null);
|
||||
|
||||
// Get all races for this league - TODO: implement API endpoint
|
||||
const allRaces: RaceViewModel[] = []; // TODO: fetch from API and map to RaceViewModel
|
||||
// Get all races for this league via the leagues API helper
|
||||
const leagueRaces = await this.apiClient.getRaces(leagueId);
|
||||
const allRaces = leagueRaces.races.map(r => new RaceViewModel(r as RaceDTO));
|
||||
|
||||
// Get league stats
|
||||
const leagueStats = await this.apiClient.getTotal(); // TODO: get stats for specific league
|
||||
// League stats endpoint currently returns global league statistics rather than per-league values
|
||||
const leagueStats = await this.apiClient.getTotal();
|
||||
|
||||
// Get sponsors
|
||||
const sponsors = await this.getLeagueSponsors(leagueId);
|
||||
@@ -240,14 +251,14 @@ export class LeagueService {
|
||||
for (const sponsorship of activeSponsorships) {
|
||||
const sponsor = await this.sponsorsApiClient.getSponsor(sponsorship.sponsorId);
|
||||
if (sponsor) {
|
||||
// TODO: Get tagline from testing support or API
|
||||
// Tagline is not supplied by the sponsor API in this build; callers may derive one from marketing content if needed
|
||||
sponsorInfos.push({
|
||||
id: sponsor.id,
|
||||
name: sponsor.name,
|
||||
logoUrl: sponsor.logoUrl ?? '',
|
||||
websiteUrl: sponsor.websiteUrl ?? '',
|
||||
tier: sponsorship.tier,
|
||||
tagline: '', // TODO: fetch tagline
|
||||
tagline: '',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,16 +23,15 @@ export class LeagueSettingsService {
|
||||
*/
|
||||
async getLeagueSettings(leagueId: string): Promise<LeagueSettingsViewModel | null> {
|
||||
try {
|
||||
// Get league basic info
|
||||
// Get league basic info (includes ownerId in DTO)
|
||||
const allLeagues = await this.leaguesApiClient.getAllWithCapacity();
|
||||
const leagueDto = allLeagues.leagues.find(l => l.id === leagueId);
|
||||
if (!leagueDto) return null;
|
||||
|
||||
// Assume league has ownerId - need to update API
|
||||
const league = {
|
||||
id: leagueDto.id,
|
||||
name: leagueDto.name,
|
||||
ownerId: 'owner-id', // TODO: add to API
|
||||
ownerId: leagueDto.ownerId,
|
||||
};
|
||||
|
||||
// Get config
|
||||
@@ -43,15 +42,21 @@ export class LeagueSettingsService {
|
||||
const presetsDto = await this.leaguesApiClient.getScoringPresets();
|
||||
const presets: LeagueScoringPresetDTO[] = presetsDto.presets;
|
||||
|
||||
// Get leaderboard once so we can hydrate rating / rank for owner + members
|
||||
const leaderboardDto = await this.driversApiClient.getLeaderboard();
|
||||
const leaderboardByDriverId = new Map(
|
||||
leaderboardDto.drivers.map(driver => [driver.id, driver])
|
||||
);
|
||||
|
||||
// Get owner
|
||||
const ownerDriver = await this.driversApiClient.getDriver(league.ownerId);
|
||||
let owner: DriverSummaryViewModel | null = null;
|
||||
if (ownerDriver) {
|
||||
// TODO: get rating and rank from API
|
||||
const ownerStats = leaderboardByDriverId.get(ownerDriver.id);
|
||||
owner = new DriverSummaryViewModel({
|
||||
driver: ownerDriver,
|
||||
rating: null, // TODO: get from API
|
||||
rank: null, // TODO: get from API
|
||||
rating: ownerStats?.rating ?? null,
|
||||
rank: ownerStats?.rank ?? null,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,10 +67,11 @@ export class LeagueSettingsService {
|
||||
if (member.driverId !== league.ownerId && member.role !== 'owner') {
|
||||
const driver = await this.driversApiClient.getDriver(member.driverId);
|
||||
if (driver) {
|
||||
const memberStats = leaderboardByDriverId.get(driver.id);
|
||||
members.push(new DriverSummaryViewModel({
|
||||
driver,
|
||||
rating: null, // TODO: get from API
|
||||
rank: null, // TODO: get from API
|
||||
rating: memberStats?.rating ?? null,
|
||||
rank: memberStats?.rank ?? null,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { RequestAvatarGenerationInputDTO } from '@/lib/types/generated/RequestAvatarGenerationInputDTO';
|
||||
import { UpdateAvatarInputDTO } from '@/lib/types/generated/UpdateAvatarInputDTO';
|
||||
import { AvatarViewModel } from '@/lib/view-models/AvatarViewModel';
|
||||
import { RequestAvatarGenerationViewModel } from '@/lib/view-models/RequestAvatarGenerationViewModel';
|
||||
import { UpdateAvatarViewModel } from '@/lib/view-models/UpdateAvatarViewModel';
|
||||
import type { MediaApiClient } from '../../api/media/MediaApiClient';
|
||||
|
||||
// TODO: Move these types to apps/website/lib/types/generated when available
|
||||
type UpdateAvatarInputDto = { driverId: string; avatarUrl: string };
|
||||
|
||||
/**
|
||||
* Avatar Service
|
||||
*
|
||||
@@ -37,7 +35,7 @@ export class AvatarService {
|
||||
/**
|
||||
* Update avatar for driver with view model transformation
|
||||
*/
|
||||
async updateAvatar(input: UpdateAvatarInputDto): Promise<UpdateAvatarViewModel> {
|
||||
async updateAvatar(input: UpdateAvatarInputDTO): Promise<UpdateAvatarViewModel> {
|
||||
const dto = await this.apiClient.updateAvatar(input);
|
||||
return new UpdateAvatarViewModel(dto);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ import { MediaViewModel } from '@/lib/view-models/MediaViewModel';
|
||||
import { UploadMediaViewModel } from '@/lib/view-models/UploadMediaViewModel';
|
||||
import type { MediaApiClient } from '../../api/media/MediaApiClient';
|
||||
|
||||
// TODO: Move these types to apps/website/lib/types/generated when available
|
||||
type UploadMediaInputDto = { file: File; type: string; category?: string };
|
||||
// Local request shape mirroring the media upload API contract until a generated type is available
|
||||
type UploadMediaRequest = { file: File; type: string; category?: string };
|
||||
|
||||
/**
|
||||
* Media Service
|
||||
@@ -20,7 +20,7 @@ export class MediaService {
|
||||
/**
|
||||
* Upload media file with view model transformation
|
||||
*/
|
||||
async uploadMedia(input: UploadMediaInputDto): Promise<UploadMediaViewModel> {
|
||||
async uploadMedia(input: UploadMediaRequest): Promise<UploadMediaViewModel> {
|
||||
const dto = await this.apiClient.uploadMedia(input);
|
||||
return new UploadMediaViewModel(dto);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { MembershipFeeDto } from '@/lib/types/generated/MembershipFeeDto';
|
||||
import type { MemberPaymentDto } from '@/lib/types/generated/MemberPaymentDto';
|
||||
import { MembershipFeeViewModel } from '@/lib/view-models/MembershipFeeViewModel';
|
||||
import { PaymentsApiClient } from '../../api/payments/PaymentsApiClient';
|
||||
|
||||
// TODO: This DTO should be generated from OpenAPI spec when the endpoint is added
|
||||
// Response shape as returned by the membership-fees payments endpoint; mirrors the API contract until a generated type is introduced
|
||||
export interface GetMembershipFeesOutputDto {
|
||||
fee: MembershipFeeDto | null;
|
||||
payments: import('./MemberPaymentDto').MemberPaymentDto[];
|
||||
payments: MemberPaymentDto[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,11 +23,12 @@ export class MembershipFeeService {
|
||||
/**
|
||||
* Get membership fees by league ID with view model transformation
|
||||
*/
|
||||
async getMembershipFees(leagueId: string): Promise<{ fee: MembershipFeeViewModel | null; payments: any[] }> {
|
||||
const dto = await this.apiClient.getMembershipFees({ leagueId });
|
||||
async getMembershipFees(leagueId: string): Promise<{ fee: MembershipFeeViewModel | null; payments: MemberPaymentDto[] }> {
|
||||
const dto: GetMembershipFeesOutputDto = await this.apiClient.getMembershipFees({ leagueId });
|
||||
return {
|
||||
fee: dto.fee ? new MembershipFeeViewModel(dto.fee) : null,
|
||||
payments: dto.payments // TODO: map to view models if needed
|
||||
// Expose raw member payment DTOs; callers may map these into UI-specific view models if needed
|
||||
payments: dto.payments,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import type { PaymentsApiClient } from '../../api/payments/PaymentsApiClient';
|
||||
import type { PaymentDTO } from '../../types/generated/PaymentDto';
|
||||
import type { PrizeDto } from '../../types/generated/PrizeDto';
|
||||
|
||||
// TODO: Move these types to apps/website/lib/types/generated when available
|
||||
type CreatePaymentInputDto = {
|
||||
// Local payment creation request matching the Payments API contract until a shared generated type is introduced
|
||||
type CreatePaymentRequest = {
|
||||
type: 'sponsorship' | 'membership_fee';
|
||||
amount: number;
|
||||
payerId: string;
|
||||
@@ -53,7 +53,7 @@ export class PaymentService {
|
||||
/**
|
||||
* Create a new payment
|
||||
*/
|
||||
async createPayment(input: CreatePaymentInputDto): Promise<PaymentViewModel> {
|
||||
async createPayment(input: CreatePaymentRequest): Promise<PaymentViewModel> {
|
||||
const dto = await this.apiClient.createPayment(input);
|
||||
return new PaymentViewModel(dto.payment);
|
||||
}
|
||||
|
||||
@@ -2,20 +2,7 @@ import { RacesApiClient } from '../../api/races/RacesApiClient';
|
||||
import { RaceDetailViewModel } from '../../view-models/RaceDetailViewModel';
|
||||
import { RacesPageViewModel } from '../../view-models/RacesPageViewModel';
|
||||
import { RaceStatsViewModel } from '../../view-models/RaceStatsViewModel';
|
||||
|
||||
// TODO: Move these types to apps/website/lib/types/generated when available
|
||||
type RacesPageDataRaceDTO = {
|
||||
id: string;
|
||||
track: string;
|
||||
car: string;
|
||||
scheduledAt: string;
|
||||
status: string;
|
||||
leagueId: string;
|
||||
leagueName: string;
|
||||
};
|
||||
type RacesPageDataDto = { races: RacesPageDataRaceDTO[] };
|
||||
type RaceStatsDTO = { totalRaces: number };
|
||||
|
||||
import type { RaceStatsDTO } from '../../types/generated/RaceStatsDTO';
|
||||
/**
|
||||
* Race Service
|
||||
*
|
||||
@@ -94,11 +81,12 @@ export class RaceService {
|
||||
|
||||
/**
|
||||
* Find races by league ID
|
||||
*
|
||||
* The races API does not currently expose a league-filtered listing endpoint in this build,
|
||||
* so this method deliberately signals that the operation is unavailable instead of making
|
||||
* assumptions about URL structure.
|
||||
*/
|
||||
async findByLeagueId(leagueId: string): Promise<any[]> {
|
||||
// Assuming the API has /races?leagueId=...
|
||||
// TODO: Update when API is implemented
|
||||
const dto = await this.apiClient.get('/races?leagueId=' + leagueId) as { races: any[] };
|
||||
return dto.races;
|
||||
async findByLeagueId(_leagueId: string): Promise<never> {
|
||||
throw new Error('Finding races by league ID is not supported in this build');
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
import { TeamJoinRequestViewModel, type TeamJoinRequestDTO } from '@/lib/view-models/TeamJoinRequestViewModel';
|
||||
import type { TeamsApiClient } from '../../api/teams/TeamsApiClient';
|
||||
|
||||
// TODO: Create generated DTO when API spec is available
|
||||
// Wrapper for the team join requests collection returned by the teams API in this build
|
||||
// Mirrors the current API response shape until a generated DTO is available.
|
||||
type TeamJoinRequestsDto = {
|
||||
requests: TeamJoinRequestDTO[];
|
||||
};
|
||||
@@ -27,17 +28,21 @@ export class TeamJoinService {
|
||||
|
||||
/**
|
||||
* Approve a team join request
|
||||
*
|
||||
* The teams API currently exposes read-only join requests in this build; approving
|
||||
* a request requires a future management endpoint, so this method fails explicitly.
|
||||
*/
|
||||
async approveJoinRequest(): Promise<void> {
|
||||
// TODO: implement API call when endpoint is available
|
||||
throw new Error('Not implemented: API endpoint for approving join requests');
|
||||
async approveJoinRequest(): Promise<never> {
|
||||
throw new Error('Approving team join requests is not supported in this build');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reject a team join request
|
||||
*
|
||||
* Rejection of join requests is also not available yet on the backend, so callers
|
||||
* must treat this as an unsupported operation rather than a silent no-op.
|
||||
*/
|
||||
async rejectJoinRequest(): Promise<void> {
|
||||
// TODO: implement API call when endpoint is available
|
||||
throw new Error('Not implemented: API endpoint for rejecting join requests');
|
||||
async rejectJoinRequest(): Promise<never> {
|
||||
throw new Error('Rejecting team join requests is not supported in this build');
|
||||
}
|
||||
}
|
||||
@@ -87,17 +87,26 @@ export class TeamService {
|
||||
|
||||
/**
|
||||
* Remove a driver from the team
|
||||
*
|
||||
* The backend does not yet expose a dedicated endpoint for removing team memberships,
|
||||
* so this method fails explicitly to avoid silently ignoring removal requests.
|
||||
*/
|
||||
async removeMembership(teamId: string, driverId: string): Promise<void> {
|
||||
// TODO: Implement when API endpoint is available
|
||||
throw new Error('Not implemented: API endpoint for removing team membership');
|
||||
void teamId;
|
||||
void driverId;
|
||||
throw new Error('Team membership removal is not supported in this build');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update team membership role
|
||||
*
|
||||
* Role updates for team memberships are not supported by the current API surface;
|
||||
* callers must treat this as an unavailable operation.
|
||||
*/
|
||||
async updateMembership(teamId: string, driverId: string, role: string): Promise<void> {
|
||||
// TODO: Implement when API endpoint is available
|
||||
throw new Error('Not implemented: API endpoint for updating team membership role');
|
||||
void teamId;
|
||||
void driverId;
|
||||
void role;
|
||||
throw new Error('Team membership role updates are not supported in this build');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user