website refactor
This commit is contained in:
@@ -1,16 +1,28 @@
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { DomainError, Service } from '@/lib/contracts/services/Service';
|
||||
import { injectable, unmanaged } from 'inversify';
|
||||
import { PaymentsApiClient } from '@/lib/api/payments/PaymentsApiClient';
|
||||
import { WalletViewModel } from '@/lib/view-models/WalletViewModel';
|
||||
import { getWebsiteApiBaseUrl } from '@/lib/config/apiBaseUrl';
|
||||
import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
|
||||
import { EnhancedErrorReporter } from '@/lib/infrastructure/EnhancedErrorReporter';
|
||||
import { Service } from '@/lib/contracts/services/Service';
|
||||
|
||||
/**
|
||||
* Wallet Service - DTO Only
|
||||
*
|
||||
* Returns raw API DTOs. No ViewModels or UX logic.
|
||||
* All client-side presentation logic must be handled by hooks/components.
|
||||
*/
|
||||
@injectable()
|
||||
export class WalletService implements Service {
|
||||
constructor() {}
|
||||
private readonly apiClient: PaymentsApiClient;
|
||||
|
||||
async getWalletBalance(_: string): Promise<Result<{ balance: number; currency: string }, DomainError>> {
|
||||
return Result.ok({ balance: 0, currency: 'USD' });
|
||||
constructor(@unmanaged() apiClient?: PaymentsApiClient) {
|
||||
if (apiClient) {
|
||||
this.apiClient = apiClient;
|
||||
} else {
|
||||
const baseUrl = getWebsiteApiBaseUrl();
|
||||
const logger = new ConsoleLogger();
|
||||
const errorReporter = new EnhancedErrorReporter(logger);
|
||||
this.apiClient = new PaymentsApiClient(baseUrl, errorReporter, logger);
|
||||
}
|
||||
}
|
||||
|
||||
async getWallet(leagueId: string): Promise<WalletViewModel> {
|
||||
const data = await this.apiClient.getWallet({ leagueId });
|
||||
return new WalletViewModel({ ...data.wallet, transactions: data.transactions });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user