website refactor

This commit is contained in:
2026-01-14 10:51:05 +01:00
parent 4522d41aef
commit 0d89ad027e
291 changed files with 6887 additions and 3685 deletions

View File

@@ -5,24 +5,15 @@ import { Result } from '@/lib/contracts/Result';
import type { Service } from '@/lib/contracts/services/Service';
import { EnhancedErrorReporter } from '@/lib/infrastructure/EnhancedErrorReporter';
import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
import type { GetPendingSponsorshipRequestsOutputDTO } from '@/lib/types/generated/GetPendingSponsorshipRequestsOutputDTO';
import type { AcceptSponsorshipRequestInputDTO } from '@/lib/types/generated/AcceptSponsorshipRequestInputDTO';
import type { RejectSponsorshipRequestInputDTO } from '@/lib/types/generated/RejectSponsorshipRequestInputDTO';
export interface AcceptSponsorshipRequestCommand {
requestId: string;
actorDriverId: string;
interface GetPendingRequestsInput {
entityType: string;
entityId: string;
}
export interface RejectSponsorshipRequestCommand {
requestId: string;
actorDriverId: string;
reason: string | null;
}
export type AcceptSponsorshipRequestServiceError =
| 'ACCEPT_SPONSORSHIP_REQUEST_FAILED';
export type RejectSponsorshipRequestServiceError =
| 'REJECT_SPONSORSHIP_REQUEST_FAILED';
export class SponsorshipRequestsService implements Service {
private readonly client: SponsorsApiClient;
@@ -38,13 +29,29 @@ export class SponsorshipRequestsService implements Service {
this.client = new SponsorsApiClient(baseUrl, errorReporter, logger);
}
async acceptRequest(
command: AcceptSponsorshipRequestCommand,
): Promise<Result<void, AcceptSponsorshipRequestServiceError>> {
async getPendingRequests(
input: GetPendingRequestsInput,
): Promise<Result<GetPendingSponsorshipRequestsOutputDTO, 'GET_PENDING_REQUESTS_FAILED'>> {
try {
await this.client.acceptSponsorshipRequest(command.requestId, {
actorDriverId: command.actorDriverId,
} as any);
const result = await this.client.getPendingSponsorshipRequests({
entityType: input.entityType,
entityId: input.entityId,
});
return Result.ok(result);
} catch {
return Result.err('GET_PENDING_REQUESTS_FAILED');
}
}
async acceptRequest(
command: { requestId: string; actorDriverId: string },
): Promise<Result<void, 'ACCEPT_SPONSORSHIP_REQUEST_FAILED'>> {
try {
const input: AcceptSponsorshipRequestInputDTO = {
respondedBy: command.actorDriverId,
};
await this.client.acceptSponsorshipRequest(command.requestId, input);
return Result.ok(undefined);
} catch {
@@ -53,13 +60,14 @@ export class SponsorshipRequestsService implements Service {
}
async rejectRequest(
command: RejectSponsorshipRequestCommand,
): Promise<Result<void, RejectSponsorshipRequestServiceError>> {
command: { requestId: string; actorDriverId: string; reason: string | null },
): Promise<Result<void, 'REJECT_SPONSORSHIP_REQUEST_FAILED'>> {
try {
await this.client.rejectSponsorshipRequest(command.requestId, {
actorDriverId: command.actorDriverId,
reason: command.reason ?? undefined,
} as any);
const input: RejectSponsorshipRequestInputDTO = {
respondedBy: command.actorDriverId,
reason: command.reason || undefined,
};
await this.client.rejectSponsorshipRequest(command.requestId, input);
return Result.ok(undefined);
} catch {