refactor(payment): code standards fixes and regression repairs
Backend: - Split payment_order.go (546→314 lines) into payment_order_lifecycle.go - Replace magic strings with constants in factory, easypay, webhook handler - Add rate limit/validity unit constants in payment_order_lifecycle, payment_service - Fix critical regression: add PaymentEnabled to GetPublicSettings response - Add missing migration 099_fix_migrated_purchase_menu_label_icon.sql Frontend: - Fix StripePopupView.vue: replace `as any` with typed interface, use extractApiErrorMessage - Fix AdminOrderTable.vue: replace hardcoded column labels with i18n t() calls - Fix SubscriptionsView.vue: replace hardcoded Today/Tomorrow with i18n - Extract duplicate statusBadgeClass/canRefund/formatOrderDateTime to orderUtils.ts - Add missing i18n keys: common.today, common.tomorrow, payment.orders.orderType/actions - Remove dead PurchaseSubscriptionView.vue (replaced by PaymentView)
This commit is contained in:
34
frontend/src/components/payment/orderUtils.ts
Normal file
34
frontend/src/components/payment/orderUtils.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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',
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user