mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
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:
@@ -12,6 +12,7 @@ import { Spinner } from '@/components/ui/Spinner';
|
||||
import { AnimatedCheckmark } from '@/components/ui/AnimatedCheckmark';
|
||||
import { AnimatedCrossmark } from '@/components/ui/AnimatedCrossmark';
|
||||
import { loadTopUpPendingInfo, clearTopUpPendingInfo } from '../utils/topUpStorage';
|
||||
import { isPaidStatus, isFailedStatus } from '../utils/paymentStatus';
|
||||
|
||||
// ── Constants ────────────────────────────────────────────────
|
||||
const MAX_POLL_MS = 10 * 60 * 1000; // 10 minutes
|
||||
@@ -177,39 +178,6 @@ function TimeoutState({ onRetry, onGoBack }: { onRetry: () => void; onGoBack: ()
|
||||
);
|
||||
}
|
||||
|
||||
// ── Determine paid status from provider-specific status strings ──
|
||||
const PAID_STATUSES = new Set([
|
||||
'succeeded',
|
||||
'success',
|
||||
'paid',
|
||||
'paid_over',
|
||||
'overpaid',
|
||||
'completed',
|
||||
'confirmed',
|
||||
'closed',
|
||||
]);
|
||||
|
||||
const FAILED_STATUSES = new Set([
|
||||
'fail',
|
||||
'failed',
|
||||
'error',
|
||||
'canceled',
|
||||
'cancelled',
|
||||
'declined',
|
||||
'expired',
|
||||
'cancel',
|
||||
'system_fail',
|
||||
'refund_paid',
|
||||
]);
|
||||
|
||||
function isPaidStatus(status: string): boolean {
|
||||
return PAID_STATUSES.has(status.toLowerCase());
|
||||
}
|
||||
|
||||
function isFailedStatus(status: string): boolean {
|
||||
return FAILED_STATUSES.has(status.toLowerCase());
|
||||
}
|
||||
|
||||
// ── Main Component ───────────────────────────────────────────
|
||||
|
||||
export default function TopUpResult() {
|
||||
|
||||
Reference in New Issue
Block a user