view data fixes
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 7m11s
Contract Testing / contract-snapshot (pull_request) Has been skipped

This commit is contained in:
2026-01-24 23:29:55 +01:00
parent c1750a33dd
commit 1b0a1f4aee
134 changed files with 10380 additions and 415 deletions

View File

@@ -1,32 +1,39 @@
import { Result } from '@/lib/contracts/Result';
import type { Mutation } from '@/lib/contracts/mutations/Mutation';
import type { DomainError } from '@/lib/contracts/services/Service';
import { DriverProfileUpdateService } from '@/lib/services/drivers/DriverProfileUpdateService';
import type { Mutation } from '@/lib/contracts/mutations/Mutation';
import { Result } from '@/lib/contracts/Result';
export interface UpdateDriverProfileCommand {
bio?: string;
country?: string;
}
type UpdateDriverProfileMutationError = 'DRIVER_PROFILE_UPDATE_FAILED';
const mapToMutationError = (_: DomainError): UpdateDriverProfileMutationError => {
return 'DRIVER_PROFILE_UPDATE_FAILED';
};
export type UpdateDriverProfileMutationError = 'DRIVER_PROFILE_UPDATE_FAILED';
export class UpdateDriverProfileMutation
implements Mutation<UpdateDriverProfileCommand, void, UpdateDriverProfileMutationError>
{
private readonly service: DriverProfileUpdateService;
constructor() {
this.service = new DriverProfileUpdateService();
}
async execute(
command: UpdateDriverProfileCommand,
): Promise<Result<void, UpdateDriverProfileMutationError>> {
const service = new DriverProfileUpdateService();
const result = await service.updateProfile({ bio: command.bio, country: command.country });
try {
const result = await this.service.updateProfile({
bio: command.bio,
country: command.country,
});
if (result.isErr()) {
return Result.err(mapToMutationError(result.getError()));
if (result.isErr()) {
return Result.err('DRIVER_PROFILE_UPDATE_FAILED');
}
return Result.ok(undefined);
} catch (error) {
return Result.err('DRIVER_PROFILE_UPDATE_FAILED');
}
return Result.ok(undefined);
}
}