fix data flow issues
This commit is contained in:
54
apps/website/lib/api/wallets/WalletsApiClient.ts
Normal file
54
apps/website/lib/api/wallets/WalletsApiClient.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { BaseApiClient } from '../base/BaseApiClient';
|
||||
|
||||
export interface LeagueWalletDTO {
|
||||
balance: number;
|
||||
currency: string;
|
||||
totalRevenue: number;
|
||||
totalFees: number;
|
||||
totalWithdrawals: number;
|
||||
pendingPayouts: number;
|
||||
canWithdraw: boolean;
|
||||
withdrawalBlockReason?: string;
|
||||
transactions: WalletTransactionDTO[];
|
||||
}
|
||||
|
||||
export interface WalletTransactionDTO {
|
||||
id: string;
|
||||
type: 'sponsorship' | 'membership' | 'withdrawal' | 'prize';
|
||||
description: string;
|
||||
amount: number;
|
||||
fee: number;
|
||||
netAmount: number;
|
||||
date: string; // ISO string
|
||||
status: 'completed' | 'pending' | 'failed';
|
||||
reference?: string;
|
||||
}
|
||||
|
||||
export interface WithdrawRequestDTO {
|
||||
amount: number;
|
||||
currency: string;
|
||||
seasonId: string;
|
||||
destinationAccount: string;
|
||||
}
|
||||
|
||||
export interface WithdrawResponseDTO {
|
||||
success: boolean;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wallets API Client
|
||||
*
|
||||
* Handles all wallet-related API operations.
|
||||
*/
|
||||
export class WalletsApiClient extends BaseApiClient {
|
||||
/** Get league wallet */
|
||||
getLeagueWallet(leagueId: string): Promise<LeagueWalletDTO> {
|
||||
return this.get<LeagueWalletDTO>(`/leagues/${leagueId}/wallet`);
|
||||
}
|
||||
|
||||
/** Withdraw from league wallet */
|
||||
withdrawFromLeagueWallet(leagueId: string, request: WithdrawRequestDTO): Promise<WithdrawResponseDTO> {
|
||||
return this.post<WithdrawResponseDTO>(`/leagues/${leagueId}/wallet/withdraw`, request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user