resolve manual DTOs
This commit is contained in:
@@ -1,24 +1,10 @@
|
||||
import { BaseApiClient } from '../base/BaseApiClient';
|
||||
import { RecordPageViewOutputDTO } from '../../types/generated/RecordPageViewOutputDTO';
|
||||
import { RecordEngagementOutputDTO } from '../../types/generated/RecordEngagementOutputDTO';
|
||||
|
||||
// TODO: Move these types to apps/website/lib/types/generated when available
|
||||
type RecordPageViewInputDto = { path: string; userId?: string };
|
||||
type RecordEngagementInputDto = { eventType: string; userId?: string; metadata?: Record<string, unknown> };
|
||||
|
||||
// TODO: Move these types to apps/website/lib/types/generated when available
|
||||
type AnalyticsDashboardDto = {
|
||||
totalUsers: number;
|
||||
activeUsers: number;
|
||||
totalRaces: number;
|
||||
totalLeagues: number;
|
||||
};
|
||||
type AnalyticsMetricsDto = {
|
||||
pageViews: number;
|
||||
uniqueVisitors: number;
|
||||
averageSessionDuration: number;
|
||||
bounceRate: number;
|
||||
};
|
||||
import { GetDashboardDataOutputDTO } from '../../types/generated/GetDashboardDataOutputDTO';
|
||||
import { GetAnalyticsMetricsOutputDTO } from '../../types/generated/GetAnalyticsMetricsOutputDTO';
|
||||
import { RecordPageViewInputDTO } from '../../types/generated/RecordPageViewInputDTO';
|
||||
import { RecordEngagementInputDTO } from '../../types/generated/RecordEngagementInputDTO';
|
||||
|
||||
/**
|
||||
* Analytics API Client
|
||||
@@ -27,22 +13,22 @@ type AnalyticsMetricsDto = {
|
||||
*/
|
||||
export class AnalyticsApiClient extends BaseApiClient {
|
||||
/** Record a page view */
|
||||
recordPageView(input: RecordPageViewInputDto): Promise<RecordPageViewOutputDTO> {
|
||||
recordPageView(input: RecordPageViewInputDTO): Promise<RecordPageViewOutputDTO> {
|
||||
return this.post<RecordPageViewOutputDTO>('/analytics/page-view', input);
|
||||
}
|
||||
|
||||
/** Record an engagement event */
|
||||
recordEngagement(input: RecordEngagementInputDto): Promise<RecordEngagementOutputDTO> {
|
||||
recordEngagement(input: RecordEngagementInputDTO): Promise<RecordEngagementOutputDTO> {
|
||||
return this.post<RecordEngagementOutputDTO>('/analytics/engagement', input);
|
||||
}
|
||||
|
||||
/** Get analytics dashboard data */
|
||||
getDashboardData(): Promise<AnalyticsDashboardDto> {
|
||||
return this.get<AnalyticsDashboardDto>('/analytics/dashboard');
|
||||
getDashboardData(): Promise<GetDashboardDataOutputDTO> {
|
||||
return this.get<GetDashboardDataOutputDTO>('/analytics/dashboard');
|
||||
}
|
||||
|
||||
/** Get analytics metrics */
|
||||
getAnalyticsMetrics(): Promise<AnalyticsMetricsDto> {
|
||||
return this.get<AnalyticsMetricsDto>('/analytics/metrics');
|
||||
getAnalyticsMetrics(): Promise<GetAnalyticsMetricsOutputDTO> {
|
||||
return this.get<GetAnalyticsMetricsOutputDTO>('/analytics/metrics');
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { BaseApiClient } from '../base/BaseApiClient';
|
||||
import { AuthSessionDTO } from '../../types/generated/AuthSessionDTO';
|
||||
|
||||
// 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 { LoginParams } from '../../types/generated/LoginParams';
|
||||
import { SignupParams } from '../../types/generated/SignupParams';
|
||||
import { LoginWithIracingCallbackParams } from '../../types/generated/LoginWithIracingCallbackParams';
|
||||
import { IracingAuthRedirectResult } from '../../types/generated/IracingAuthRedirectResult';
|
||||
|
||||
/**
|
||||
* Auth API Client
|
||||
@@ -12,12 +12,12 @@ type SignupParamsDto = { email: string; password: string; displayName: string };
|
||||
*/
|
||||
export class AuthApiClient extends BaseApiClient {
|
||||
/** Sign up with email */
|
||||
signup(params: SignupParamsDto): Promise<AuthSessionDTO> {
|
||||
signup(params: SignupParams): Promise<AuthSessionDTO> {
|
||||
return this.post<AuthSessionDTO>('/auth/signup', params);
|
||||
}
|
||||
|
||||
/** Login with email */
|
||||
login(params: LoginParamsDto): Promise<AuthSessionDTO> {
|
||||
login(params: LoginParams): Promise<AuthSessionDTO> {
|
||||
return this.post<AuthSessionDTO>('/auth/login', params);
|
||||
}
|
||||
|
||||
@@ -32,9 +32,19 @@ export class AuthApiClient extends BaseApiClient {
|
||||
}
|
||||
|
||||
/** Start iRacing auth redirect */
|
||||
getIracingAuthUrl(returnTo?: string): string {
|
||||
const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:3001';
|
||||
const params = returnTo ? `?returnTo=${encodeURIComponent(returnTo)}` : '';
|
||||
return `${baseUrl}/auth/iracing/start${params}`;
|
||||
startIracingAuthRedirect(returnTo?: string): Promise<IracingAuthRedirectResult> {
|
||||
const query = returnTo ? `?returnTo=${encodeURIComponent(returnTo)}` : '';
|
||||
return this.get<IracingAuthRedirectResult>(`/auth/iracing/start${query}`);
|
||||
}
|
||||
|
||||
/** Login with iRacing callback */
|
||||
loginWithIracingCallback(params: LoginWithIracingCallbackParams): Promise<AuthSessionDTO> {
|
||||
const query = new URLSearchParams();
|
||||
query.append('code', params.code);
|
||||
query.append('state', params.state);
|
||||
if (params.returnTo) {
|
||||
query.append('returnTo', params.returnTo);
|
||||
}
|
||||
return this.get<AuthSessionDTO>(`/auth/iracing/callback?${query.toString()}`);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +1,27 @@
|
||||
import { BaseApiClient } from '../base/BaseApiClient';
|
||||
import {
|
||||
DashboardDriverSummaryDTO,
|
||||
DashboardRaceSummaryDTO,
|
||||
DashboardLeagueStandingSummaryDTO,
|
||||
DashboardFeedItemSummaryDTO,
|
||||
DashboardFriendSummaryDTO,
|
||||
DashboardRecentResultDTO,
|
||||
} from '../../types/generated';
|
||||
|
||||
// DTOs
|
||||
export type DriverDto = {
|
||||
id: string;
|
||||
name: string;
|
||||
avatarUrl: string;
|
||||
country: string;
|
||||
totalRaces: number;
|
||||
wins: number;
|
||||
podiums: number;
|
||||
rating: number;
|
||||
globalRank: number;
|
||||
consistency: number;
|
||||
};
|
||||
|
||||
export type RaceDto = {
|
||||
id: string;
|
||||
track: string;
|
||||
car: string;
|
||||
scheduledAt: string; // ISO date string
|
||||
isMyLeague: boolean;
|
||||
leagueName?: string;
|
||||
};
|
||||
|
||||
export type LeagueStandingDto = {
|
||||
leagueId: string;
|
||||
leagueName: string;
|
||||
position: number;
|
||||
points: number;
|
||||
totalDrivers: number;
|
||||
};
|
||||
|
||||
export type FeedItemDto = {
|
||||
id: string;
|
||||
type: string;
|
||||
headline: string;
|
||||
body: string | null;
|
||||
timestamp: string; // ISO date string
|
||||
ctaHref?: string;
|
||||
ctaLabel?: string;
|
||||
};
|
||||
|
||||
export type FriendDto = {
|
||||
id: string;
|
||||
name: string;
|
||||
avatarUrl: string;
|
||||
country: string;
|
||||
};
|
||||
|
||||
// Define DashboardOverviewDTO using generated types
|
||||
export type DashboardOverviewDto = {
|
||||
currentDriver: DriverDto;
|
||||
nextRace: RaceDto | null;
|
||||
upcomingRaces: RaceDto[];
|
||||
leagueStandings: LeagueStandingDto[];
|
||||
feedItems: FeedItemDto[];
|
||||
friends: FriendDto[];
|
||||
currentDriver: DashboardDriverSummaryDTO | null;
|
||||
myUpcomingRaces: DashboardRaceSummaryDTO[];
|
||||
otherUpcomingRaces: DashboardRaceSummaryDTO[];
|
||||
upcomingRaces: DashboardRaceSummaryDTO[];
|
||||
activeLeaguesCount: number;
|
||||
nextRace: DashboardRaceSummaryDTO | null;
|
||||
recentResults: DashboardRecentResultDTO[];
|
||||
leagueStandingsSummaries: DashboardLeagueStandingSummaryDTO[];
|
||||
feedSummary: {
|
||||
feedItems: DashboardFeedItemSummaryDTO[];
|
||||
};
|
||||
friends: DashboardFriendSummaryDTO[];
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
import { BaseApiClient } from '../base/BaseApiClient';
|
||||
// Import generated types
|
||||
import type { CompleteOnboardingInputDTO, CompleteOnboardingOutputDTO, DriverRegistrationStatusDTO, DriverLeaderboardItemDTO, DriverProfileDTO } from '../../types/generated';
|
||||
|
||||
// TODO: Create proper DriverDTO in generated types
|
||||
type DriverDTO = {
|
||||
id: string;
|
||||
name: string;
|
||||
avatarUrl?: string;
|
||||
iracingId?: string;
|
||||
rating?: number;
|
||||
};
|
||||
import type { CompleteOnboardingInputDTO, CompleteOnboardingOutputDTO, DriverRegistrationStatusDTO, DriverLeaderboardItemDTO, DriverProfileDTO, GetDriverOutputDTO } from '../../types/generated';
|
||||
|
||||
type DriversLeaderboardDto = {
|
||||
drivers: DriverLeaderboardItemDTO[];
|
||||
@@ -32,8 +23,8 @@ export class DriversApiClient extends BaseApiClient {
|
||||
}
|
||||
|
||||
/** Get current driver (based on session) */
|
||||
getCurrent(): Promise<DriverDTO | null> {
|
||||
return this.get<DriverDTO | null>('/drivers/current');
|
||||
getCurrent(): Promise<GetDriverOutputDTO | null> {
|
||||
return this.get<GetDriverOutputDTO | null>('/drivers/current');
|
||||
}
|
||||
|
||||
/** Get driver registration status for a specific race */
|
||||
@@ -42,8 +33,8 @@ export class DriversApiClient extends BaseApiClient {
|
||||
}
|
||||
|
||||
/** Get driver by ID */
|
||||
getDriver(driverId: string): Promise<DriverDTO | null> {
|
||||
return this.get<DriverDTO | null>(`/drivers/${driverId}`);
|
||||
getDriver(driverId: string): Promise<GetDriverOutputDTO | null> {
|
||||
return this.get<GetDriverOutputDTO | null>(`/drivers/${driverId}`);
|
||||
}
|
||||
|
||||
/** Get driver profile with full details */
|
||||
@@ -52,7 +43,7 @@ export class DriversApiClient extends BaseApiClient {
|
||||
}
|
||||
|
||||
/** Update current driver profile */
|
||||
updateProfile(updates: { bio?: string; country?: string }): Promise<DriverDTO> {
|
||||
return this.put<DriverDTO>('/drivers/profile', updates);
|
||||
updateProfile(updates: { bio?: string; country?: string }): Promise<GetDriverOutputDTO> {
|
||||
return this.put<GetDriverOutputDTO>('/drivers/profile', updates);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ import { AnalyticsApiClient } from './analytics/AnalyticsApiClient';
|
||||
import { AuthApiClient } from './auth/AuthApiClient';
|
||||
import { PaymentsApiClient } from './payments/PaymentsApiClient';
|
||||
import { DashboardApiClient } from './dashboard/DashboardApiClient';
|
||||
import { PenaltiesApiClient } from './penalties/PenaltiesApiClient';
|
||||
import { ProtestsApiClient } from './protests/ProtestsApiClient';
|
||||
|
||||
/**
|
||||
* Main API Client
|
||||
@@ -25,6 +27,8 @@ export class ApiClient {
|
||||
public readonly auth: AuthApiClient;
|
||||
public readonly payments: PaymentsApiClient;
|
||||
public readonly dashboard: DashboardApiClient;
|
||||
public readonly penalties: PenaltiesApiClient;
|
||||
public readonly protests: ProtestsApiClient;
|
||||
|
||||
constructor(baseUrl: string) {
|
||||
this.leagues = new LeaguesApiClient(baseUrl);
|
||||
@@ -37,6 +41,8 @@ export class ApiClient {
|
||||
this.auth = new AuthApiClient(baseUrl);
|
||||
this.payments = new PaymentsApiClient(baseUrl);
|
||||
this.dashboard = new DashboardApiClient(baseUrl);
|
||||
this.penalties = new PenaltiesApiClient(baseUrl);
|
||||
this.protests = new ProtestsApiClient(baseUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ import type {
|
||||
LeagueMembershipsDto,
|
||||
CreateLeagueInputDto,
|
||||
CreateLeagueOutputDto,
|
||||
SponsorshipDetailDTO,
|
||||
RaceDTO,
|
||||
} from '../../dtos';
|
||||
|
||||
/**
|
||||
@@ -61,8 +63,8 @@ export class LeaguesApiClient extends BaseApiClient {
|
||||
}
|
||||
|
||||
/** Get season sponsorships */
|
||||
getSeasonSponsorships(seasonId: string): Promise<{ sponsorships: Array<{ sponsorId: string; tier: string; status: string }> }> {
|
||||
return this.get<{ sponsorships: Array<{ sponsorId: string; tier: string; status: string }> }>(`/seasons/${seasonId}/sponsorships`);
|
||||
getSeasonSponsorships(seasonId: string): Promise<{ sponsorships: SponsorshipDetailDTO[] }> {
|
||||
return this.get<{ sponsorships: SponsorshipDetailDTO[] }>(`/leagues/seasons/${seasonId}/sponsorships`);
|
||||
}
|
||||
|
||||
/** Get league config */
|
||||
@@ -84,7 +86,7 @@ export class LeaguesApiClient extends BaseApiClient {
|
||||
}
|
||||
|
||||
/** Get races for a league */
|
||||
getRaces(leagueId: string): Promise<{ races: any[] }> {
|
||||
return this.get<{ races: any[] }>(`/leagues/${leagueId}/races`);
|
||||
getRaces(leagueId: string): Promise<{ races: RaceDTO[] }> {
|
||||
return this.get<{ races: RaceDTO[] }>(`/leagues/${leagueId}/races`);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
import type {
|
||||
DeleteMediaOutputDto,
|
||||
GetMediaOutputDto,
|
||||
RequestAvatarGenerationInputDto,
|
||||
RequestAvatarGenerationOutputDto,
|
||||
UpdateAvatarInputDto,
|
||||
UpdateAvatarOutputDto,
|
||||
UploadMediaInputDto,
|
||||
UploadMediaOutputDto,
|
||||
} from '../../dtos';
|
||||
import type { GetAvatarOutputDto } from '../../types/GetAvatarOutputDto';
|
||||
DeleteMediaOutputDTO,
|
||||
GetMediaOutputDTO,
|
||||
RequestAvatarGenerationInputDTO,
|
||||
RequestAvatarGenerationOutputDTO,
|
||||
UpdateAvatarInputDTO,
|
||||
UpdateAvatarOutputDTO,
|
||||
UploadMediaOutputDTO,
|
||||
} from '../generated';
|
||||
import type { GetAvatarOutputDTO } from '../generated';
|
||||
import { BaseApiClient } from '../base/BaseApiClient';
|
||||
|
||||
/**
|
||||
@@ -18,38 +17,38 @@ import { BaseApiClient } from '../base/BaseApiClient';
|
||||
*/
|
||||
export class MediaApiClient extends BaseApiClient {
|
||||
/** Upload media file */
|
||||
uploadMedia(input: UploadMediaInputDto): Promise<UploadMediaOutputDto> {
|
||||
uploadMedia(input: { file: File; type: string; category?: string }): Promise<UploadMediaOutputDTO> {
|
||||
const formData = new FormData();
|
||||
formData.append('file', input.file);
|
||||
formData.append('type', input.type);
|
||||
if (input.category) {
|
||||
formData.append('category', input.category);
|
||||
}
|
||||
return this.post<UploadMediaOutputDto>('/media/upload', formData);
|
||||
return this.post<UploadMediaOutputDTO>('/media/upload', formData);
|
||||
}
|
||||
|
||||
/** Get media by ID */
|
||||
getMedia(mediaId: string): Promise<GetMediaOutputDto> {
|
||||
return this.get<GetMediaOutputDto>(`/media/${mediaId}`);
|
||||
getMedia(mediaId: string): Promise<GetMediaOutputDTO> {
|
||||
return this.get<GetMediaOutputDTO>(`/media/${mediaId}`);
|
||||
}
|
||||
|
||||
/** Delete media by ID */
|
||||
deleteMedia(mediaId: string): Promise<DeleteMediaOutputDto> {
|
||||
return this.delete<DeleteMediaOutputDto>(`/media/${mediaId}`);
|
||||
deleteMedia(mediaId: string): Promise<DeleteMediaOutputDTO> {
|
||||
return this.delete<DeleteMediaOutputDTO>(`/media/${mediaId}`);
|
||||
}
|
||||
|
||||
/** Request avatar generation */
|
||||
requestAvatarGeneration(input: RequestAvatarGenerationInputDto): Promise<RequestAvatarGenerationOutputDto> {
|
||||
return this.post<RequestAvatarGenerationOutputDto>('/media/avatar/generate', input);
|
||||
requestAvatarGeneration(input: RequestAvatarGenerationInputDTO): Promise<RequestAvatarGenerationOutputDTO> {
|
||||
return this.post<RequestAvatarGenerationOutputDTO>('/media/avatar/generate', input);
|
||||
}
|
||||
|
||||
/** Get avatar for driver */
|
||||
getAvatar(driverId: string): Promise<GetAvatarOutputDto> {
|
||||
return this.get<GetAvatarOutputDto>(`/media/avatar/${driverId}`);
|
||||
getAvatar(driverId: string): Promise<GetAvatarOutputDTO> {
|
||||
return this.get<GetAvatarOutputDTO>(`/media/avatar/${driverId}`);
|
||||
}
|
||||
|
||||
/** Update avatar for driver */
|
||||
updateAvatar(input: UpdateAvatarInputDto): Promise<UpdateAvatarOutputDto> {
|
||||
return this.put<UpdateAvatarOutputDto>(`/media/avatar/${input.driverId}`, { avatarUrl: input.avatarUrl });
|
||||
updateAvatar(input: UpdateAvatarInputDTO): Promise<UpdateAvatarOutputDTO> {
|
||||
return this.put<UpdateAvatarOutputDTO>(`/media/avatar/${input.driverId}`, { avatarUrl: input.avatarUrl });
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
import { BaseApiClient } from '../base/BaseApiClient';
|
||||
import type { PaymentDto, MembershipFeeDto, MemberPaymentDto, PrizeDto, WalletDto, TransactionDto, UpdatePaymentStatusInputDTO } from '../types/generated';
|
||||
|
||||
// TODO: Import these types from apps/website/lib/types/generated when available
|
||||
type GetPaymentsOutputDto = { payments: import('../types/generated').PaymentDto[] };
|
||||
// Define missing types that are not fully generated
|
||||
type GetPaymentsOutputDto = { payments: PaymentDto[] };
|
||||
type CreatePaymentInputDto = {
|
||||
type: 'sponsorship' | 'membership_fee';
|
||||
amount: number;
|
||||
@@ -10,15 +11,15 @@ type CreatePaymentInputDto = {
|
||||
leagueId: string;
|
||||
seasonId?: string;
|
||||
};
|
||||
type CreatePaymentOutputDto = { payment: import('../types/generated').PaymentDto };
|
||||
type CreatePaymentOutputDto = { payment: PaymentDto };
|
||||
type GetMembershipFeesOutputDto = {
|
||||
fee: import('../types/generated').MembershipFeeDto | null;
|
||||
payments: import('../types/generated').MemberPaymentDto[]
|
||||
fee: MembershipFeeDto | null;
|
||||
payments: MemberPaymentDto[]
|
||||
};
|
||||
type GetPrizesOutputDto = { prizes: import('../types/generated').PrizeDto[] };
|
||||
type GetPrizesOutputDto = { prizes: PrizeDto[] };
|
||||
type GetWalletOutputDto = {
|
||||
wallet: import('../types/generated').WalletDto;
|
||||
transactions: import('../types/generated').TransactionDto[]
|
||||
wallet: WalletDto;
|
||||
transactions: TransactionDto[]
|
||||
};
|
||||
type ProcessWalletTransactionInputDto = {
|
||||
leagueId: string;
|
||||
@@ -29,8 +30,8 @@ type ProcessWalletTransactionInputDto = {
|
||||
referenceType?: 'sponsorship' | 'membership_fee' | 'prize';
|
||||
};
|
||||
type ProcessWalletTransactionOutputDto = {
|
||||
wallet: import('../types/generated').WalletDto;
|
||||
transaction: import('../types/generated').TransactionDto
|
||||
wallet: WalletDto;
|
||||
transaction: TransactionDto
|
||||
};
|
||||
type UpdateMemberPaymentInputDto = {
|
||||
feeId: string;
|
||||
@@ -38,8 +39,33 @@ type UpdateMemberPaymentInputDto = {
|
||||
status?: 'pending' | 'paid' | 'overdue';
|
||||
paidAt?: Date | string;
|
||||
};
|
||||
type UpdateMemberPaymentOutputDto = { payment: import('../types/generated').MemberPaymentDto };
|
||||
type GetWalletTransactionsOutputDto = { transactions: import('../types/generated').TransactionDto[] };
|
||||
type UpdateMemberPaymentOutputDto = { payment: MemberPaymentDto };
|
||||
type GetWalletTransactionsOutputDto = { transactions: TransactionDto[] };
|
||||
type UpdatePaymentStatusOutputDto = { payment: PaymentDto };
|
||||
type UpsertMembershipFeeInputDto = {
|
||||
leagueId: string;
|
||||
seasonId?: string;
|
||||
type: 'season' | 'monthly' | 'per_race';
|
||||
amount: number;
|
||||
};
|
||||
type UpsertMembershipFeeOutputDto = { fee: MembershipFeeDto };
|
||||
type CreatePrizeInputDto = {
|
||||
leagueId: string;
|
||||
seasonId: string;
|
||||
position: number;
|
||||
name: string;
|
||||
amount: number;
|
||||
type: 'cash' | 'merchandise' | 'other';
|
||||
description?: string;
|
||||
};
|
||||
type CreatePrizeOutputDto = { prize: PrizeDto };
|
||||
type AwardPrizeInputDto = {
|
||||
prizeId: string;
|
||||
driverId: string;
|
||||
};
|
||||
type AwardPrizeOutputDto = { prize: PrizeDto };
|
||||
type DeletePrizeInputDto = { prizeId: string };
|
||||
type DeletePrizeOutputDto = { success: boolean };
|
||||
|
||||
/**
|
||||
* Payments API Client
|
||||
@@ -48,12 +74,14 @@ type GetWalletTransactionsOutputDto = { transactions: import('../types/generated
|
||||
*/
|
||||
export class PaymentsApiClient extends BaseApiClient {
|
||||
/** Get payments */
|
||||
getPayments(leagueId?: string, driverId?: string): Promise<GetPaymentsOutputDto> {
|
||||
getPayments(query?: { leagueId?: string; payerId?: string; type?: 'sponsorship' | 'membership_fee'; status?: 'pending' | 'completed' | 'failed' | 'refunded' }): Promise<GetPaymentsOutputDto> {
|
||||
const params = new URLSearchParams();
|
||||
if (leagueId) params.append('leagueId', leagueId);
|
||||
if (driverId) params.append('driverId', driverId);
|
||||
const query = params.toString();
|
||||
return this.get<GetPaymentsOutputDto>(`/payments${query ? `?${query}` : ''}`);
|
||||
if (query?.leagueId) params.append('leagueId', query.leagueId);
|
||||
if (query?.payerId) params.append('payerId', query.payerId);
|
||||
if (query?.type) params.append('type', query.type);
|
||||
if (query?.status) params.append('status', query.status);
|
||||
const queryString = params.toString();
|
||||
return this.get<GetPaymentsOutputDto>(`/payments${queryString ? `?${queryString}` : ''}`);
|
||||
}
|
||||
|
||||
/** Create a payment */
|
||||
@@ -62,21 +90,63 @@ export class PaymentsApiClient extends BaseApiClient {
|
||||
}
|
||||
|
||||
/** Get membership fees */
|
||||
getMembershipFees(leagueId: string): Promise<GetMembershipFeesOutputDto> {
|
||||
return this.get<GetMembershipFeesOutputDto>(`/payments/membership-fees?leagueId=${leagueId}`);
|
||||
getMembershipFees(query: { leagueId: string; driverId?: string }): Promise<GetMembershipFeesOutputDto> {
|
||||
const params = new URLSearchParams();
|
||||
params.append('leagueId', query.leagueId);
|
||||
if (query.driverId) params.append('driverId', query.driverId);
|
||||
const queryString = params.toString();
|
||||
return this.get<GetMembershipFeesOutputDto>(`/payments/membership-fees?${queryString}`);
|
||||
}
|
||||
|
||||
/** Get prizes */
|
||||
getPrizes(leagueId?: string, seasonId?: string): Promise<GetPrizesOutputDto> {
|
||||
getPrizes(query?: { leagueId?: string; seasonId?: string }): Promise<GetPrizesOutputDto> {
|
||||
const params = new URLSearchParams();
|
||||
if (leagueId) params.append('leagueId', leagueId);
|
||||
if (seasonId) params.append('seasonId', seasonId);
|
||||
const query = params.toString();
|
||||
return this.get<GetPrizesOutputDto>(`/payments/prizes${query ? `?${query}` : ''}`);
|
||||
if (query?.leagueId) params.append('leagueId', query.leagueId);
|
||||
if (query?.seasonId) params.append('seasonId', query.seasonId);
|
||||
const queryString = params.toString();
|
||||
return this.get<GetPrizesOutputDto>(`/payments/prizes${queryString ? `?${queryString}` : ''}`);
|
||||
}
|
||||
|
||||
/** Get wallet */
|
||||
getWallet(driverId: string): Promise<GetWalletOutputDto> {
|
||||
return this.get<GetWalletOutputDto>(`/payments/wallets?driverId=${driverId}`);
|
||||
getWallet(query?: { leagueId?: string }): Promise<GetWalletOutputDto> {
|
||||
const params = new URLSearchParams();
|
||||
if (query?.leagueId) params.append('leagueId', query.leagueId);
|
||||
const queryString = params.toString();
|
||||
return this.get<GetWalletOutputDto>(`/payments/wallets${queryString ? `?${queryString}` : ''}`);
|
||||
}
|
||||
|
||||
/** Update payment status */
|
||||
updatePaymentStatus(input: UpdatePaymentStatusInputDTO): Promise<UpdatePaymentStatusOutputDto> {
|
||||
return this.patch<UpdatePaymentStatusOutputDto>('/payments/status', input);
|
||||
}
|
||||
|
||||
/** Upsert membership fee */
|
||||
upsertMembershipFee(input: UpsertMembershipFeeInputDto): Promise<UpsertMembershipFeeOutputDto> {
|
||||
return this.post<UpsertMembershipFeeOutputDto>('/payments/membership-fees', input);
|
||||
}
|
||||
|
||||
/** Update member payment */
|
||||
updateMemberPayment(input: UpdateMemberPaymentInputDto): Promise<UpdateMemberPaymentOutputDto> {
|
||||
return this.patch<UpdateMemberPaymentOutputDto>('/payments/membership-fees/member-payment', input);
|
||||
}
|
||||
|
||||
/** Create prize */
|
||||
createPrize(input: CreatePrizeInputDto): Promise<CreatePrizeOutputDto> {
|
||||
return this.post<CreatePrizeOutputDto>('/payments/prizes', input);
|
||||
}
|
||||
|
||||
/** Award prize */
|
||||
awardPrize(input: AwardPrizeInputDto): Promise<AwardPrizeOutputDto> {
|
||||
return this.patch<AwardPrizeOutputDto>('/payments/prizes/award', input);
|
||||
}
|
||||
|
||||
/** Delete prize */
|
||||
deletePrize(prizeId: string): Promise<DeletePrizeOutputDto> {
|
||||
return this.delete<DeletePrizeOutputDto>(`/payments/prizes?prizeId=${prizeId}`);
|
||||
}
|
||||
|
||||
/** Process wallet transaction */
|
||||
processWalletTransaction(input: ProcessWalletTransactionInputDto): Promise<ProcessWalletTransactionOutputDto> {
|
||||
return this.post<ProcessWalletTransactionOutputDto>('/payments/wallets/transactions', input);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import { BaseApiClient } from '../base/BaseApiClient';
|
||||
import { RacePenaltiesDTO } from '../../types/generated/RacePenaltiesDTO';
|
||||
import { ApplyPenaltyCommandDTO } from '../../types/generated/ApplyPenaltyCommandDTO';
|
||||
|
||||
/**
|
||||
* Penalties API Client
|
||||
@@ -7,12 +9,12 @@ import { BaseApiClient } from '../base/BaseApiClient';
|
||||
*/
|
||||
export class PenaltiesApiClient extends BaseApiClient {
|
||||
/** Get penalties for a race */
|
||||
getRacePenalties(raceId: string): Promise<{ penalties: any[] }> {
|
||||
return this.get<{ penalties: any[] }>(`/races/${raceId}/penalties`);
|
||||
getRacePenalties(raceId: string): Promise<RacePenaltiesDTO> {
|
||||
return this.get<RacePenaltiesDTO>(`/races/${raceId}/penalties`);
|
||||
}
|
||||
|
||||
/** Apply a penalty */
|
||||
applyPenalty(input: any): Promise<void> {
|
||||
applyPenalty(input: ApplyPenaltyCommandDTO): Promise<void> {
|
||||
return this.post<void>('/races/penalties/apply', input);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@ import type {
|
||||
LeagueAdminProtestsDTO,
|
||||
ApplyPenaltyCommandDTO,
|
||||
RequestProtestDefenseCommandDTO,
|
||||
} from '../../types';
|
||||
ReviewProtestCommandDTO,
|
||||
} from '../../types/generated';
|
||||
import type { RaceProtestsDTO } from '../../types';
|
||||
|
||||
/**
|
||||
* Protests API Client
|
||||
@@ -32,12 +34,12 @@ export class ProtestsApiClient extends BaseApiClient {
|
||||
}
|
||||
|
||||
/** Review protest */
|
||||
reviewProtest(input: { protestId: string; stewardId: string; decision: string; decisionNotes: string }): Promise<void> {
|
||||
reviewProtest(input: ReviewProtestCommandDTO): Promise<void> {
|
||||
return this.post<void>(`/protests/${input.protestId}/review`, input);
|
||||
}
|
||||
|
||||
/** Get protests for a race */
|
||||
getRaceProtests(raceId: string): Promise<{ protests: any[] }> {
|
||||
return this.get<{ protests: any[] }>(`/races/${raceId}/protests`);
|
||||
getRaceProtests(raceId: string): Promise<RaceProtestsDTO> {
|
||||
return this.get<RaceProtestsDTO>(`/races/${raceId}/protests`);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,34 @@
|
||||
import { BaseApiClient } from '../base/BaseApiClient';
|
||||
import type {
|
||||
RaceStatsDto,
|
||||
RacesPageDataDto,
|
||||
RaceDetailDto,
|
||||
RaceResultsDetailDto,
|
||||
RaceWithSOFDto,
|
||||
RegisterForRaceInputDto,
|
||||
ImportRaceResultsInputDto,
|
||||
ImportRaceResultsSummaryDto,
|
||||
WithdrawFromRaceInputDto,
|
||||
} from '../../dtos';
|
||||
import type { RaceStatsDTO } from '../../types/generated/RaceStatsDTO';
|
||||
import type { RacesPageDataRaceDTO } from '../../types/generated/RacesPageDataRaceDTO';
|
||||
import type { RaceResultsDetailDTO } from '../../types/generated/RaceResultsDetailDTO';
|
||||
import type { RaceWithSOFDTO } from '../../types/generated/RaceWithSOFDTO';
|
||||
import type { RegisterForRaceParamsDTO } from '../../types/generated/RegisterForRaceParamsDTO';
|
||||
import type { ImportRaceResultsDTO } from '../../types/generated/ImportRaceResultsDTO';
|
||||
import type { WithdrawFromRaceParamsDTO } from '../../types/generated/WithdrawFromRaceParamsDTO';
|
||||
import type { RaceDetailRaceDTO } from '../../types/generated/RaceDetailRaceDTO';
|
||||
import type { RaceDetailLeagueDTO } from '../../types/generated/RaceDetailLeagueDTO';
|
||||
import type { RaceDetailEntryDTO } from '../../types/generated/RaceDetailEntryDTO';
|
||||
import type { RaceDetailRegistrationDTO } from '../../types/generated/RaceDetailRegistrationDTO';
|
||||
import type { RaceDetailUserResultDTO } from '../../types/generated/RaceDetailUserResultDTO';
|
||||
|
||||
// Define missing types
|
||||
type RacesPageDataDTO = { races: RacesPageDataRaceDTO[] };
|
||||
type RaceDetailDTO = {
|
||||
race: RaceDetailRaceDTO | null;
|
||||
league: RaceDetailLeagueDTO | null;
|
||||
entryList: RaceDetailEntryDTO[];
|
||||
registration: RaceDetailRegistrationDTO;
|
||||
userResult: RaceDetailUserResultDTO | null;
|
||||
error?: string;
|
||||
};
|
||||
type ImportRaceResultsSummaryDTO = {
|
||||
success: boolean;
|
||||
raceId: string;
|
||||
driversProcessed: number;
|
||||
resultsRecorded: number;
|
||||
errors?: string[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Races API Client
|
||||
@@ -18,42 +37,42 @@ import type {
|
||||
*/
|
||||
export class RacesApiClient extends BaseApiClient {
|
||||
/** Get total number of races */
|
||||
getTotal(): Promise<RaceStatsDto> {
|
||||
return this.get<RaceStatsDto>('/races/total-races');
|
||||
getTotal(): Promise<RaceStatsDTO> {
|
||||
return this.get<RaceStatsDTO>('/races/total-races');
|
||||
}
|
||||
|
||||
/** Get races page data */
|
||||
getPageData(): Promise<RacesPageDataDto> {
|
||||
return this.get<RacesPageDataDto>('/races/page-data');
|
||||
getPageData(): Promise<RacesPageDataDTO> {
|
||||
return this.get<RacesPageDataDTO>('/races/page-data');
|
||||
}
|
||||
|
||||
/** Get race detail */
|
||||
getDetail(raceId: string, driverId: string): Promise<RaceDetailDto> {
|
||||
return this.get<RaceDetailDto>(`/races/${raceId}?driverId=${driverId}`);
|
||||
getDetail(raceId: string, driverId: string): Promise<RaceDetailDTO> {
|
||||
return this.get<RaceDetailDTO>(`/races/${raceId}?driverId=${driverId}`);
|
||||
}
|
||||
|
||||
/** Get race results detail */
|
||||
getResultsDetail(raceId: string): Promise<RaceResultsDetailDto> {
|
||||
return this.get<RaceResultsDetailDto>(`/races/${raceId}/results`);
|
||||
getResultsDetail(raceId: string): Promise<RaceResultsDetailDTO> {
|
||||
return this.get<RaceResultsDetailDTO>(`/races/${raceId}/results`);
|
||||
}
|
||||
|
||||
/** Get race with strength of field */
|
||||
getWithSOF(raceId: string): Promise<RaceWithSOFDto> {
|
||||
return this.get<RaceWithSOFDto>(`/races/${raceId}/sof`);
|
||||
getWithSOF(raceId: string): Promise<RaceWithSOFDTO> {
|
||||
return this.get<RaceWithSOFDTO>(`/races/${raceId}/sof`);
|
||||
}
|
||||
|
||||
/** Register for race */
|
||||
register(raceId: string, input: RegisterForRaceInputDto): Promise<void> {
|
||||
register(raceId: string, input: RegisterForRaceParamsDTO): Promise<void> {
|
||||
return this.post<void>(`/races/${raceId}/register`, input);
|
||||
}
|
||||
|
||||
/** Import race results */
|
||||
importResults(raceId: string, input: ImportRaceResultsInputDto): Promise<ImportRaceResultsSummaryDto> {
|
||||
return this.post<ImportRaceResultsSummaryDto>(`/races/${raceId}/import-results`, input);
|
||||
importResults(raceId: string, input: ImportRaceResultsDTO): Promise<ImportRaceResultsSummaryDTO> {
|
||||
return this.post<ImportRaceResultsSummaryDTO>(`/races/${raceId}/import-results`, input);
|
||||
}
|
||||
|
||||
/** Withdraw from race */
|
||||
withdraw(raceId: string, input: WithdrawFromRaceInputDto): Promise<void> {
|
||||
withdraw(raceId: string, input: WithdrawFromRaceParamsDTO): Promise<void> {
|
||||
return this.post<void>(`/races/${raceId}/withdraw`, input);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,15 @@ import { BaseApiClient } from '../base/BaseApiClient';
|
||||
import type { CreateSponsorInputDTO } from '../../types/generated/CreateSponsorInputDTO';
|
||||
import type { SponsorDashboardDTO } from '../../types/generated/SponsorDashboardDTO';
|
||||
import type { SponsorSponsorshipsDTO } from '../../types/generated/SponsorSponsorshipsDTO';
|
||||
import type { GetPendingSponsorshipRequestsOutputDTO } from '../../types/generated/GetPendingSponsorshipRequestsOutputDTO';
|
||||
import type { AcceptSponsorshipRequestInputDTO } from '../../types/generated/AcceptSponsorshipRequestInputDTO';
|
||||
import type { RejectSponsorshipRequestInputDTO } from '../../types/generated/RejectSponsorshipRequestInputDTO';
|
||||
import type { GetSponsorOutputDTO } from '../../types/generated/GetSponsorOutputDTO';
|
||||
import type { SponsorDTO } from '../../types/generated/SponsorDTO';
|
||||
|
||||
// TODO: Move these types to apps/website/lib/types/generated when available
|
||||
// Types that are not yet generated
|
||||
export type CreateSponsorOutputDto = { id: string; name: string };
|
||||
export type GetEntitySponsorshipPricingResultDto = { pricing: Array<{ entityType: string; price: number }> };
|
||||
export type SponsorDTO = { id: string; name: string; logoUrl?: string; websiteUrl?: string };
|
||||
export type GetSponsorsOutputDto = { sponsors: SponsorDTO[] };
|
||||
|
||||
/**
|
||||
@@ -41,22 +45,22 @@ export class SponsorsApiClient extends BaseApiClient {
|
||||
}
|
||||
|
||||
/** Get sponsor by ID */
|
||||
getSponsor(sponsorId: string): Promise<SponsorDTO | null> {
|
||||
return this.get<SponsorDTO | null>(`/sponsors/${sponsorId}`);
|
||||
getSponsor(sponsorId: string): Promise<GetSponsorOutputDTO | null> {
|
||||
return this.get<GetSponsorOutputDTO | null>(`/sponsors/${sponsorId}`);
|
||||
}
|
||||
|
||||
/** Get pending sponsorship requests for an entity */
|
||||
getPendingSponsorshipRequests(params: { entityType: string; entityId: string }): Promise<{ requests: any[] }> {
|
||||
return this.get<{ requests: any[] }>(`/sponsors/requests?entityType=${params.entityType}&entityId=${params.entityId}`);
|
||||
getPendingSponsorshipRequests(params: { entityType: string; entityId: string }): Promise<GetPendingSponsorshipRequestsOutputDTO> {
|
||||
return this.get<GetPendingSponsorshipRequestsOutputDTO>(`/sponsors/requests?entityType=${params.entityType}&entityId=${params.entityId}`);
|
||||
}
|
||||
|
||||
/** Accept a sponsorship request */
|
||||
acceptSponsorshipRequest(requestId: string, respondedBy: string): Promise<void> {
|
||||
return this.post(`/sponsors/requests/${requestId}/accept`, { respondedBy });
|
||||
acceptSponsorshipRequest(requestId: string, input: AcceptSponsorshipRequestInputDTO): Promise<void> {
|
||||
return this.post(`/sponsors/requests/${requestId}/accept`, input);
|
||||
}
|
||||
|
||||
/** Reject a sponsorship request */
|
||||
rejectSponsorshipRequest(requestId: string, respondedBy: string, reason?: string): Promise<void> {
|
||||
return this.post(`/sponsors/requests/${requestId}/reject`, { respondedBy, reason });
|
||||
rejectSponsorshipRequest(requestId: string, input: RejectSponsorshipRequestInputDTO): Promise<void> {
|
||||
return this.post(`/sponsors/requests/${requestId}/reject`, input);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
import { LeagueMemberDTO } from '@/lib/types/generated/LeagueMemberDTO';
|
||||
import type {
|
||||
AllTeamsDto,
|
||||
CreateTeamInputDto,
|
||||
CreateTeamOutputDto,
|
||||
DriverTeamDto,
|
||||
TeamDetailsDto,
|
||||
TeamJoinRequestsDto,
|
||||
TeamMembersDto,
|
||||
UpdateTeamInputDto,
|
||||
UpdateTeamOutputDto,
|
||||
} from '../../dtos';
|
||||
import type { GetAllTeamsOutputDTO } from '@/lib/types/generated/GetAllTeamsOutputDTO';
|
||||
import type { GetTeamDetailsOutputDTO } from '@/lib/types/generated/GetTeamDetailsOutputDTO';
|
||||
import type { GetTeamMembersOutputDTO } from '@/lib/types/generated/GetTeamMembersOutputDTO';
|
||||
import type { GetTeamJoinRequestsOutputDTO } from '@/lib/types/generated/GetTeamJoinRequestsOutputDTO';
|
||||
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 { BaseApiClient } from '../base/BaseApiClient';
|
||||
|
||||
/**
|
||||
@@ -19,42 +18,42 @@ import { BaseApiClient } from '../base/BaseApiClient';
|
||||
*/
|
||||
export class TeamsApiClient extends BaseApiClient {
|
||||
/** Get all teams */
|
||||
getAll(): Promise<AllTeamsDto> {
|
||||
return this.get<AllTeamsDto>('/teams/all');
|
||||
getAll(): Promise<GetAllTeamsOutputDTO> {
|
||||
return this.get<GetAllTeamsOutputDTO>('/teams/all');
|
||||
}
|
||||
|
||||
/** Get team details */
|
||||
getDetails(teamId: string): Promise<TeamDetailsDto | null> {
|
||||
return this.get<TeamDetailsDto | null>(`/teams/${teamId}`);
|
||||
getDetails(teamId: string): Promise<GetTeamDetailsOutputDTO | null> {
|
||||
return this.get<GetTeamDetailsOutputDTO | null>(`/teams/${teamId}`);
|
||||
}
|
||||
|
||||
/** Get team members */
|
||||
getMembers(teamId: string): Promise<TeamMembersDto> {
|
||||
return this.get<TeamMembersDto>(`/teams/${teamId}/members`);
|
||||
getMembers(teamId: string): Promise<GetTeamMembersOutputDTO> {
|
||||
return this.get<GetTeamMembersOutputDTO>(`/teams/${teamId}/members`);
|
||||
}
|
||||
|
||||
/** Get team join requests */
|
||||
getJoinRequests(teamId: string): Promise<TeamJoinRequestsDto> {
|
||||
return this.get<TeamJoinRequestsDto>(`/teams/${teamId}/join-requests`);
|
||||
getJoinRequests(teamId: string): Promise<GetTeamJoinRequestsOutputDTO> {
|
||||
return this.get<GetTeamJoinRequestsOutputDTO>(`/teams/${teamId}/join-requests`);
|
||||
}
|
||||
|
||||
/** Create a new team */
|
||||
create(input: CreateTeamInputDto): Promise<CreateTeamOutputDto> {
|
||||
return this.post<CreateTeamOutputDto>('/teams', input);
|
||||
create(input: CreateTeamInputDTO): Promise<CreateTeamOutputDTO> {
|
||||
return this.post<CreateTeamOutputDTO>('/teams', input);
|
||||
}
|
||||
|
||||
/** Update team */
|
||||
update(teamId: string, input: UpdateTeamInputDto): Promise<UpdateTeamOutputDto> {
|
||||
return this.patch<UpdateTeamOutputDto>(`/teams/${teamId}`, input);
|
||||
update(teamId: string, input: UpdateTeamInputDTO): Promise<UpdateTeamOutputDTO> {
|
||||
return this.patch<UpdateTeamOutputDTO>(`/teams/${teamId}`, input);
|
||||
}
|
||||
|
||||
/** Get driver's team */
|
||||
getDriverTeam(driverId: string): Promise<DriverTeamDto | null> {
|
||||
return this.get<DriverTeamDto | null>(`/teams/driver/${driverId}`);
|
||||
getDriverTeam(driverId: string): Promise<GetDriverTeamOutputDTO | null> {
|
||||
return this.get<GetDriverTeamOutputDTO | null>(`/teams/driver/${driverId}`);
|
||||
}
|
||||
|
||||
/** Get membership for a driver in a team */
|
||||
getMembership(teamId: string, driverId: string): Promise<LeagueMemberDTO | null> {
|
||||
return this.get<LeagueMemberDTO | null>(`/teams/${teamId}/members/${driverId}`);
|
||||
getMembership(teamId: string, driverId: string): Promise<GetTeamMembershipOutputDTO | null> {
|
||||
return this.get<GetTeamMembershipOutputDTO | null>(`/teams/${teamId}/members/${driverId}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user