69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
import { DriversApiClient } from '@/lib/api/drivers/DriversApiClient';
|
|
import type { CompleteOnboardingInputDTO } from '@/lib/types/generated/CompleteOnboardingInputDTO';
|
|
import type { GetDriverOutputDTO } from '@/lib/types/generated/GetDriverOutputDTO';
|
|
import type { CompleteOnboardingOutputDTO } from '@/lib/types/generated/CompleteOnboardingOutputDTO';
|
|
import type { DriverDTO } from '@/lib/types/generated/DriverDTO';
|
|
import type { GetDriverProfileOutputDTO } from '@/lib/types/generated/GetDriverProfileOutputDTO';
|
|
|
|
/**
|
|
* Driver Service - DTO Only
|
|
*
|
|
* Returns raw API DTOs. No ViewModels or UX logic.
|
|
* All client-side presentation logic must be handled by hooks/components.
|
|
*/
|
|
export class DriverService {
|
|
constructor(
|
|
private readonly apiClient: DriversApiClient
|
|
) {}
|
|
|
|
/**
|
|
* Get driver leaderboard (returns DTO)
|
|
*/
|
|
async getDriverLeaderboard() {
|
|
return this.apiClient.getLeaderboard();
|
|
}
|
|
|
|
/**
|
|
* Complete driver onboarding (returns DTO)
|
|
*/
|
|
async completeDriverOnboarding(input: CompleteOnboardingInputDTO): Promise<CompleteOnboardingOutputDTO> {
|
|
return this.apiClient.completeOnboarding(input);
|
|
}
|
|
|
|
/**
|
|
* Get current driver (returns DTO)
|
|
*/
|
|
async getCurrentDriver(): Promise<DriverDTO | null> {
|
|
return this.apiClient.getCurrent();
|
|
}
|
|
|
|
/**
|
|
* Get driver profile (returns DTO)
|
|
*/
|
|
async getDriverProfile(driverId: string): Promise<GetDriverProfileOutputDTO> {
|
|
return this.apiClient.getDriverProfile(driverId);
|
|
}
|
|
|
|
/**
|
|
* Update current driver profile (returns DTO)
|
|
*/
|
|
async updateProfile(updates: { bio?: string; country?: string }): Promise<DriverDTO> {
|
|
return this.apiClient.updateProfile(updates);
|
|
}
|
|
|
|
/**
|
|
* Find driver by ID (returns DTO)
|
|
*/
|
|
async findById(id: string): Promise<GetDriverOutputDTO | null> {
|
|
return this.apiClient.getDriver(id);
|
|
}
|
|
|
|
/**
|
|
* Find multiple drivers by IDs (returns DTOs)
|
|
*/
|
|
async findByIds(ids: string[]): Promise<GetDriverOutputDTO[]> {
|
|
const drivers = await Promise.all(ids.map(id => this.apiClient.getDriver(id)));
|
|
return drivers.filter((d): d is GetDriverOutputDTO => d !== null);
|
|
}
|
|
}
|