website refactor

This commit is contained in:
2026-01-14 10:51:05 +01:00
parent 4522d41aef
commit 0d89ad027e
291 changed files with 6887 additions and 3685 deletions

View File

@@ -1,13 +1,75 @@
/**
* Media Service - DTO Only
* MediaService
*
* Returns raw API DTOs. No ViewModels or UX logic.
* All client-side presentation logic must be handled by hooks/components.
* Frontend orchestration service for media operations.
* Handles binary media fetching with proper error handling.
*/
export class MediaService {
constructor(private readonly apiClient: any) {}
async getMediaById(mediaId: string): Promise<any> {
return { id: mediaId, url: '' };
import { Result } from '@/lib/contracts/Result';
import { Service, DomainError } from '@/lib/contracts/services/Service';
import { MediaAdapter } from '@/lib/adapters/MediaAdapter';
import { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
/**
* MediaService
*
* Handles media asset fetching with proper error handling.
* Creates its own dependencies and orchestrates adapter calls.
*/
export class MediaService implements Service {
private adapter: MediaAdapter;
constructor() {
// Service creates its own dependencies
this.adapter = new MediaAdapter();
}
/**
* Get avatar for a driver
*/
async getAvatar(driverId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
return this.adapter.fetchMedia(`/media/avatar/${driverId}`);
}
/**
* Get category icon
*/
async getCategoryIcon(categoryId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
return this.adapter.fetchMedia(`/media/categories/${categoryId}/icon`);
}
/**
* Get league cover
*/
async getLeagueCover(leagueId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
return this.adapter.fetchMedia(`/media/leagues/${leagueId}/cover`);
}
/**
* Get league logo
*/
async getLeagueLogo(leagueId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
return this.adapter.fetchMedia(`/media/leagues/${leagueId}/logo`);
}
/**
* Get sponsor logo
*/
async getSponsorLogo(sponsorId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
return this.adapter.fetchMedia(`/media/sponsors/${sponsorId}/logo`);
}
/**
* Get team logo
*/
async getTeamLogo(teamId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
return this.adapter.fetchMedia(`/media/teams/${teamId}/logo`);
}
/**
* Get track image
*/
async getTrackImage(trackId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
return this.adapter.fetchMedia(`/media/tracks/${trackId}/image`);
}
}