website refactor
This commit is contained in:
@@ -5,6 +5,7 @@ import { DomainError, Service } from '@/lib/contracts/services/Service';
|
||||
import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
|
||||
import { EnhancedErrorReporter } from '@/lib/infrastructure/EnhancedErrorReporter';
|
||||
import { getWebsiteApiBaseUrl } from '@/lib/config/apiBaseUrl';
|
||||
import { isProductionEnvironment } from '@/lib/config/env';
|
||||
|
||||
/**
|
||||
* Team Join Service - ViewModels
|
||||
@@ -21,28 +22,27 @@ export class TeamJoinService implements Service {
|
||||
const errorReporter = new EnhancedErrorReporter(logger, {
|
||||
showUserNotifications: true,
|
||||
logToConsole: true,
|
||||
reportToExternal: process.env.NODE_ENV === 'production',
|
||||
reportToExternal: isProductionEnvironment(),
|
||||
});
|
||||
this.apiClient = new TeamsApiClient(baseUrl, errorReporter, logger);
|
||||
}
|
||||
|
||||
async getJoinRequests(teamId: string, currentDriverId: string, isOwner: boolean): Promise<TeamJoinRequestViewModel[]> {
|
||||
async getJoinRequests(teamId: string, currentDriverId: string, isOwner: boolean): Promise<Result<TeamJoinRequestViewModel[], DomainError>> {
|
||||
try {
|
||||
const result = await this.apiClient.getJoinRequests(teamId);
|
||||
return result.requests.map(request =>
|
||||
return Result.ok(result.requests.map(request =>
|
||||
new TeamJoinRequestViewModel(request, currentDriverId, isOwner)
|
||||
);
|
||||
} catch (error) {
|
||||
// Return empty array on error
|
||||
return [];
|
||||
));
|
||||
} catch (error: any) {
|
||||
return Result.err({ type: 'serverError', message: error.message || 'Failed to fetch join requests' });
|
||||
}
|
||||
}
|
||||
|
||||
async approveJoinRequest(): Promise<void> {
|
||||
throw new Error('Not implemented: API endpoint for approving join requests');
|
||||
async approveJoinRequest(): Promise<Result<void, DomainError>> {
|
||||
return Result.err({ type: 'notImplemented', message: 'Not implemented: API endpoint for approving join requests' });
|
||||
}
|
||||
|
||||
async rejectJoinRequest(): Promise<void> {
|
||||
throw new Error('Not implemented: API endpoint for rejecting join requests');
|
||||
async rejectJoinRequest(): Promise<Result<void, DomainError>> {
|
||||
return Result.err({ type: 'notImplemented', message: 'Not implemented: API endpoint for rejecting join requests' });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user