refactor page to use services
This commit is contained in:
@@ -7,6 +7,8 @@ import { PaymentsApiClient } from '../api/payments/PaymentsApiClient';
|
||||
import { AuthApiClient } from '../api/auth/AuthApiClient';
|
||||
import { AnalyticsApiClient } from '../api/analytics/AnalyticsApiClient';
|
||||
import { MediaApiClient } from '../api/media/MediaApiClient';
|
||||
import { DashboardApiClient } from '../api/dashboard/DashboardApiClient';
|
||||
import { ProtestsApiClient } from '../api/protests/ProtestsApiClient';
|
||||
import { ConsoleErrorReporter } from '../infrastructure/logging/ConsoleErrorReporter';
|
||||
import { ConsoleLogger } from '../infrastructure/logging/ConsoleLogger';
|
||||
|
||||
@@ -19,17 +21,20 @@ import { TeamService } from './teams/TeamService';
|
||||
import { TeamJoinService } from './teams/TeamJoinService';
|
||||
import { LeagueService } from './leagues/LeagueService';
|
||||
import { LeagueMembershipService } from './leagues/LeagueMembershipService';
|
||||
import { LeagueSettingsService } from './leagues/LeagueSettingsService';
|
||||
import { SponsorService } from './sponsors/SponsorService';
|
||||
import { SponsorshipService } from './sponsors/SponsorshipService';
|
||||
import { PaymentService } from './payments/PaymentService';
|
||||
import { AnalyticsService } from './analytics/AnalyticsService';
|
||||
import { DashboardService } from './analytics/DashboardService';
|
||||
import { DashboardService as AnalyticsDashboardService } from './analytics/DashboardService';
|
||||
import { DashboardService } from './dashboard/DashboardService';
|
||||
import { MediaService } from './media/MediaService';
|
||||
import { AvatarService } from './media/AvatarService';
|
||||
import { WalletService } from './payments/WalletService';
|
||||
import { MembershipFeeService } from './payments/MembershipFeeService';
|
||||
import { AuthService } from './auth/AuthService';
|
||||
import { SessionService } from './auth/SessionService';
|
||||
import { ProtestService } from './protests/ProtestService';
|
||||
|
||||
/**
|
||||
* ServiceFactory - Composition root for all services
|
||||
@@ -52,6 +57,8 @@ export class ServiceFactory {
|
||||
auth: AuthApiClient;
|
||||
analytics: AnalyticsApiClient;
|
||||
media: MediaApiClient;
|
||||
dashboard: DashboardApiClient;
|
||||
protests: ProtestsApiClient;
|
||||
};
|
||||
|
||||
constructor(baseUrl: string) {
|
||||
@@ -66,6 +73,8 @@ export class ServiceFactory {
|
||||
auth: new AuthApiClient(baseUrl, this.errorReporter, this.logger),
|
||||
analytics: new AnalyticsApiClient(baseUrl, this.errorReporter, this.logger),
|
||||
media: new MediaApiClient(baseUrl, this.errorReporter, this.logger),
|
||||
dashboard: new DashboardApiClient(baseUrl, this.errorReporter, this.logger),
|
||||
protests: new ProtestsApiClient(baseUrl, this.errorReporter, this.logger),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -115,15 +124,22 @@ export class ServiceFactory {
|
||||
* Create LeagueService instance
|
||||
*/
|
||||
createLeagueService(): LeagueService {
|
||||
return new LeagueService(this.apiClients.leagues);
|
||||
return new LeagueService(this.apiClients.leagues, this.apiClients.drivers, this.apiClients.sponsors, this.apiClients.races);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create LeagueMembershipService instance
|
||||
*/
|
||||
createLeagueMembershipService(): LeagueMembershipService {
|
||||
return new LeagueMembershipService(this.apiClients.leagues);
|
||||
}
|
||||
* Create LeagueMembershipService instance
|
||||
*/
|
||||
createLeagueMembershipService(): LeagueMembershipService {
|
||||
return new LeagueMembershipService(this.apiClients.leagues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create LeagueSettingsService instance
|
||||
*/
|
||||
createLeagueSettingsService(): LeagueSettingsService {
|
||||
return new LeagueSettingsService(this.apiClients.leagues, this.apiClients.drivers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create SponsorService instance
|
||||
@@ -154,11 +170,18 @@ export class ServiceFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create DashboardService instance
|
||||
*/
|
||||
createDashboardService(): DashboardService {
|
||||
return new DashboardService(this.apiClients.analytics);
|
||||
}
|
||||
* Create Analytics DashboardService instance
|
||||
*/
|
||||
createAnalyticsDashboardService(): AnalyticsDashboardService {
|
||||
return new AnalyticsDashboardService(this.apiClients.analytics);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create DashboardService instance
|
||||
*/
|
||||
createDashboardService(): DashboardService {
|
||||
return new DashboardService(this.apiClients.dashboard);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create MediaService instance
|
||||
@@ -201,4 +224,11 @@ export class ServiceFactory {
|
||||
createSessionService(): SessionService {
|
||||
return new SessionService(this.apiClients.auth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create ProtestService instance
|
||||
*/
|
||||
createProtestService(): ProtestService {
|
||||
return new ProtestService(this.apiClients.protests);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user