This commit is contained in:
2025-12-16 21:05:01 +01:00
parent f61e3a4e5a
commit 7532c7ed6d
207 changed files with 7861 additions and 2606 deletions

View File

@@ -1,3 +1,5 @@
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
import type { DriverDTO } from '../dto/DriverDTO';
import { EntityMappers } from '../mappers/EntityMappers';
@@ -15,12 +17,12 @@ export interface UpdateDriverProfileInput {
export class UpdateDriverProfileUseCase {
constructor(private readonly driverRepository: IDriverRepository) {}
async execute(input: UpdateDriverProfileInput): Promise<DriverDTO | null> {
async execute(input: UpdateDriverProfileInput): Promise<Result<DriverDTO, ApplicationErrorCode<'DRIVER_NOT_FOUND'>>> {
const { driverId, bio, country } = input;
const existing = await this.driverRepository.findById(driverId);
if (!existing) {
return null;
return Result.err({ code: 'DRIVER_NOT_FOUND' });
}
const updated = existing.update({
@@ -30,6 +32,6 @@ export class UpdateDriverProfileUseCase {
const persisted = await this.driverRepository.update(updated);
const dto = EntityMappers.toDriverDTO(persisted);
return dto ?? null;
return Result.ok(dto!);
}
}