import { Result } from '@core/shared/domain/Result';
import type { Driver } from '../../domain/entities/Driver';
import type { DriverRepository } from '../../domain/repositories/DriverRepository';

export type GetDriverInput = {
  driverId: string;
};

export class GetDriverUseCase {
  constructor(private readonly driverRepository: DriverRepository) {}

  async execute(input: GetDriverInput): Promise<Result<Driver | null>> {
    try {
      const driver = await this.driverRepository.findById(input.driverId);
      return Result.ok(driver);
    } catch (error) {
      return Result.err(error instanceof Error ? error : new Error(String(error)));
    }
  }
}
