mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 10:27:49 +00:00
feat: add partner management and withdrawal admin pages
- Admin partners page: list partners, view applications, approve/reject - Admin partner detail: stats, commission management, campaign assignment - Admin withdrawals page: list with risk scoring, status filters including cancelled - Admin withdrawal detail: fraud analysis, approve/reject/complete actions - Partner API client with full TypeScript interfaces - Withdrawal API client with admin and user endpoints - Referral page: partner application form, withdrawal balance and history - Navigation: partners and withdrawals in admin panel marketing group - i18n: full translations for ru, en, zh, fa locales - Neutral fallbacks for unknown status badges
This commit is contained in:
152
src/api/withdrawals.ts
Normal file
152
src/api/withdrawals.ts
Normal file
@@ -0,0 +1,152 @@
|
||||
import apiClient from './client';
|
||||
|
||||
// ==================== User-facing types ====================
|
||||
|
||||
export interface WithdrawalBalanceResponse {
|
||||
total_earned: number;
|
||||
referral_spent: number;
|
||||
withdrawn: number;
|
||||
pending: number;
|
||||
available_referral: number;
|
||||
available_total: number;
|
||||
only_referral_mode: boolean;
|
||||
min_amount_kopeks: number;
|
||||
is_withdrawal_enabled: boolean;
|
||||
can_request: boolean;
|
||||
cannot_request_reason: string | null;
|
||||
}
|
||||
|
||||
export interface WithdrawalCreateRequest {
|
||||
amount_kopeks: number;
|
||||
payment_details: string;
|
||||
}
|
||||
|
||||
export interface WithdrawalItem {
|
||||
id: number;
|
||||
amount_kopeks: number;
|
||||
amount_rubles: number;
|
||||
status: string;
|
||||
payment_details: string | null;
|
||||
admin_comment: string | null;
|
||||
created_at: string;
|
||||
processed_at: string | null;
|
||||
}
|
||||
|
||||
export interface WithdrawalListResponse {
|
||||
items: WithdrawalItem[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface WithdrawalCreateResponse {
|
||||
id: number;
|
||||
amount_kopeks: number;
|
||||
status: string;
|
||||
}
|
||||
|
||||
// ==================== Admin-facing types ====================
|
||||
|
||||
export interface AdminWithdrawalItem {
|
||||
id: number;
|
||||
user_id: number;
|
||||
username: string | null;
|
||||
first_name: string | null;
|
||||
telegram_id: number | null;
|
||||
amount_kopeks: number;
|
||||
amount_rubles: number;
|
||||
status: string;
|
||||
risk_score: number;
|
||||
risk_level: string;
|
||||
payment_details: string | null;
|
||||
admin_comment: string | null;
|
||||
created_at: string;
|
||||
processed_at: string | null;
|
||||
}
|
||||
|
||||
export interface AdminWithdrawalListResponse {
|
||||
items: AdminWithdrawalItem[];
|
||||
total: number;
|
||||
pending_count: number;
|
||||
pending_total_kopeks: number;
|
||||
}
|
||||
|
||||
export interface AdminWithdrawalDetailResponse {
|
||||
id: number;
|
||||
user_id: number;
|
||||
username: string | null;
|
||||
first_name: string | null;
|
||||
telegram_id: number | null;
|
||||
amount_kopeks: number;
|
||||
amount_rubles: number;
|
||||
status: string;
|
||||
risk_score: number;
|
||||
risk_level: string;
|
||||
risk_analysis: Record<string, unknown> | null;
|
||||
payment_details: string | null;
|
||||
admin_comment: string | null;
|
||||
balance_kopeks: number;
|
||||
total_referrals: number;
|
||||
total_earnings_kopeks: number;
|
||||
created_at: string;
|
||||
processed_at: string | null;
|
||||
}
|
||||
|
||||
export const withdrawalApi = {
|
||||
// User endpoints
|
||||
getBalance: async (): Promise<WithdrawalBalanceResponse> => {
|
||||
const response = await apiClient.get<WithdrawalBalanceResponse>(
|
||||
'/cabinet/referral/withdrawal/balance',
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
create: async (data: WithdrawalCreateRequest): Promise<WithdrawalCreateResponse> => {
|
||||
const response = await apiClient.post<WithdrawalCreateResponse>(
|
||||
'/cabinet/referral/withdrawal/create',
|
||||
data,
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getHistory: async (): Promise<WithdrawalListResponse> => {
|
||||
const response = await apiClient.get<WithdrawalListResponse>(
|
||||
'/cabinet/referral/withdrawal/history',
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
cancel: async (requestId: number): Promise<void> => {
|
||||
await apiClient.post(`/cabinet/referral/withdrawal/${requestId}/cancel`);
|
||||
},
|
||||
|
||||
// Admin endpoints
|
||||
getAll: async (params?: {
|
||||
status?: string;
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
}): Promise<AdminWithdrawalListResponse> => {
|
||||
const response = await apiClient.get<AdminWithdrawalListResponse>(
|
||||
'/cabinet/admin/withdrawals',
|
||||
{ params },
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getDetail: async (withdrawalId: number): Promise<AdminWithdrawalDetailResponse> => {
|
||||
const response = await apiClient.get<AdminWithdrawalDetailResponse>(
|
||||
`/cabinet/admin/withdrawals/${withdrawalId}`,
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
approve: async (withdrawalId: number, comment?: string): Promise<void> => {
|
||||
await apiClient.post(`/cabinet/admin/withdrawals/${withdrawalId}/approve`, { comment });
|
||||
},
|
||||
|
||||
reject: async (withdrawalId: number, comment?: string): Promise<void> => {
|
||||
await apiClient.post(`/cabinet/admin/withdrawals/${withdrawalId}/reject`, { comment });
|
||||
},
|
||||
|
||||
complete: async (withdrawalId: number): Promise<void> => {
|
||||
await apiClient.post(`/cabinet/admin/withdrawals/${withdrawalId}/complete`);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user