mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-28 08:08:32 +00:00
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
/**
|
|
* Shared utility functions for payment order display.
|
|
* Used by AdminOrderDetail, AdminOrderTable, AdminRefundDialog, AdminOrdersView, etc.
|
|
*/
|
|
|
|
const STATUS_BADGE_MAP: Record<string, string> = {
|
|
PENDING: 'badge-warning',
|
|
PAID: 'badge-info',
|
|
RECHARGING: 'badge-info',
|
|
COMPLETED: 'badge-success',
|
|
EXPIRED: 'badge-secondary',
|
|
CANCELLED: 'badge-secondary',
|
|
FAILED: 'badge-danger',
|
|
REFUND_REQUESTED: 'badge-warning',
|
|
REFUNDING: 'badge-warning',
|
|
REFUND_PENDING: 'badge-warning',
|
|
PARTIALLY_REFUNDED: 'badge-warning',
|
|
REFUNDED: 'badge-info',
|
|
REFUND_FAILED: 'badge-danger',
|
|
}
|
|
|
|
const REFUNDABLE_STATUSES = ['COMPLETED', 'PARTIALLY_REFUNDED', 'REFUND_REQUESTED', 'REFUND_FAILED']
|
|
|
|
export function statusBadgeClass(status: string): string {
|
|
return STATUS_BADGE_MAP[status] || 'badge-secondary'
|
|
}
|
|
|
|
export function canRefund(status: string): boolean {
|
|
return REFUNDABLE_STATUSES.includes(status)
|
|
}
|
|
|
|
export function formatOrderDateTime(dateStr: string): string {
|
|
if (!dateStr) return '-'
|
|
return new Date(dateStr).toLocaleString()
|
|
}
|