code quality
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
import { getWebsiteApiBaseUrl } from '@/lib/config/apiBaseUrl';
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { DomainError } from '@/lib/contracts/services/Service';
|
||||
import { MediaBinaryDTO } from '@/lib/types/generated/MediaBinaryDTO';
|
||||
import { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
||||
|
||||
// TODO why is this an adapter?
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ViewDataBuilder } from '../../contracts/builders/ViewDataBuilder';
|
||||
import type { DashboardStatsResponseDto } from '../../types/generated/DashboardStatsResponseDTO';
|
||||
import type { DashboardStatsResponseDTO } from '../../types/generated/DashboardStatsResponseDTO';
|
||||
import type { AdminDashboardViewData } from '../../view-data/AdminDashboardViewData';
|
||||
|
||||
export class AdminDashboardViewDataBuilder {
|
||||
@@ -9,7 +9,7 @@ export class AdminDashboardViewDataBuilder {
|
||||
* @param apiDto - The DTO from the service
|
||||
* @returns ViewData for the admin dashboard
|
||||
*/
|
||||
public static build(apiDto: DashboardStatsResponseDto): AdminDashboardViewData {
|
||||
public static build(apiDto: DashboardStatsResponseDTO): AdminDashboardViewData {
|
||||
return {
|
||||
stats: {
|
||||
totalUsers: apiDto.totalUsers,
|
||||
@@ -24,4 +24,4 @@ export class AdminDashboardViewDataBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
AdminDashboardViewDataBuilder satisfies ViewDataBuilder<DashboardStatsResponseDto, AdminDashboardViewData>;
|
||||
AdminDashboardViewDataBuilder satisfies ViewDataBuilder<DashboardStatsResponseDTO, AdminDashboardViewData>;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import type { ForgotPasswordPageDTO } from '@/lib/types/generated/ForgotPasswordPageDTO';
|
||||
import type { ForgotPasswordPageDTO } from '@/lib/services/auth/types/ForgotPasswordPageDTO';
|
||||
import type { ForgotPasswordViewData } from '@/lib/view-data/ForgotPasswordViewData';
|
||||
|
||||
export class ForgotPasswordViewDataBuilder {
|
||||
public static build(apiDto: ForgotPasswordPageDTO): ForgotPasswordViewData {
|
||||
return {
|
||||
returnTo: apiDto.returnTo,
|
||||
returnTo: apiDto.returnTo || '',
|
||||
showSuccess: false,
|
||||
formState: {
|
||||
fields: {
|
||||
|
||||
@@ -5,9 +5,11 @@ import { HealthAlertFormatter } from '@/lib/formatters/HealthAlertFormatter';
|
||||
import { HealthComponentFormatter } from '@/lib/formatters/HealthComponentFormatter';
|
||||
import { HealthMetricFormatter } from '@/lib/formatters/HealthMetricFormatter';
|
||||
import { HealthStatusFormatter } from '@/lib/formatters/HealthStatusFormatter';
|
||||
import type { HealthDTO } from '@/lib/types/generated/HealthDTO';
|
||||
import type { HealthDTO } from '../../../../api/src/domain/health/HealthDTO';
|
||||
import type { HealthAlert, HealthComponent, HealthMetrics, HealthStatus, HealthViewData } from '@/lib/view-data/HealthViewData';
|
||||
|
||||
export type { HealthDTO };
|
||||
|
||||
export class HealthViewDataBuilder {
|
||||
public static build(apiDto: HealthDTO): HealthViewData {
|
||||
const now = new Date();
|
||||
@@ -38,7 +40,7 @@ export class HealthViewDataBuilder {
|
||||
};
|
||||
|
||||
// Build components
|
||||
const components: HealthComponent[] = (apiDto.components || []).map((component) => ({
|
||||
const components: HealthComponent[] = (apiDto.components || []).map((component: { name: string; status: 'ok' | 'degraded' | 'error' | 'unknown'; lastCheck?: string; responseTime?: number; errorRate?: number; }) => ({
|
||||
name: component.name,
|
||||
status: component.status,
|
||||
statusLabel: HealthComponentFormatter.formatStatusLabel(component.status),
|
||||
@@ -51,7 +53,7 @@ export class HealthViewDataBuilder {
|
||||
}));
|
||||
|
||||
// Build alerts
|
||||
const alerts: HealthAlert[] = (apiDto.alerts || []).map((alert) => ({
|
||||
const alerts: HealthAlert[] = (apiDto.alerts || []).map((alert: { id: string; type: 'critical' | 'warning' | 'info'; title: string; message: string; timestamp: string; }) => ({
|
||||
id: alert.id,
|
||||
type: alert.type,
|
||||
title: alert.title,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import type { MediaBinaryDTO } from '@/lib/types/generated/MediaBinaryDTO';
|
||||
import type { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
||||
import type { LeagueCoverViewData } from '@/lib/view-data/LeagueCoverViewData';
|
||||
|
||||
export class LeagueCoverViewDataBuilder {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import type { MediaBinaryDTO } from '@/lib/types/generated/MediaBinaryDTO';
|
||||
import type { LeagueLogoViewData } from '@/lib/view-data/LeagueLogoViewData';
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import type { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
||||
import type { LeagueLogoViewData } from '@/lib/view-data/LeagueLogoViewData';
|
||||
|
||||
export class LeagueLogoViewDataBuilder {
|
||||
public static build(apiDto: MediaBinaryDTO): LeagueLogoViewData {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use client';
|
||||
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import { DateFormatter } from '@/lib/formatters/DateFormatter';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import type { LeagueScheduleViewData } from '@/lib/view-data/LeagueScheduleViewData';
|
||||
import type { LeagueScheduleDTO } from '@/lib/types/generated/LeagueScheduleDTO';
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import type { LeagueScheduleDTO } from '@/lib/types/generated/LeagueScheduleDTO';
|
||||
import type { LeagueScheduleViewData } from '@/lib/view-data/LeagueScheduleViewData';
|
||||
|
||||
export class LeagueScheduleViewDataBuilder {
|
||||
public static build(apiDto: LeagueScheduleDTO, currentDriverId?: string, isAdmin: boolean = false): LeagueScheduleViewData {
|
||||
@@ -24,7 +24,7 @@ export class LeagueScheduleViewDataBuilder {
|
||||
sessionType: race.sessionType || 'race',
|
||||
isPast,
|
||||
isUpcoming,
|
||||
status: race.status || (isPast ? 'completed' : 'scheduled'),
|
||||
status: (race.status || (isPast ? 'completed' : 'scheduled')) as 'scheduled' | 'completed',
|
||||
// Registration info (would come from API in real implementation)
|
||||
isUserRegistered: false,
|
||||
canRegister: isUpcoming,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import type { LeagueSettingsViewData } from '@/lib/view-data/LeagueSettingsViewData';
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import type { LeagueSettingsViewData } from '@/lib/view-data/LeagueSettingsViewData';
|
||||
|
||||
type LeagueSettingsInputDTO = {
|
||||
league: { id: string; name: string; ownerId: string; createdAt: string };
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
'use client';
|
||||
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import { DateFormatter } from '@/lib/formatters/DateFormatter';
|
||||
import { StatusFormatter } from '@/lib/formatters/StatusFormatter';
|
||||
import type { LeagueSponsorshipsApiDto } from '@/lib/types/tbd/LeagueSponsorshipsApiDto';
|
||||
import type { LeagueSponsorshipsViewData } from '@/lib/view-data/LeagueSponsorshipsViewData';
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import type { GetSeasonSponsorshipsOutputDTO } from '@/lib/types/generated/GetSeasonSponsorshipsOutputDTO';
|
||||
|
||||
type LeagueSponsorshipsInputDTO = GetSeasonSponsorshipsOutputDTO & {
|
||||
leagueId: string;
|
||||
league: { id: string; name: string; description: string };
|
||||
sponsorshipSlots: LeagueSponsorshipsViewData['sponsorshipSlots'];
|
||||
}
|
||||
type LeagueSponsorshipsInputDTO = LeagueSponsorshipsApiDto;
|
||||
|
||||
export class LeagueSponsorshipsViewDataBuilder {
|
||||
public static build(apiDto: LeagueSponsorshipsInputDTO): LeagueSponsorshipsViewData {
|
||||
@@ -20,13 +16,13 @@ export class LeagueSponsorshipsViewDataBuilder {
|
||||
onTabChange: () => {},
|
||||
league: apiDto.league,
|
||||
sponsorshipSlots: apiDto.sponsorshipSlots,
|
||||
sponsorshipRequests: apiDto.sponsorships.map(r => ({
|
||||
sponsorshipRequests: apiDto.sponsorshipRequests.map(r => ({
|
||||
id: r.id,
|
||||
slotId: '', // Missing in DTO
|
||||
sponsorId: '', // Missing in DTO
|
||||
sponsorName: '', // Missing in DTO
|
||||
requestedAt: r.createdAt,
|
||||
formattedRequestedAt: DateFormatter.formatShort(r.createdAt),
|
||||
slotId: r.slotId,
|
||||
sponsorId: r.sponsorId,
|
||||
sponsorName: r.sponsorName,
|
||||
requestedAt: r.requestedAt,
|
||||
formattedRequestedAt: DateFormatter.formatShort(r.requestedAt),
|
||||
status: r.status as 'pending' | 'approved' | 'rejected',
|
||||
statusLabel: StatusFormatter.protestStatus(r.status),
|
||||
})),
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use client';
|
||||
|
||||
import type { LeagueStandingsViewData } from '@/lib/view-data/LeagueStandingsViewData';
|
||||
import type { LeagueStandingDTO } from '@/lib/types/generated/LeagueStandingDTO';
|
||||
import type { LeagueMemberDTO } from '@/lib/types/generated/LeagueMemberDTO';
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import type { LeagueMemberDTO } from '@/lib/types/generated/LeagueMemberDTO';
|
||||
import type { LeagueStandingDTO } from '@/lib/types/generated/LeagueStandingDTO';
|
||||
import type { LeagueStandingsViewData } from '@/lib/view-data/LeagueStandingsViewData';
|
||||
|
||||
interface LeagueStandingsApiDto {
|
||||
standings: LeagueStandingDTO[];
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
'use client';
|
||||
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import { NumberFormatter } from '@/lib/formatters/NumberFormatter';
|
||||
import type { GetLeagueWalletOutputDTO } from '@/lib/types/generated/GetLeagueWalletOutputDTO';
|
||||
import type { LeagueWalletViewData } from '@/lib/view-data/LeagueWalletViewData';
|
||||
import type { WalletTransactionViewData } from '@/lib/view-data/WalletTransactionViewData';
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import { NumberFormatter } from '@/lib/formatters/NumberFormatter';
|
||||
|
||||
type LeagueWalletInputDTO = GetLeagueWalletOutputDTO & {
|
||||
leagueId: string;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import type { AllLeaguesWithCapacityAndScoringDTO } from '@/lib/types/generated/AllLeaguesWithCapacityAndScoringDTO';
|
||||
import type { LeaguesViewData } from '@/lib/view-data/LeaguesViewData';
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
|
||||
export class LeaguesViewDataBuilder {
|
||||
public static build(apiDto: AllLeaguesWithCapacityAndScoringDTO): LeaguesViewData {
|
||||
@@ -29,7 +29,7 @@ export class LeaguesViewDataBuilder {
|
||||
scoring: league.scoring ? {
|
||||
gameId: league.scoring.gameId,
|
||||
gameName: league.scoring.gameName,
|
||||
primaryChampionshipType: league.scoring.primaryChampionshipType,
|
||||
primaryChampionshipType: league.scoring.primaryChampionshipType as "driver" | "team" | "nations" | "trophy",
|
||||
scoringPresetId: league.scoring.scoringPresetId,
|
||||
scoringPresetName: league.scoring.scoringPresetName,
|
||||
dropPolicySummary: league.scoring.dropPolicySummary,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import type { LoginPageDTO } from '@/lib/types/generated/LoginPageDTO';
|
||||
import type { LoginViewData } from '@/lib/view-data/LoginViewData';
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import type { LoginPageDTO } from '@/lib/services/auth/types/LoginPageDTO';
|
||||
import type { LoginViewData } from '@/lib/view-data/LoginViewData';
|
||||
|
||||
export class LoginViewDataBuilder {
|
||||
public static build(apiDto: LoginPageDTO): LoginViewData {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import type { SponsorLogoViewData } from '@/lib/view-data/SponsorLogoViewData';
|
||||
import { MediaBinaryDTO } from '@/lib/types/generated/MediaBinaryDTO';
|
||||
import { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
||||
import { GetMediaOutputDTO } from '@/lib/types/generated/GetMediaOutputDTO';
|
||||
|
||||
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import type { TeamLogoViewData } from '@/lib/view-data/TeamLogoViewData';
|
||||
import { MediaBinaryDTO } from '@/lib/types/generated/MediaBinaryDTO';
|
||||
import { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
||||
import { GetMediaOutputDTO } from '@/lib/types/generated/GetMediaOutputDTO';
|
||||
|
||||
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Deterministic; side-effect free; no HTTP calls.
|
||||
*/
|
||||
|
||||
import type { MediaBinaryDTO } from '@/lib/types/generated/MediaBinaryDTO';
|
||||
import type { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
||||
import type { TrackImageViewData } from '@/lib/view-data/TrackImageViewData';
|
||||
|
||||
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* ForgotPasswordPageDTO
|
||||
*
|
||||
* DTO for the forgot password page.
|
||||
*/
|
||||
export interface ForgotPasswordPageDTO {
|
||||
returnTo?: string;
|
||||
}
|
||||
9
apps/website/lib/types/MediaBinaryDTO.ts
Normal file
9
apps/website/lib/types/MediaBinaryDTO.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* MediaBinaryDTO
|
||||
*
|
||||
* Represents binary media data fetched from the API.
|
||||
*/
|
||||
export interface MediaBinaryDTO {
|
||||
buffer: ArrayBuffer;
|
||||
contentType: string;
|
||||
}
|
||||
@@ -15,7 +15,7 @@ export interface LeagueScheduleViewData extends ViewData {
|
||||
sessionType: string;
|
||||
isPast: boolean;
|
||||
isUpcoming: boolean;
|
||||
status: string;
|
||||
status: 'scheduled' | 'completed';
|
||||
strengthOfField?: number;
|
||||
isUserRegistered: boolean;
|
||||
canRegister: boolean;
|
||||
|
||||
@@ -8,9 +8,12 @@ export interface StandingEntryViewData {
|
||||
driverId: string;
|
||||
position: number;
|
||||
points: number;
|
||||
totalPoints: number;
|
||||
wins: number;
|
||||
podiums: number;
|
||||
races: number;
|
||||
racesStarted: number;
|
||||
avgFinish: number;
|
||||
leaderPoints: number;
|
||||
nextPoints: number;
|
||||
currentUserId: string;
|
||||
|
||||
Reference in New Issue
Block a user