fix issues in core
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { UseCase } from '@core/shared/application';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
@@ -23,15 +24,20 @@ export type UpdateDriverProfileErrorCode =
|
||||
* Encapsulates domain entity mutation. Mapping to DTOs is handled by presenters
|
||||
* in the presentation layer through the output port.
|
||||
*/
|
||||
export class UpdateDriverProfileUseCase implements UseCase<UpdateDriverProfileInput, UpdateDriverProfileResult, UpdateDriverProfileErrorCode> {
|
||||
export class UpdateDriverProfileUseCase
|
||||
implements UseCase<UpdateDriverProfileInput, void, UpdateDriverProfileErrorCode>
|
||||
{
|
||||
constructor(
|
||||
private readonly driverRepository: IDriverRepository,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<UpdateDriverProfileResult>,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
input: UpdateDriverProfileInput,
|
||||
): Promise<Result<UpdateDriverProfileResult, ApplicationErrorCode<UpdateDriverProfileErrorCode, { message: string }>>> {
|
||||
): Promise<
|
||||
Result<void, ApplicationErrorCode<UpdateDriverProfileErrorCode, { message: string }>>
|
||||
> {
|
||||
const { driverId, bio, country } = input;
|
||||
|
||||
if ((bio !== undefined && bio.trim().length === 0) || (country !== undefined && country.trim().length === 0)) {
|
||||
@@ -61,7 +67,9 @@ export class UpdateDriverProfileUseCase implements UseCase<UpdateDriverProfileIn
|
||||
|
||||
await this.driverRepository.update(updated);
|
||||
|
||||
return Result.ok(updated);
|
||||
this.output.present(updated);
|
||||
|
||||
return Result.ok(undefined);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : 'Failed to update driver profile';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user