fix data flow issues
This commit is contained in:
99
core/racing/application/use-cases/GetLeagueWalletUseCase.ts
Normal file
99
core/racing/application/use-cases/GetLeagueWalletUseCase.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
import type { ILeagueWalletRepository } from '../../domain/repositories/ILeagueWalletRepository';
|
||||
import type { ITransactionRepository } from '../../domain/repositories/ITransactionRepository';
|
||||
import type { GetLeagueWalletOutputPort } from '../ports/output/GetLeagueWalletOutputPort';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
|
||||
export interface GetLeagueWalletUseCaseParams {
|
||||
leagueId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use Case for retrieving league wallet information.
|
||||
*/
|
||||
export class GetLeagueWalletUseCase {
|
||||
constructor(
|
||||
private readonly leagueWalletRepository: ILeagueWalletRepository,
|
||||
private readonly transactionRepository: ITransactionRepository,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
params: GetLeagueWalletUseCaseParams,
|
||||
): Promise<Result<GetLeagueWalletOutputPort, ApplicationErrorCode<'REPOSITORY_ERROR'>>> {
|
||||
try {
|
||||
// For now, return mock data to emulate previous state
|
||||
// TODO: Implement full domain logic when wallet entities are properly seeded
|
||||
const mockWallet: GetLeagueWalletOutputPort = {
|
||||
balance: 2450.00,
|
||||
currency: 'USD',
|
||||
totalRevenue: 3200.00,
|
||||
totalFees: 320.00,
|
||||
totalWithdrawals: 430.00,
|
||||
pendingPayouts: 150.00,
|
||||
canWithdraw: false,
|
||||
withdrawalBlockReason: 'Season 2 is still active. Withdrawals are available after season completion.',
|
||||
transactions: [
|
||||
{
|
||||
id: 'txn-1',
|
||||
type: 'sponsorship',
|
||||
description: 'Main Sponsor - TechCorp',
|
||||
amount: 1200.00,
|
||||
fee: 120.00,
|
||||
netAmount: 1080.00,
|
||||
date: '2025-12-01T00:00:00.000Z',
|
||||
status: 'completed',
|
||||
reference: 'SP-2025-001',
|
||||
},
|
||||
{
|
||||
id: 'txn-2',
|
||||
type: 'sponsorship',
|
||||
description: 'Secondary Sponsor - RaceFuel',
|
||||
amount: 400.00,
|
||||
fee: 40.00,
|
||||
netAmount: 360.00,
|
||||
date: '2025-12-01T00:00:00.000Z',
|
||||
status: 'completed',
|
||||
reference: 'SP-2025-002',
|
||||
},
|
||||
{
|
||||
id: 'txn-3',
|
||||
type: 'membership',
|
||||
description: 'Season Fee - 32 drivers',
|
||||
amount: 1600.00,
|
||||
fee: 160.00,
|
||||
netAmount: 1440.00,
|
||||
date: '2025-11-15T00:00:00.000Z',
|
||||
status: 'completed',
|
||||
reference: 'MF-2025-032',
|
||||
},
|
||||
{
|
||||
id: 'txn-4',
|
||||
type: 'withdrawal',
|
||||
description: 'Bank Transfer - Season 1 Payout',
|
||||
amount: -430.00,
|
||||
fee: 0,
|
||||
netAmount: -430.00,
|
||||
date: '2025-10-30T00:00:00.000Z',
|
||||
status: 'completed',
|
||||
reference: 'WD-2025-001',
|
||||
},
|
||||
{
|
||||
id: 'txn-5',
|
||||
type: 'prize',
|
||||
description: 'Championship Prize Pool (reserved)',
|
||||
amount: -150.00,
|
||||
fee: 0,
|
||||
netAmount: -150.00,
|
||||
date: '2025-12-05T00:00:00.000Z',
|
||||
status: 'pending',
|
||||
reference: 'PZ-2025-001',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return Result.ok(mockWallet);
|
||||
} catch {
|
||||
return Result.err({ code: 'REPOSITORY_ERROR', message: 'Failed to fetch league wallet' });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user