website refactor
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { describe, it, expect, vi, Mocked } from 'vitest';
|
||||
import { DriverRegistrationService } from './DriverRegistrationService';
|
||||
import { DriversApiClient } from '../../api/drivers/DriversApiClient';
|
||||
import { DriverRegistrationStatusViewModel } from '../../view-models/DriverRegistrationStatusViewModel';
|
||||
import { DriversApiClient } from '@/lib/api/drivers/DriversApiClient';
|
||||
import { DriverRegistrationStatusViewModel } from '@/lib/view-models/DriverRegistrationStatusViewModel';
|
||||
|
||||
describe('DriverRegistrationService', () => {
|
||||
let mockApiClient: Mocked<DriversApiClient>;
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import type { DriversApiClient } from '../../api/drivers/DriversApiClient';
|
||||
import { DriverRegistrationStatusViewModel } from '../../view-models/DriverRegistrationStatusViewModel';
|
||||
|
||||
/**
|
||||
* Driver Registration Service
|
||||
*
|
||||
* Orchestrates driver registration status operations by coordinating API calls and view model creation.
|
||||
* All dependencies are injected via constructor.
|
||||
*/
|
||||
export class DriverRegistrationService {
|
||||
constructor(
|
||||
private readonly apiClient: DriversApiClient
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get driver registration status for a specific race
|
||||
*/
|
||||
async getDriverRegistrationStatus(
|
||||
driverId: string,
|
||||
raceId: string
|
||||
): Promise<DriverRegistrationStatusViewModel> {
|
||||
const dto = await this.apiClient.getRegistrationStatus(driverId, raceId);
|
||||
return new DriverRegistrationStatusViewModel(dto);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { describe, it, expect, vi, Mocked } from 'vitest';
|
||||
import { DriverService } from './DriverService';
|
||||
import { DriversApiClient } from '../../api/drivers/DriversApiClient';
|
||||
import { DriverLeaderboardViewModel } from '../../view-models/DriverLeaderboardViewModel';
|
||||
import { DriverViewModel } from '../../view-models/DriverViewModel';
|
||||
import { CompleteOnboardingViewModel } from '../../view-models/CompleteOnboardingViewModel';
|
||||
import { DriversApiClient } from '@/lib/api/drivers/DriversApiClient';
|
||||
import { DriverLeaderboardViewModel } from '@/lib/view-models/DriverLeaderboardViewModel';
|
||||
import { DriverViewModel } from '@/lib/view-models/DriverViewModel';
|
||||
import { CompleteOnboardingViewModel } from '@/lib/view-models/CompleteOnboardingViewModel';
|
||||
|
||||
describe('DriverService', () => {
|
||||
let mockApiClient: Mocked<DriversApiClient>;
|
||||
|
||||
@@ -41,7 +41,7 @@ export class DriverService {
|
||||
if (!dto) {
|
||||
return null;
|
||||
}
|
||||
return new DriverViewModel({ ...dto, avatarUrl: (dto as any).avatarUrl ?? null });
|
||||
return new DriverViewModel({ ...dto, avatarUrl: dto.avatarUrl ?? null });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,7 @@ export class DriverService {
|
||||
extendedProfile: dto.extendedProfile
|
||||
? {
|
||||
socialHandles: dto.extendedProfile.socialHandles.map((h) => ({
|
||||
platform: h.platform as any,
|
||||
platform: h.platform as 'twitter' | 'youtube' | 'twitch' | 'discord',
|
||||
handle: h.handle,
|
||||
url: h.url,
|
||||
})),
|
||||
@@ -121,8 +121,8 @@ export class DriverService {
|
||||
id: a.id,
|
||||
title: a.title,
|
||||
description: a.description,
|
||||
icon: a.icon as any,
|
||||
rarity: a.rarity as any,
|
||||
icon: a.icon as 'trophy' | 'medal' | 'star' | 'crown' | 'target' | 'zap',
|
||||
rarity: a.rarity as 'common' | 'rare' | 'epic' | 'legendary',
|
||||
earnedAt: a.earnedAt,
|
||||
})),
|
||||
racingStyle: dto.extendedProfile.racingStyle,
|
||||
|
||||
Reference in New Issue
Block a user