refactor: extract shared payment status sets to utility module

- Move PAID_STATUSES/FAILED_STATUSES from Balance.tsx and TopUpResult.tsx
  to src/utils/paymentStatus.ts
- Eliminates code duplication between the two pages
This commit is contained in:
Fringg
2026-03-09 05:00:08 +03:00
parent 7ce5341e95
commit 6a9fdac75c
3 changed files with 35 additions and 57 deletions

View File

@@ -0,0 +1,31 @@
export const PAID_STATUSES = new Set([
'succeeded',
'success',
'paid',
'paid_over',
'overpaid',
'completed',
'confirmed',
'closed',
]);
export const FAILED_STATUSES = new Set([
'fail',
'failed',
'error',
'canceled',
'cancelled',
'declined',
'expired',
'cancel',
'system_fail',
'refund_paid',
]);
export function isPaidStatus(status: string): boolean {
return PAID_STATUSES.has(status.toLowerCase());
}
export function isFailedStatus(status: string): boolean {
return FAILED_STATUSES.has(status.toLowerCase());
}