mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +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:
31
src/utils/paymentStatus.ts
Normal file
31
src/utils/paymentStatus.ts
Normal 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());
|
||||
}
|
||||
Reference in New Issue
Block a user