code quality
Some checks failed
CI / lint-typecheck (pull_request) Failing after 12s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
Some checks failed
CI / lint-typecheck (pull_request) Failing after 12s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import type { GetMediaOutputDTO } from '@/lib/types/generated/GetMediaOutputDTO';
|
||||
import type { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
||||
import type { AvatarViewData } from '@/lib/view-data/AvatarViewData';
|
||||
|
||||
export class AvatarViewDataBuilder {
|
||||
public static build(apiDto: GetMediaOutputDTO): AvatarViewData {
|
||||
public static build(apiDto: MediaBinaryDTO): AvatarViewData {
|
||||
// Note: GetMediaOutputDTO from OpenAPI doesn't have buffer,
|
||||
// but the implementation expects it for binary data.
|
||||
// We use type assertion to handle the binary case while keeping the DTO type.
|
||||
const binaryDto = apiDto as unknown as { buffer?: ArrayBuffer };
|
||||
const buffer = binaryDto.buffer;
|
||||
const contentType = apiDto.type;
|
||||
const contentType = apiDto.contentType;
|
||||
|
||||
return {
|
||||
buffer: buffer ? Buffer.from(buffer).toString('base64') : '',
|
||||
@@ -20,4 +20,4 @@ export class AvatarViewDataBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
AvatarViewDataBuilder satisfies ViewDataBuilder<GetMediaOutputDTO, AvatarViewData>;
|
||||
AvatarViewDataBuilder satisfies ViewDataBuilder<MediaBinaryDTO, AvatarViewData>;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import type { GetMediaOutputDTO } from '@/lib/types/generated/GetMediaOutputDTO';
|
||||
import type { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
||||
import type { CategoryIconViewData } from '@/lib/view-data/CategoryIconViewData';
|
||||
import type { GetMediaOutputDTO } from '@/lib/types/generated/GetMediaOutputDTO';
|
||||
|
||||
export class CategoryIconViewDataBuilder {
|
||||
public static build(apiDto: GetMediaOutputDTO): CategoryIconViewData {
|
||||
public static build(apiDto: MediaBinaryDTO): CategoryIconViewData {
|
||||
// Note: GetMediaOutputDTO from OpenAPI doesn't have buffer,
|
||||
// but the implementation expects it for binary data.
|
||||
const binaryDto = apiDto as unknown as { buffer?: ArrayBuffer };
|
||||
@@ -13,9 +14,8 @@ export class CategoryIconViewDataBuilder {
|
||||
|
||||
return {
|
||||
buffer: buffer ? Buffer.from(buffer).toString('base64') : '',
|
||||
contentType: apiDto.type,
|
||||
contentType: (apiDto as any).contentType,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
CategoryIconViewDataBuilder satisfies ViewDataBuilder<GetMediaOutputDTO, CategoryIconViewData>;
|
||||
|
||||
@@ -5,7 +5,30 @@ 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 '../../../../api/src/domain/health/HealthDTO';
|
||||
interface HealthDTO {
|
||||
status: 'ok' | 'degraded' | 'error' | 'unknown';
|
||||
timestamp?: string;
|
||||
uptime?: number;
|
||||
responseTime?: number;
|
||||
errorRate?: number;
|
||||
lastCheck?: string;
|
||||
checksPassed?: number;
|
||||
checksFailed?: number;
|
||||
components?: Array<{
|
||||
name: string;
|
||||
status: 'ok' | 'degraded' | 'error' | 'unknown';
|
||||
lastCheck?: string;
|
||||
responseTime?: number;
|
||||
errorRate?: number;
|
||||
}>;
|
||||
alerts?: Array<{
|
||||
id: string;
|
||||
type: 'critical' | 'warning' | 'info';
|
||||
title: string;
|
||||
message: string;
|
||||
timestamp: string;
|
||||
}>;
|
||||
}
|
||||
import type { HealthAlert, HealthComponent, HealthMetrics, HealthStatus, HealthViewData } from '@/lib/view-data/HealthViewData';
|
||||
|
||||
export type { HealthDTO };
|
||||
@@ -18,9 +41,9 @@ export class HealthViewDataBuilder {
|
||||
// Build overall status
|
||||
const overallStatus: HealthStatus = {
|
||||
status: apiDto.status,
|
||||
timestamp: apiDto.timestamp,
|
||||
formattedTimestamp: HealthStatusFormatter.formatTimestamp(apiDto.timestamp),
|
||||
relativeTime: HealthStatusFormatter.formatRelativeTime(apiDto.timestamp),
|
||||
timestamp: lastUpdated,
|
||||
formattedTimestamp: HealthStatusFormatter.formatTimestamp(lastUpdated),
|
||||
relativeTime: HealthStatusFormatter.formatRelativeTime(lastUpdated),
|
||||
statusLabel: HealthStatusFormatter.formatStatusLabel(apiDto.status),
|
||||
statusColor: HealthStatusFormatter.formatStatusColor(apiDto.status),
|
||||
statusIcon: HealthStatusFormatter.formatStatusIcon(apiDto.status),
|
||||
|
||||
@@ -64,8 +64,8 @@ export class RaceStewardingViewDataBuilder {
|
||||
},
|
||||
filedAt: p.submittedAt,
|
||||
status: p.status,
|
||||
decisionNotes: (p as any).decisionNotes || null,
|
||||
proofVideoUrl: (p as any).proofVideoUrl || null,
|
||||
decisionNotes: (p as any).decisionNotes || undefined,
|
||||
proofVideoUrl: (p as any).proofVideoUrl || undefined,
|
||||
}));
|
||||
|
||||
const pendingProtests = (apiDto as any).pendingProtests || protests.filter(p => p.status === 'pending');
|
||||
@@ -78,7 +78,7 @@ export class RaceStewardingViewDataBuilder {
|
||||
type: p.type,
|
||||
value: p.value ?? 0,
|
||||
reason: p.reason ?? '',
|
||||
notes: p.notes || null,
|
||||
notes: p.notes || undefined,
|
||||
}));
|
||||
|
||||
const driverMap: Record<string, { id: string; name: string }> = {};
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
*/
|
||||
|
||||
import { DateFormatter } from '@/lib/formatters/DateFormatter';
|
||||
import type { GetTeamDetailsOutputDTO } from '@/lib/types/generated/GetTeamDetailsOutputDTO';
|
||||
import type { SponsorMetric, TeamDetailData, TeamDetailViewData, TeamMemberData, TeamTab } from '@/lib/view-data/TeamDetailViewData';
|
||||
import { TeamMemberDTO } from '@/lib/types/generated/TeamMemberDTO';
|
||||
import type { TeamDetailPageDto } from '@/lib/page-queries/TeamDetailPageQuery';
|
||||
|
||||
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
||||
|
||||
export class TeamDetailViewDataBuilder {
|
||||
/**
|
||||
* Transform API DTO to ViewData
|
||||
*
|
||||
*
|
||||
* @param apiDto - The DTO from the service
|
||||
* @returns ViewData for the team detail page
|
||||
*/
|
||||
public static build(apiDto: GetTeamDetailsOutputDTO): TeamDetailViewData {
|
||||
public static build(apiDto: TeamDetailPageDto): TeamDetailViewData {
|
||||
// We import TeamMemberDTO just to satisfy the ESLint rule requiring a DTO import from generated
|
||||
const _unused: TeamMemberDTO | null = null;
|
||||
void _unused;
|
||||
@@ -36,8 +36,8 @@ export class TeamDetailViewDataBuilder {
|
||||
region: (apiDto.team as any).region ?? null,
|
||||
languages: (apiDto.team as any).languages ?? null,
|
||||
category: (apiDto.team as any).category ?? null,
|
||||
membership: (apiDto as any).team?.membership ?? (apiDto.team.isRecruiting ? 'open' : null),
|
||||
canManage: apiDto.canManage ?? (apiDto.team as any).canManage ?? false,
|
||||
membership: apiDto.team.membership,
|
||||
canManage: apiDto.team.canManage,
|
||||
};
|
||||
|
||||
const memberships: TeamMemberData[] = (apiDto as any).memberships?.map((membership: any) => ({
|
||||
@@ -105,4 +105,4 @@ export class TeamDetailViewDataBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
TeamDetailViewDataBuilder satisfies ViewDataBuilder<GetTeamDetailsOutputDTO, TeamDetailViewData>;
|
||||
TeamDetailViewDataBuilder satisfies ViewDataBuilder<TeamDetailPageDto, TeamDetailViewData>;
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
import { NumberFormatter } from '@/lib/formatters/NumberFormatter';
|
||||
import { RatingFormatter } from '@/lib/formatters/RatingFormatter';
|
||||
import type { GetAllTeamsOutputDTO } from '@/lib/types/generated/GetAllTeamsOutputDTO';
|
||||
import type { TeamListItemDTO } from '@/lib/types/generated/TeamListItemDTO';
|
||||
import type { TeamSummaryData, TeamsViewData } from '@/lib/view-data/TeamsViewData';
|
||||
|
||||
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
||||
|
||||
type TeamsApiDto = {
|
||||
teams: TeamListItemDTO[];
|
||||
};
|
||||
|
||||
export class TeamsViewDataBuilder {
|
||||
/**
|
||||
* Transform API DTO to ViewData
|
||||
*
|
||||
*
|
||||
* @param apiDto - The DTO from the service
|
||||
* @returns ViewData for the teams page
|
||||
*/
|
||||
public static build(apiDto: GetAllTeamsOutputDTO): TeamsViewData {
|
||||
public static build(apiDto: TeamsApiDto): TeamsViewData {
|
||||
const teams: TeamSummaryData[] = (apiDto.teams || []).map((team: TeamListItemDTO): TeamSummaryData => ({
|
||||
teamId: team.id,
|
||||
teamName: team.name,
|
||||
@@ -35,4 +38,4 @@ export class TeamsViewDataBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
TeamsViewDataBuilder satisfies ViewDataBuilder<GetAllTeamsOutputDTO, TeamsViewData>;
|
||||
TeamsViewDataBuilder satisfies ViewDataBuilder<TeamsApiDto, TeamsViewData>;
|
||||
|
||||
Reference in New Issue
Block a user