@burdenoff/microfe-billing 2026.1119.2 → 2026.1122.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/billing/modules/addons/pages/AddonsBrowsePage.js +2 -1
  2. package/dist/billing/modules/addons/pages/AddonsBrowsePage.js.map +1 -1
  3. package/dist/billing/modules/addons/pages/AddonsListPage.js +2 -1
  4. package/dist/billing/modules/addons/pages/AddonsListPage.js.map +1 -1
  5. package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js +5 -2
  6. package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js.map +1 -1
  7. package/dist/billing/modules/analytics/pages/AnalyticsPage.js +2 -1
  8. package/dist/billing/modules/analytics/pages/AnalyticsPage.js.map +1 -1
  9. package/dist/billing/modules/billing/pages/BillingWebhookLogsPage.js +2 -1
  10. package/dist/billing/modules/billing/pages/BillingWebhookLogsPage.js.map +1 -1
  11. package/dist/billing/modules/billing/pages/InvoicesListPage.js +3 -1
  12. package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
  13. package/dist/billing/modules/billing/pages/OrderCallbackLogsPage.js +2 -1
  14. package/dist/billing/modules/billing/pages/OrderCallbackLogsPage.js.map +1 -1
  15. package/dist/billing/modules/billing/pages/PaymentMethodsPage.js +2 -1
  16. package/dist/billing/modules/billing/pages/PaymentMethodsPage.js.map +1 -1
  17. package/dist/billing/modules/billing/pages/RefundIssueLogsPage.js +2 -1
  18. package/dist/billing/modules/billing/pages/RefundIssueLogsPage.js.map +1 -1
  19. package/dist/billing/modules/billing/pages/RefundsPage.js +3 -1
  20. package/dist/billing/modules/billing/pages/RefundsPage.js.map +1 -1
  21. package/dist/billing/modules/billing/pages/TransactionsPage.js +166 -164
  22. package/dist/billing/modules/billing/pages/TransactionsPage.js.map +1 -1
  23. package/dist/billing/modules/billing/pages/UserRefundsPage.js +3 -1
  24. package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
  25. package/dist/billing/modules/coupons/pages/CouponsListPage.js +4 -1
  26. package/dist/billing/modules/coupons/pages/CouponsListPage.js.map +1 -1
  27. package/dist/billing/modules/credits/pages/AdminCreditsPage.js +3 -1
  28. package/dist/billing/modules/credits/pages/AdminCreditsPage.js.map +1 -1
  29. package/dist/billing/modules/credits/pages/CreditTransactionsPage.js +3 -1
  30. package/dist/billing/modules/credits/pages/CreditTransactionsPage.js.map +1 -1
  31. package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js +6 -2
  32. package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js.map +1 -1
  33. package/dist/billing/modules/credits/pages/CreditsPage.js +3 -1
  34. package/dist/billing/modules/credits/pages/CreditsPage.js.map +1 -1
  35. package/dist/billing/modules/discounts/pages/DiscountsListPage.js +3 -1
  36. package/dist/billing/modules/discounts/pages/DiscountsListPage.js.map +1 -1
  37. package/dist/billing/modules/earnings/pages/EarningsPage.js +14 -5
  38. package/dist/billing/modules/earnings/pages/EarningsPage.js.map +1 -1
  39. package/dist/billing/modules/earnings/pages/PayoutAdminPage.js +3 -1
  40. package/dist/billing/modules/earnings/pages/PayoutAdminPage.js.map +1 -1
  41. package/dist/billing/modules/earnings/pages/PayoutsPage.js +6 -2
  42. package/dist/billing/modules/earnings/pages/PayoutsPage.js.map +1 -1
  43. package/dist/billing/modules/plans/pages/PlansBrowsePage.js +3 -1
  44. package/dist/billing/modules/plans/pages/PlansBrowsePage.js.map +1 -1
  45. package/dist/billing/modules/plans/pages/PlansListPage.js +3 -1
  46. package/dist/billing/modules/plans/pages/PlansListPage.js.map +1 -1
  47. package/dist/billing/modules/promotions/pages/PromotionsListPage.js +2 -1
  48. package/dist/billing/modules/promotions/pages/PromotionsListPage.js.map +1 -1
  49. package/dist/billing/modules/quota/pages/QuotaTemplatesListPage.js +2 -1
  50. package/dist/billing/modules/quota/pages/QuotaTemplatesListPage.js.map +1 -1
  51. package/dist/billing/modules/subscriptions/pages/SubscriptionsListPage.js +3 -1
  52. package/dist/billing/modules/subscriptions/pages/SubscriptionsListPage.js.map +1 -1
  53. package/dist/billing/modules/usage/pages/UsagePage.js +4 -2
  54. package/dist/billing/modules/usage/pages/UsagePage.js.map +1 -1
  55. package/dist/billing/shared/components/EmptyState.d.ts +7 -0
  56. package/dist/billing/shared/components/EmptyState.js +5 -2
  57. package/dist/billing/shared/components/EmptyState.js.map +1 -1
  58. package/dist/billing/shared/types/graphql.d.ts +0 -3
  59. package/dist/billing/shared/types/graphql.js.map +1 -1
  60. package/dist/generated/global-operations.d.ts +157 -31
  61. package/dist/generated/global-operations.js.map +1 -1
  62. package/dist/generated/global-types.d.ts +6856 -970
  63. package/dist/generated/global-types.js.map +1 -1
  64. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"OrderCallbackLogsPage.js","names":["PAGE_SIZE","CALLBACK_STATUS_OPTIONS","getBadge","order","statusTokens","AlertTriangle","CheckCircle","Clock","OrderCallbackDetailModal","canRetry","onClose","X","formatDateTime","onRetry","isRetrying","Loader2","RotateCw","OrderCallbackLogsPage","permissions","useBillingPermissions","page","setPage","useState","filters","setFilters","selectedOrder","setSelectedOrder","retryError","setRetryError","useOrderCallbacks","useOrderCallbackMutations","AccessDenied","error","isServerError","ServerError","refetch","handleFilterChange","prev","key","value","handleRetry","retryOrderCallback","err","columns","badge","BadgeIcon","totalPages","totalCount","PageHeader","RefreshCw","ThemedSelect","s","isLoading","orders","i","IllustratedEmptyState","ResponsiveTable","Eye","p","ChevronLeft","ChevronRight"],"sources":["../../../../../src/billing/modules/billing/pages/OrderCallbackLogsPage.tsx"],"sourcesContent":["/**\n * Billing Module - Order Callback Logs Page\n * Admin visibility into the billing→external-service (store, etc.) order\n * completion callback — every BillingOrder's callback delivery attempt, not\n * just the ones currently FAILED. The outbound counterpart to\n * BillingWebhookLogsPage's inbound Stripe/Razorpay webhook view: lets\n * whoever owns billing ops see and retry a stuck billing→store handoff\n * without needing direct DB access (BOFF-7192).\n */\n\nimport { useState, type FC } from 'react';\nimport {\n RefreshCw,\n ChevronLeft,\n ChevronRight,\n CheckCircle,\n AlertTriangle,\n Clock,\n X,\n RotateCw,\n Loader2,\n Eye,\n} from 'lucide-react';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport {\n useOrderCallbacks,\n useOrderCallbackMutations,\n type OrderCallbackFilters,\n type OrderCallback,\n} from '../hooks';\nimport { AccessDenied, PageHeader, ServerError } from '../../../shared/components';\nimport { formatDateTime, isServerError } from '../../../shared/utils';\nimport { statusTokens } from '../../../shared/utils/tokens';\nimport {\n ResponsiveTable,\n type ResponsiveTableColumn,\n IllustratedEmptyState,\n ThemedSelect,\n} from '@burdenoff/fe-libs/ui';\n\nconst PAGE_SIZE = 25;\nconst CALLBACK_STATUS_OPTIONS = ['PENDING', 'SUCCESS', 'FAILED'];\n\nconst getBadge = (\n order: OrderCallback\n): { label: string; className: string; icon: FC<{ className?: string }> } => {\n if (order.callbackStatus === 'FAILED') {\n return {\n label: 'Failed',\n className: `${statusTokens.error.bg} ${statusTokens.error.text}`,\n icon: AlertTriangle,\n };\n }\n if (order.callbackStatus === 'SUCCESS') {\n return {\n label: 'Delivered',\n className: `${statusTokens.success.bg} ${statusTokens.success.text}`,\n icon: CheckCircle,\n };\n }\n return {\n label: order.callbackStatus || 'Pending',\n className: `${statusTokens.warning.bg} ${statusTokens.warning.text}`,\n icon: Clock,\n };\n};\n\nconst OrderCallbackDetailModal: FC<{\n order: OrderCallback | null;\n onClose: () => void;\n onRetry: (order: OrderCallback) => void;\n isRetrying: boolean;\n}> = ({ order, onClose, onRetry, isRetrying }) => {\n if (!order) return null;\n\n const canRetry = order.callbackStatus === 'FAILED' && Boolean(order.billingAccountId);\n\n return (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center bg-bg-overlay p-4\">\n <div className=\"w-full max-w-2xl max-h-[85vh] overflow-y-auto rounded-lg bg-bg-surface border border-border-subtle shadow-[var(--shadow-elevation-2)]\">\n <div className=\"flex items-center justify-between p-4 border-b border-border-subtle\">\n <h3 className=\"text-base font-semibold text-text-primary\">Order callback details</h3>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-sunken/50\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n <div className=\"p-4 space-y-4\">\n <div className=\"grid grid-cols-2 gap-4 text-sm\">\n <div>\n <p className=\"text-text-muted\">Order ID</p>\n <p className=\"text-text-primary font-mono text-xs break-all\">{order.id}</p>\n </div>\n <div>\n <p className=\"text-text-muted\">Service</p>\n <p className=\"text-text-primary\">{order.externalService}</p>\n </div>\n <div>\n <p className=\"text-text-muted\">Order status</p>\n <p className=\"text-text-primary\">{order.status}</p>\n </div>\n <div>\n <p className=\"text-text-muted\">Amount</p>\n <p className=\"text-text-primary\">\n {order.subtotal} {order.currency}\n </p>\n </div>\n <div>\n <p className=\"text-text-muted\">Billing account</p>\n <p className=\"text-text-primary font-mono text-xs break-all\">\n {order.billingAccountId || '—'}\n </p>\n </div>\n <div>\n <p className=\"text-text-muted\">Payment / Transaction</p>\n <p className=\"text-text-primary font-mono text-xs break-all\">\n {order.paymentId || '—'} / {order.transactionId || '—'}\n </p>\n </div>\n <div>\n <p className=\"text-text-muted\">Created</p>\n <p className=\"text-text-primary\">{formatDateTime(order.createdAt)}</p>\n </div>\n <div>\n <p className=\"text-text-muted\">Last callback attempt</p>\n <p className=\"text-text-primary\">\n {order.callbackLastAttemptAt ? formatDateTime(order.callbackLastAttemptAt) : '—'}\n </p>\n </div>\n <div>\n <p className=\"text-text-muted\">Callback attempts</p>\n <p className=\"text-text-primary\">{order.callbackAttempts ?? 0}</p>\n </div>\n <div>\n <p className=\"text-text-muted\">Callback status</p>\n <p className=\"text-text-primary\">{order.callbackStatus || 'PENDING'}</p>\n </div>\n </div>\n {order.callbackLastError && (\n <div>\n <p className=\"text-sm text-text-muted mb-1\">Last error</p>\n <pre className=\"text-xs whitespace-pre-wrap p-3 rounded-md bg-status-error-bg-subtle text-status-error-text border border-status-error-border\">\n {order.callbackLastError}\n </pre>\n </div>\n )}\n {order.callbackStatus === 'FAILED' && !order.billingAccountId && (\n <p className=\"text-xs text-text-muted\">\n No billing account was resolved on this order, so it can&apos;t be retried from here —\n the callback was never able to identify who paid.\n </p>\n )}\n {order.callbackStatus === 'FAILED' && (\n <button\n type=\"button\"\n onClick={() => onRetry(order)}\n disabled={!canRetry || isRetrying}\n className=\"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bgHover disabled:opacity-50\"\n >\n {isRetrying ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <RotateCw className=\"size-4\" />\n )}\n Retry callback\n </button>\n )}\n </div>\n </div>\n </div>\n );\n};\n\nexport const OrderCallbackLogsPage: FC = () => {\n const permissions = useBillingPermissions();\n const [page, setPage] = useState(0);\n const [filters, setFilters] = useState<OrderCallbackFilters>({});\n const [selectedOrder, setSelectedOrder] = useState<OrderCallback | null>(null);\n const [retryError, setRetryError] = useState<string | null>(null);\n\n const { orders, totalCount, isLoading, error, refetch } = useOrderCallbacks(\n filters,\n page,\n PAGE_SIZE\n );\n const { retryOrderCallback, isRetrying } = useOrderCallbackMutations();\n\n if (!permissions.isBillingAdmin) {\n return <AccessDenied message=\"You don't have permission to view order callback logs.\" />;\n }\n\n if (error && isServerError(error)) {\n return (\n <div className=\"p-6\">\n <ServerError\n title=\"Server Unavailable\"\n message=\"Unable to load order callback logs. The server might be down or experiencing issues.\"\n onRetry={() => refetch()}\n showRetry\n />\n </div>\n );\n }\n\n const handleFilterChange = <K extends keyof OrderCallbackFilters>(\n key: K,\n value: OrderCallbackFilters[K]\n ) => {\n setFilters((prev) => ({ ...prev, [key]: value }));\n setPage(0);\n };\n\n const handleRetry = async (order: OrderCallback) => {\n if (!order.billingAccountId) return;\n setRetryError(null);\n try {\n await retryOrderCallback(order.id, order.billingAccountId);\n await refetch();\n setSelectedOrder(null);\n } catch (err) {\n setRetryError(err instanceof Error ? err.message : 'Failed to retry callback');\n }\n };\n\n const columns: ResponsiveTableColumn<OrderCallback>[] = [\n {\n key: 'date',\n header: 'Created',\n priority: 'primary',\n cellClassName: 'whitespace-nowrap',\n cell: (order) => (\n <div className=\"flex flex-col\">\n <span className=\"text-sm text-text-primary\">\n {formatDateTime(order.createdAt).split(' ')[0]}\n </span>\n <span className=\"text-xs text-text-muted\">\n {formatDateTime(order.createdAt).split(' ')[1]}\n </span>\n </div>\n ),\n },\n {\n key: 'callbackStatus',\n header: 'Callback',\n cellClassName: 'whitespace-nowrap',\n cell: (order) => {\n const badge = getBadge(order);\n const BadgeIcon = badge.icon;\n return (\n <span\n className={`inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded ${badge.className}`}\n >\n <BadgeIcon className=\"size-3\" />\n {badge.label}\n </span>\n );\n },\n },\n {\n key: 'service',\n header: 'Service',\n priority: 'hidden-on-mobile',\n cellClassName: 'whitespace-nowrap',\n cell: (order) => <span className=\"text-sm text-text-primary\">{order.externalService}</span>,\n },\n {\n key: 'orderId',\n header: 'Order ID',\n cellClassName: 'whitespace-nowrap max-w-[220px] truncate',\n cell: (order) => (\n <span className=\"text-sm font-mono text-text-muted\" title={order.id}>\n {order.id}\n </span>\n ),\n },\n {\n key: 'attempts',\n header: 'Attempts',\n priority: 'hidden-on-mobile',\n cellClassName: 'whitespace-nowrap',\n cell: (order) => (\n <span className=\"text-sm text-text-secondary\">{order.callbackAttempts ?? 0}</span>\n ),\n },\n {\n key: 'error',\n header: 'Error',\n priority: 'hidden-on-mobile',\n cellClassName: 'max-w-[280px] truncate',\n cell: (order) => (\n <span className=\"text-sm text-status-error-text\">{order.callbackLastError || '-'}</span>\n ),\n },\n ];\n\n const totalPages = Math.max(1, Math.ceil(totalCount / PAGE_SIZE));\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title=\"Order Callback Logs\"\n description=\"Every billing→store (and other external service) order-completion callback — investigate a stuck handoff directly.\"\n actions={\n <button\n type=\"button\"\n onClick={() => refetch()}\n className=\"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50\"\n >\n <RefreshCw className=\"size-4\" />\n Refresh\n </button>\n }\n />\n\n {retryError && (\n <div className=\"p-3 rounded-md bg-status-error-bg-subtle text-status-error-text border border-status-error-border text-sm\">\n {retryError}\n </div>\n )}\n\n {/* Filters */}\n <div className=\"p-4 border border-border-subtle rounded-lg bg-bg-sunken/30 grid grid-cols-1 sm:grid-cols-3 gap-4\">\n <div>\n <label className=\"block text-sm font-medium mb-1\">Callback status</label>\n <ThemedSelect\n value={filters.callbackStatus || ''}\n onChange={(e) => handleFilterChange('callbackStatus', e.target.value || undefined)}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"\">All</option>\n {CALLBACK_STATUS_OPTIONS.map((s) => (\n <option key={s} value={s}>\n {s}\n </option>\n ))}\n </ThemedSelect>\n </div>\n <div>\n <label className=\"block text-sm font-medium mb-1\">Service</label>\n <input\n type=\"text\"\n value={filters.externalService || ''}\n onChange={(e) => handleFilterChange('externalService', e.target.value || undefined)}\n placeholder=\"e.g. STORE\"\n className=\"w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface\"\n />\n </div>\n <div>\n <label className=\"block text-sm font-medium mb-1\">Has Error</label>\n <ThemedSelect\n value={filters.hasError === undefined ? '' : String(filters.hasError)}\n onChange={(e) =>\n handleFilterChange(\n 'hasError',\n e.target.value === '' ? undefined : e.target.value === 'true'\n )\n }\n className=\"w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"\">All</option>\n <option value=\"true\">Has error</option>\n <option value=\"false\">No error</option>\n </ThemedSelect>\n </div>\n </div>\n\n {/* Table */}\n {isLoading && orders.length === 0 ? (\n <div className=\"space-y-2\">\n {[1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"h-16 bg-bg-sunken animate-pulse rounded\" />\n ))}\n </div>\n ) : orders.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title=\"No order callbacks found\"\n description=\"Nothing matches these filters — try widening them, or check back after the next store purchase.\"\n />\n ) : (\n <div className=\"border border-border-subtle rounded-lg overflow-hidden\">\n <ResponsiveTable<OrderCallback>\n columns={columns}\n data={orders}\n rowKey={(order) => order.id}\n rowActions={(order) => (\n <button\n type=\"button\"\n onClick={() => setSelectedOrder(order)}\n className=\"inline-flex items-center gap-1.5 px-2 py-1 text-sm font-medium rounded-button text-text-secondary hover:text-text-primary hover:bg-bg-sunken/60 transition-colors\"\n >\n <Eye className=\"size-4\" />\n <span className=\"hidden sm:inline\">View</span>\n </button>\n )}\n />\n </div>\n )}\n\n {/* Pagination */}\n {totalCount > 0 && (\n <div className=\"flex flex-col sm:flex-row items-center justify-between gap-4 border-t border-border-subtle pt-4\">\n <p className=\"text-sm text-text-muted text-center sm:text-left\">\n Showing {page * PAGE_SIZE + 1} to {Math.min((page + 1) * PAGE_SIZE, totalCount)} of{' '}\n {totalCount} orders\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => setPage((p) => Math.max(0, p - 1))}\n disabled={page === 0}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-button border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors\"\n >\n <ChevronLeft className=\"size-4\" />\n <span className=\"hidden sm:inline\">Previous</span>\n </button>\n <span className=\"text-sm text-text-muted px-2\">\n <span className=\"hidden sm:inline\">Page </span>\n {page + 1} <span className=\"hidden sm:inline\">of</span>\n <span className=\"sm:hidden\">/</span> {totalPages}\n </span>\n <button\n type=\"button\"\n onClick={() => setPage((p) => (p + 1 < totalPages ? p + 1 : p))}\n disabled={page + 1 >= totalPages}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-button border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors\"\n >\n <span className=\"hidden sm:inline\">Next</span>\n <ChevronRight className=\"size-4\" />\n </button>\n </div>\n </div>\n )}\n\n <OrderCallbackDetailModal\n order={selectedOrder}\n onClose={() => setSelectedOrder(null)}\n onRetry={handleRetry}\n isRetrying={isRetrying}\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAwCA,IAAMA,IAAY,IACZC,IAA0B;CAAC;CAAW;CAAW;AAAQ,GAEzDC,KACJ,MAEIC,EAAM,mBAAmB,WACpB;CACL,OAAO;CACP,WAAW,GAAGC,EAAa,MAAM,GAAG,GAAGA,EAAa,MAAM;CAC1D,MAAMC;AACR,IAEEF,EAAM,mBAAmB,YACpB;CACL,OAAO;CACP,WAAW,GAAGC,EAAa,QAAQ,GAAG,GAAGA,EAAa,QAAQ;CAC9D,MAAME;AACR,IAEK;CACL,OAAOH,EAAM,kBAAkB;CAC/B,WAAW,GAAGC,EAAa,QAAQ,GAAG,GAAGA,EAAa,QAAQ;CAC9D,MAAMG;AACR,GAGIC,KAKA,EAAE,UAAO,YAAS,YAAS,oBAAiB;CAChD,IAAI,CAACL,GAAO,OAAO;CAEnB,IAAMM,IAAWN,EAAM,mBAAmB,YAAY,EAAQA,EAAM;CAEpE,OACE,kBAAC,OAAD;EAAK,WAAU;EACb,UAAA,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,MAAD;KAAI,WAAU;KAA4C,UAAA;IAA0B,CAAA,GACpF,kBAAC,UAAD;KACE,MAAK;KACL,SAASO;KACT,WAAU;KAEV,UAAA,kBAACC,GAAD,EAAG,WAAU,SAAU,CAAA;IACjB,CAAA,CACL;GACL,CAAA,GAAA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AAC,kBAAC,QAAD;SAAM,WAAU;SAAmB,UAAA;QAAQ,CAAA;QACtD,kBAAC,QAAD;SAAM,WAAU;SAAY,UAAA;QAAO,CAAA;QAAC;QAAE0B;OAClC;;MACN,kBAAC,UAAD;OACE,MAAK;OACL,eAAezB,GAAS,MAAOqC,IAAI,IAAIZ,IAAaY,IAAI,IAAIA,CAAE;OAC9D,UAAUtC,IAAO,KAAK0B;OACtB,WAAU;OAJZ,UAAA,CAME,kBAAC,QAAD;QAAM,WAAU;QAAmB,UAAA;OAAU,CAAA,GAC7C,kBAACc,GAAD,EAAc,WAAU,SAAU,CAAA,CAC5B;;KACL;IACF,CAAA,CAAA;;GAGP,kBAACpD,GAAD;IACE,OAAOiB;IACP,eAAeC,EAAiB,IAAI;IACpC,SAASc;IACG;GACb,CAAA;EACE;;AAET"}
1
+ {"version":3,"file":"OrderCallbackLogsPage.js","names":["PAGE_SIZE","CALLBACK_STATUS_OPTIONS","getBadge","order","statusTokens","AlertTriangle","CheckCircle","Clock","OrderCallbackDetailModal","canRetry","onClose","X","formatDateTime","onRetry","isRetrying","Loader2","RotateCw","OrderCallbackLogsPage","permissions","useBillingPermissions","page","setPage","useState","filters","setFilters","selectedOrder","setSelectedOrder","retryError","setRetryError","useOrderCallbacks","useOrderCallbackMutations","AccessDenied","error","isServerError","ServerError","refetch","handleFilterChange","prev","key","value","handleRetry","retryOrderCallback","err","columns","badge","BadgeIcon","totalPages","totalCount","PageHeader","RefreshCw","ThemedSelect","s","isLoading","orders","i","IllustratedEmptyState","ResponsiveTable","Eye","p","ChevronLeft","ChevronRight"],"sources":["../../../../../src/billing/modules/billing/pages/OrderCallbackLogsPage.tsx"],"sourcesContent":["/**\n * Billing Module - Order Callback Logs Page\n * Admin visibility into the billing→external-service (store, etc.) order\n * completion callback — every BillingOrder's callback delivery attempt, not\n * just the ones currently FAILED. The outbound counterpart to\n * BillingWebhookLogsPage's inbound Stripe/Razorpay webhook view: lets\n * whoever owns billing ops see and retry a stuck billing→store handoff\n * without needing direct DB access (BOFF-7192).\n */\n\nimport { useState, type FC } from 'react';\nimport {\n RefreshCw,\n ChevronLeft,\n ChevronRight,\n CheckCircle,\n AlertTriangle,\n Clock,\n X,\n RotateCw,\n Loader2,\n Eye,\n} from 'lucide-react';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport {\n useOrderCallbacks,\n useOrderCallbackMutations,\n type OrderCallbackFilters,\n type OrderCallback,\n} from '../hooks';\nimport { AccessDenied, PageHeader, ServerError } from '../../../shared/components';\nimport { formatDateTime, isServerError } from '../../../shared/utils';\nimport { statusTokens } from '../../../shared/utils/tokens';\nimport {\n ResponsiveTable,\n type ResponsiveTableColumn,\n IllustratedEmptyState,\n ThemedSelect,\n} from '@burdenoff/fe-libs/ui';\n\nconst PAGE_SIZE = 25;\nconst CALLBACK_STATUS_OPTIONS = ['PENDING', 'SUCCESS', 'FAILED'];\n\nconst getBadge = (\n order: OrderCallback\n): { label: string; className: string; icon: FC<{ className?: string }> } => {\n if (order.callbackStatus === 'FAILED') {\n return {\n label: 'Failed',\n className: `${statusTokens.error.bg} ${statusTokens.error.text}`,\n icon: AlertTriangle,\n };\n }\n if (order.callbackStatus === 'SUCCESS') {\n return {\n label: 'Delivered',\n className: `${statusTokens.success.bg} ${statusTokens.success.text}`,\n icon: CheckCircle,\n };\n }\n return {\n label: order.callbackStatus || 'Pending',\n className: `${statusTokens.warning.bg} ${statusTokens.warning.text}`,\n icon: Clock,\n };\n};\n\nconst OrderCallbackDetailModal: FC<{\n order: OrderCallback | null;\n onClose: () => void;\n onRetry: (order: OrderCallback) => void;\n isRetrying: boolean;\n}> = ({ order, onClose, onRetry, isRetrying }) => {\n if (!order) return null;\n\n const canRetry = order.callbackStatus === 'FAILED' && Boolean(order.billingAccountId);\n\n return (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center bg-bg-overlay p-4\">\n <div className=\"w-full max-w-2xl max-h-[85vh] overflow-y-auto rounded-lg bg-bg-surface border border-border-subtle shadow-[var(--shadow-elevation-2)]\">\n <div className=\"flex items-center justify-between p-4 border-b border-border-subtle\">\n <h3 className=\"text-base font-semibold text-text-primary\">Order callback details</h3>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-sunken/50\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n <div className=\"p-4 space-y-4\">\n <div className=\"grid grid-cols-2 gap-4 text-sm\">\n <div>\n <p className=\"text-text-muted\">Order ID</p>\n <p className=\"text-text-primary font-mono text-xs break-all\">{order.id}</p>\n </div>\n <div>\n <p className=\"text-text-muted\">Service</p>\n <p className=\"text-text-primary\">{order.externalService}</p>\n </div>\n <div>\n <p className=\"text-text-muted\">Order status</p>\n <p className=\"text-text-primary\">{order.status}</p>\n </div>\n <div>\n <p className=\"text-text-muted\">Amount</p>\n <p className=\"text-text-primary\">\n {order.subtotal} {order.currency}\n </p>\n </div>\n <div>\n <p className=\"text-text-muted\">Billing account</p>\n <p className=\"text-text-primary font-mono text-xs break-all\">\n {order.billingAccountId || '—'}\n </p>\n </div>\n <div>\n <p className=\"text-text-muted\">Payment / Transaction</p>\n <p className=\"text-text-primary font-mono text-xs break-all\">\n {order.paymentId || '—'} / {order.transactionId || '—'}\n </p>\n </div>\n <div>\n <p className=\"text-text-muted\">Created</p>\n <p className=\"text-text-primary\">{formatDateTime(order.createdAt)}</p>\n </div>\n <div>\n <p className=\"text-text-muted\">Last callback attempt</p>\n <p className=\"text-text-primary\">\n {order.callbackLastAttemptAt ? formatDateTime(order.callbackLastAttemptAt) : '—'}\n </p>\n </div>\n <div>\n <p className=\"text-text-muted\">Callback attempts</p>\n <p className=\"text-text-primary\">{order.callbackAttempts ?? 0}</p>\n </div>\n <div>\n <p className=\"text-text-muted\">Callback status</p>\n <p className=\"text-text-primary\">{order.callbackStatus || 'PENDING'}</p>\n </div>\n </div>\n {order.callbackLastError && (\n <div>\n <p className=\"text-sm text-text-muted mb-1\">Last error</p>\n <pre className=\"text-xs whitespace-pre-wrap p-3 rounded-md bg-status-error-bg-subtle text-status-error-text border border-status-error-border\">\n {order.callbackLastError}\n </pre>\n </div>\n )}\n {order.callbackStatus === 'FAILED' && !order.billingAccountId && (\n <p className=\"text-xs text-text-muted\">\n No billing account was resolved on this order, so it can&apos;t be retried from here —\n the callback was never able to identify who paid.\n </p>\n )}\n {order.callbackStatus === 'FAILED' && (\n <button\n type=\"button\"\n onClick={() => onRetry(order)}\n disabled={!canRetry || isRetrying}\n className=\"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bgHover disabled:opacity-50\"\n >\n {isRetrying ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <RotateCw className=\"size-4\" />\n )}\n Retry callback\n </button>\n )}\n </div>\n </div>\n </div>\n );\n};\n\nexport const OrderCallbackLogsPage: FC = () => {\n const permissions = useBillingPermissions();\n const [page, setPage] = useState(0);\n const [filters, setFilters] = useState<OrderCallbackFilters>({});\n const [selectedOrder, setSelectedOrder] = useState<OrderCallback | null>(null);\n const [retryError, setRetryError] = useState<string | null>(null);\n\n const { orders, totalCount, isLoading, error, refetch } = useOrderCallbacks(\n filters,\n page,\n PAGE_SIZE\n );\n const { retryOrderCallback, isRetrying } = useOrderCallbackMutations();\n\n if (!permissions.isBillingAdmin) {\n return <AccessDenied message=\"You don't have permission to view order callback logs.\" />;\n }\n\n if (error && isServerError(error)) {\n return (\n <div className=\"p-6\">\n <ServerError\n title=\"Server Unavailable\"\n message=\"Unable to load order callback logs. The server might be down or experiencing issues.\"\n onRetry={() => refetch()}\n showRetry\n />\n </div>\n );\n }\n\n const handleFilterChange = <K extends keyof OrderCallbackFilters>(\n key: K,\n value: OrderCallbackFilters[K]\n ) => {\n setFilters((prev) => ({ ...prev, [key]: value }));\n setPage(0);\n };\n\n const handleRetry = async (order: OrderCallback) => {\n if (!order.billingAccountId) return;\n setRetryError(null);\n try {\n await retryOrderCallback(order.id, order.billingAccountId);\n await refetch();\n setSelectedOrder(null);\n } catch (err) {\n setRetryError(err instanceof Error ? err.message : 'Failed to retry callback');\n }\n };\n\n const columns: ResponsiveTableColumn<OrderCallback>[] = [\n {\n key: 'date',\n header: 'Created',\n priority: 'primary',\n cellClassName: 'whitespace-nowrap',\n cell: (order) => (\n <div className=\"flex flex-col\">\n <span className=\"text-sm text-text-primary\">\n {formatDateTime(order.createdAt).split(' ')[0]}\n </span>\n <span className=\"text-xs text-text-muted\">\n {formatDateTime(order.createdAt).split(' ')[1]}\n </span>\n </div>\n ),\n },\n {\n key: 'callbackStatus',\n header: 'Callback',\n cellClassName: 'whitespace-nowrap',\n cell: (order) => {\n const badge = getBadge(order);\n const BadgeIcon = badge.icon;\n return (\n <span\n className={`inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded ${badge.className}`}\n >\n <BadgeIcon className=\"size-3\" />\n {badge.label}\n </span>\n );\n },\n },\n {\n key: 'service',\n header: 'Service',\n priority: 'hidden-on-mobile',\n cellClassName: 'whitespace-nowrap',\n cell: (order) => <span className=\"text-sm text-text-primary\">{order.externalService}</span>,\n },\n {\n key: 'orderId',\n header: 'Order ID',\n cellClassName: 'whitespace-nowrap max-w-[220px] truncate',\n cell: (order) => (\n <span className=\"text-sm font-mono text-text-muted\" title={order.id}>\n {order.id}\n </span>\n ),\n },\n {\n key: 'attempts',\n header: 'Attempts',\n priority: 'hidden-on-mobile',\n cellClassName: 'whitespace-nowrap',\n cell: (order) => (\n <span className=\"text-sm text-text-secondary\">{order.callbackAttempts ?? 0}</span>\n ),\n },\n {\n key: 'error',\n header: 'Error',\n priority: 'hidden-on-mobile',\n cellClassName: 'max-w-[280px] truncate',\n cell: (order) => (\n <span className=\"text-sm text-status-error-text\">{order.callbackLastError || '-'}</span>\n ),\n },\n ];\n\n const totalPages = Math.max(1, Math.ceil(totalCount / PAGE_SIZE));\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title=\"Order Callback Logs\"\n description=\"Every billing→store (and other external service) order-completion callback — investigate a stuck handoff directly.\"\n actions={\n <button\n type=\"button\"\n onClick={() => refetch()}\n className=\"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50\"\n >\n <RefreshCw className=\"size-4\" />\n Refresh\n </button>\n }\n />\n\n {retryError && (\n <div className=\"p-3 rounded-md bg-status-error-bg-subtle text-status-error-text border border-status-error-border text-sm\">\n {retryError}\n </div>\n )}\n\n {/* Filters */}\n <div className=\"p-4 border border-border-subtle rounded-lg bg-bg-sunken/30 grid grid-cols-1 sm:grid-cols-3 gap-4\">\n <div>\n <label className=\"block text-sm font-medium mb-1\">Callback status</label>\n <ThemedSelect\n value={filters.callbackStatus || ''}\n onChange={(e) => handleFilterChange('callbackStatus', e.target.value || undefined)}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"\">All</option>\n {CALLBACK_STATUS_OPTIONS.map((s) => (\n <option key={s} value={s}>\n {s}\n </option>\n ))}\n </ThemedSelect>\n </div>\n <div>\n <label className=\"block text-sm font-medium mb-1\">Service</label>\n <input\n type=\"text\"\n value={filters.externalService || ''}\n onChange={(e) => handleFilterChange('externalService', e.target.value || undefined)}\n placeholder=\"e.g. STORE\"\n className=\"w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface\"\n />\n </div>\n <div>\n <label className=\"block text-sm font-medium mb-1\">Has Error</label>\n <ThemedSelect\n value={filters.hasError === undefined ? '' : String(filters.hasError)}\n onChange={(e) =>\n handleFilterChange(\n 'hasError',\n e.target.value === '' ? undefined : e.target.value === 'true'\n )\n }\n className=\"w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"\">All</option>\n <option value=\"true\">Has error</option>\n <option value=\"false\">No error</option>\n </ThemedSelect>\n </div>\n </div>\n\n {/* Table */}\n {isLoading && orders.length === 0 ? (\n <div className=\"space-y-2\">\n {[1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"h-16 bg-bg-sunken animate-pulse rounded\" />\n ))}\n </div>\n ) : orders.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title=\"No order callbacks found\"\n description=\"Nothing matches these filters — try widening them, or check back after the next store purchase.\"\n kind={\n Object.values(filters).some((value) => value !== undefined && value !== '')\n ? 'filtered'\n : 'first-use'\n }\n />\n ) : (\n <div className=\"border border-border-subtle rounded-lg overflow-hidden\">\n <ResponsiveTable<OrderCallback>\n columns={columns}\n data={orders}\n rowKey={(order) => order.id}\n rowActions={(order) => (\n <button\n type=\"button\"\n onClick={() => setSelectedOrder(order)}\n className=\"inline-flex items-center gap-1.5 px-2 py-1 text-sm font-medium rounded-button text-text-secondary hover:text-text-primary hover:bg-bg-sunken/60 transition-colors\"\n >\n <Eye className=\"size-4\" />\n <span className=\"hidden sm:inline\">View</span>\n </button>\n )}\n />\n </div>\n )}\n\n {/* Pagination */}\n {totalCount > 0 && (\n <div className=\"flex flex-col sm:flex-row items-center justify-between gap-4 border-t border-border-subtle pt-4\">\n <p className=\"text-sm text-text-muted text-center sm:text-left\">\n Showing {page * PAGE_SIZE + 1} to {Math.min((page + 1) * PAGE_SIZE, totalCount)} of{' '}\n {totalCount} orders\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => setPage((p) => Math.max(0, p - 1))}\n disabled={page === 0}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-button border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors\"\n >\n <ChevronLeft className=\"size-4\" />\n <span className=\"hidden sm:inline\">Previous</span>\n </button>\n <span className=\"text-sm text-text-muted px-2\">\n <span className=\"hidden sm:inline\">Page </span>\n {page + 1} <span className=\"hidden sm:inline\">of</span>\n <span className=\"sm:hidden\">/</span> {totalPages}\n </span>\n <button\n type=\"button\"\n onClick={() => setPage((p) => (p + 1 < totalPages ? p + 1 : p))}\n disabled={page + 1 >= totalPages}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-button border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors\"\n >\n <span className=\"hidden sm:inline\">Next</span>\n <ChevronRight className=\"size-4\" />\n </button>\n </div>\n </div>\n )}\n\n <OrderCallbackDetailModal\n order={selectedOrder}\n onClose={() => setSelectedOrder(null)}\n onRetry={handleRetry}\n isRetrying={isRetrying}\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAwCA,IAAMA,IAAY,IACZC,IAA0B;CAAC;CAAW;CAAW;AAAQ,GAEzDC,KACJ,MAEIC,EAAM,mBAAmB,WACpB;CACL,OAAO;CACP,WAAW,GAAGC,EAAa,MAAM,GAAG,GAAGA,EAAa,MAAM;CAC1D,MAAMC;AACR,IAEEF,EAAM,mBAAmB,YACpB;CACL,OAAO;CACP,WAAW,GAAGC,EAAa,QAAQ,GAAG,GAAGA,EAAa,QAAQ;CAC9D,MAAME;AACR,IAEK;CACL,OAAOH,EAAM,kBAAkB;CAC/B,WAAW,GAAGC,EAAa,QAAQ,GAAG,GAAGA,EAAa,QAAQ;CAC9D,MAAMG;AACR,GAGIC,KAKA,EAAE,UAAO,YAAS,YAAS,oBAAiB;CAChD,IAAI,CAACL,GAAO,OAAO;CAEnB,IAAMM,IAAWN,EAAM,mBAAmB,YAAY,EAAQA,EAAM;CAEpE,OACE,kBAAC,OAAD;EAAK,WAAU;EACb,UAAA,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,MAAD;KAAI,WAAU;KAA4C,UAAA;IAA0B,CAAA,GACpF,kBAAC,UAAD;KACE,MAAK;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,WAAU,SAAU,CAAA,GACjC,kBAAC,QAAD;QAAM,WAAU;QAAmB,UAAA;OAAc,CAAA,CAC3C;;MACR,kBAAC,QAAD;OAAM,WAAU;OAAhB,UAAA;QACE,kBAAC,QAAD;SAAM,WAAU;SAAmB,UAAA;QAAW,CAAA;QAC7CvC,IAAO;QAAE;QAAC,kBAAC,QAAD;SAAM,WAAU;SAAmB,UAAA;QAAQ,CAAA;QACtD,kBAAC,QAAD;SAAM,WAAU;SAAY,UAAA;QAAO,CAAA;QAAC;QAAE0B;OAClC;;MACN,kBAAC,UAAD;OACE,MAAK;OACL,eAAezB,GAAS,MAAOqC,IAAI,IAAIZ,IAAaY,IAAI,IAAIA,CAAE;OAC9D,UAAUtC,IAAO,KAAK0B;OACtB,WAAU;OAJZ,UAAA,CAME,kBAAC,QAAD;QAAM,WAAU;QAAmB,UAAA;OAAU,CAAA,GAC7C,kBAACc,GAAD,EAAc,WAAU,SAAU,CAAA,CAC5B;;KACL;IACF,CAAA,CAAA;;GAGP,kBAACpD,GAAD;IACE,OAAOiB;IACP,eAAeC,EAAiB,IAAI;IACpC,SAASc;IACG;GACb,CAAA;EACE;;AAET"}
@@ -117,7 +117,8 @@ var x = {
117
117
  onClick: () => P(!0),
118
118
  className: "px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-md hover:bg-action-primary-bg/90",
119
119
  children: "Add Payment Method"
120
- }) : void 0
120
+ }) : void 0,
121
+ glassIllustration: "money"
121
122
  }) : /* @__PURE__ */ v("div", {
122
123
  className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",
123
124
  children: O.map((e) => /* @__PURE__ */ v(w, {
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentMethodsPage.js","names":["CARD_ICONS","METHOD_TYPE_LABELS","PaymentMethodsPage","useI18n","tr","translated","t","key","fallback","permissions","useBillingPermissions","useBillingEventEmitter","useBilling","useLocation","useDefaultDashboardAccount","useDashboardMutations","showAddModal","setShowAddModal","useState","actionError","setActionError","toFullPath","useCallback","basePath","path","navigateToAdd","navigate","handleSetDefault","billingAccountId","billingAccount","setDefaultPaymentMethod","paymentMethodId","refetch","nativeNotify","emit","error","handleDelete","deletePaymentMethod","useEffect","pathname","isLoading","i","PageHeader","PagePurpose","paymentMethods","IllustratedEmptyState","PaymentMethodCard","method","AddPaymentMethodModal","toast","AccessDenied","isSettingDefault","setIsSettingDefault","isDeleting","setIsDeleting","isConfirmingDelete","setIsConfirmingDelete","isExpired","onSetDefault","onDelete","canManage","confirmed","nativeConfirm"],"sources":["../../../../../src/billing/modules/billing/pages/PaymentMethodsPage.tsx"],"sourcesContent":["/**\n * Billing Module - Payment Methods Page\n * Displays and manages payment methods\n */\n\nimport { useCallback, useEffect, useState, type FC } from 'react';\nimport { useLocation } from 'react-router';\nimport { toast } from 'sonner';\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useDashboardMutations, useDefaultDashboardAccount } from '../../dashboard/hooks';\nimport { AccessDenied, PageHeader } from '../../../shared/components';\nimport { AddPaymentMethodModal } from '../../dashboard/components/AddPaymentMethodModal';\nimport { nativeConfirm, nativeImpact, nativeNotify } from '../../../../utils/nativeBridge';\nimport type { PaymentMethod, PaymentMethodType } from '../../../shared/types';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PagePurpose, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\n\nconst CARD_ICONS: Record<string, string> = {\n visa: '💳',\n mastercard: '💳',\n amex: '💳',\n default: '💳',\n};\n\nconst METHOD_TYPE_LABELS: Record<PaymentMethodType, string> = {\n CREDIT_CARD: 'Credit Card',\n DEBIT_CARD: 'Debit Card',\n WALLET: 'Digital Wallet',\n NETBANKING: 'Net Banking',\n BANK_TRANSFER: 'Bank Transfer',\n PAYPAL: 'PayPal',\n CRYPTO: 'Cryptocurrency',\n};\n\nexport const PaymentMethodsPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const permissions = useBillingPermissions();\n const { emit } = useBillingEventEmitter();\n const { navigate, basePath } = useBilling();\n const { pathname } = useLocation();\n const { billingAccount, paymentMethods, isLoading, refetch } = useDefaultDashboardAccount();\n const { setDefaultPaymentMethod, deletePaymentMethod } = useDashboardMutations();\n const [showAddModal, setShowAddModal] = useState(false);\n const [actionError, setActionError] = useState<string | null>(null);\n\n // basePath-aware path join, mirroring OverviewPage's navigateTo helper.\n const toFullPath = useCallback(\n (path: string) => {\n if (basePath && basePath !== '/') {\n const base = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;\n return `${base}/${path}`;\n }\n return `/${path}`;\n },\n [basePath]\n );\n\n // Navigate (basePath-aware) to the dedicated add-payment-method route.\n const navigateToAdd = useCallback(() => {\n navigate(toFullPath('payment-methods/add'));\n }, [navigate, toFullPath]);\n\n const handleSetDefault = useCallback(\n async (paymentMethodId: string): Promise<void> => {\n const billingAccountId = billingAccount?.id;\n if (!billingAccountId) {\n setActionError('No billing account context');\n return;\n }\n\n setActionError(null);\n try {\n await setDefaultPaymentMethod(paymentMethodId, billingAccountId);\n await refetch();\n void nativeNotify('success');\n emit('billing.payment_method.default_set', {\n route: '/billing/payment-methods',\n entityId: paymentMethodId,\n source: 'payment-methods',\n });\n } catch (error) {\n setActionError(\n error instanceof Error ? error.message : 'Failed to set default payment method'\n );\n void nativeNotify('error');\n }\n },\n [billingAccount?.id, emit, refetch, setDefaultPaymentMethod]\n );\n\n const handleDelete = useCallback(\n async (paymentMethodId: string): Promise<void> => {\n const billingAccountId = billingAccount?.id;\n if (!billingAccountId) {\n setActionError('No billing account context');\n return;\n }\n\n setActionError(null);\n try {\n await deletePaymentMethod(paymentMethodId, billingAccountId);\n await refetch();\n void nativeNotify('success');\n emit('billing.payment_method.deleted', {\n route: '/billing/payment-methods',\n entityId: paymentMethodId,\n source: 'payment-methods',\n });\n } catch (error) {\n setActionError(error instanceof Error ? error.message : 'Failed to remove payment method');\n void nativeNotify('error');\n }\n },\n [billingAccount?.id, deletePaymentMethod, emit, refetch]\n );\n\n // The /payment-methods/add route renders this same page; open the add modal\n // automatically when landing there so the route is actually functional.\n useEffect(() => {\n if (pathname.replace(/\\/+$/, '').endsWith('/payment-methods/add')) {\n setShowAddModal(true);\n }\n }, [pathname]);\n\n if (!permissions.canViewPaymentMethods) {\n return (\n <AccessDenied\n message={tr(\n 'billing.paymentMethods.noViewPermission',\n \"You don't have permission to view payment methods.\"\n )}\n />\n );\n }\n\n if (isLoading) {\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"h-8 w-48 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4\">\n {[1, 2, 3].map((i) => (\n <div key={i} className=\"h-32 bg-bg-sunken animate-pulse rounded-lg\" />\n ))}\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title={tr('billing.paymentMethods.title', 'Payment Methods')}\n description={tr('billing.paymentMethods.subtitle', 'Manage your saved payment methods')}\n actions={\n permissions.canManagePaymentMethods && (\n <button\n type=\"button\"\n onClick={navigateToAdd}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-md hover:bg-action-primary-bg/90 transition-colors\"\n >\n {tr('billing.paymentMethods.add', 'Add payment method')}\n </button>\n )\n }\n />\n\n <PagePurpose>\n {tr(\n 'billing.paymentMethods.purpose',\n 'Save and manage the cards and payment options used to pay invoices, subscriptions and one-off purchases. Add a method, mark one as default for automatic billing, or remove ones you no longer use.'\n )}\n </PagePurpose>\n\n {actionError && (\n <div className=\"rounded-button border border-status-error-border bg-status-error-bg-subtle p-3\">\n <p className=\"text-sm text-status-error-text\">{actionError}</p>\n </div>\n )}\n\n {/* Payment Methods List */}\n {paymentMethods.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-generic\"\n title={tr('billing.paymentMethods.noPaymentMethods', 'No payment methods')}\n description={tr(\n 'billing.paymentMethods.noPaymentMethodsDesc',\n 'Add a payment method to make purchases and manage subscriptions.'\n )}\n action={\n permissions.canManagePaymentMethods ? (\n <button\n type=\"button\"\n onClick={() => setShowAddModal(true)}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-md hover:bg-action-primary-bg/90\"\n >\n Add Payment Method\n </button>\n ) : undefined\n }\n />\n ) : (\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4\">\n {paymentMethods.map((method) => (\n <PaymentMethodCard\n key={method.id}\n method={method}\n canManage={permissions.canManagePaymentMethods}\n onSetDefault={handleSetDefault}\n onDelete={handleDelete}\n />\n ))}\n </div>\n )}\n\n {/* Add Payment Method Modal (Stripe + Razorpay) */}\n <AddPaymentMethodModal\n isOpen={showAddModal}\n onClose={() => {\n setShowAddModal(false);\n // If we arrived via the /add route, return to the list URL.\n if (pathname.replace(/\\/+$/, '').endsWith('/payment-methods/add')) {\n navigate(toFullPath('payment-methods'));\n }\n }}\n billingAccountId={billingAccount?.id ?? ''}\n currency={billingAccount?.currency ?? 'USD'}\n country={billingAccount?.billingAddresses?.[0]?.country ?? undefined}\n onSuccess={() => {\n emit('billing.payment_method.added', {\n route: '/billing/payment-methods',\n entityId: billingAccount?.id,\n source: 'payment-methods',\n });\n setActionError(null);\n void nativeNotify('success');\n toast.success('Payment method added successfully');\n setShowAddModal(false);\n if (pathname.replace(/\\/+$/, '').endsWith('/payment-methods/add')) {\n navigate(toFullPath('payment-methods'));\n }\n // The new PaymentMethod row is created by the provider's webhook\n // (e.g. Stripe's setup_intent.succeeded), which can land a beat\n // after the client-side confirm resolves — a single immediate\n // refetch can race it and show the stale list. Refetch again\n // shortly after as a safety net so the new card reliably appears\n // without the user needing to manually reload the page.\n void refetch();\n setTimeout(() => {\n void refetch();\n }, 2500);\n }}\n />\n </div>\n );\n};\n\n// ============================================================================\n// Payment Method Card Component\n// ============================================================================\n\ninterface PaymentMethodCardProps {\n method: PaymentMethod;\n canManage: boolean;\n onSetDefault: (id: string) => Promise<void>;\n onDelete: (id: string) => Promise<void>;\n}\n\nconst PaymentMethodCard: FC<PaymentMethodCardProps> = ({\n method,\n canManage,\n onSetDefault,\n onDelete,\n}) => {\n const [isSettingDefault, setIsSettingDefault] = useState(false);\n const [isDeleting, setIsDeleting] = useState(false);\n const [isConfirmingDelete, setIsConfirmingDelete] = useState(false);\n const isExpired =\n method.expiryYear && method.expiryMonth\n ? new Date(method.expiryYear, method.expiryMonth - 1) < new Date()\n : false;\n\n const handleSetDefault = async () => {\n setIsSettingDefault(true);\n try {\n await onSetDefault(method.id);\n } finally {\n setIsSettingDefault(false);\n }\n };\n\n const handleDelete = async () => {\n setIsDeleting(true);\n try {\n await onDelete(method.id);\n } finally {\n setIsDeleting(false);\n setIsConfirmingDelete(false);\n }\n };\n\n const handleDeleteRequest = async () => {\n void nativeImpact('medium');\n const confirmed = await nativeConfirm({\n title: 'Delete payment method',\n message: 'Are you sure you want to remove this payment method?',\n okButtonTitle: 'Delete',\n cancelButtonTitle: 'Cancel',\n });\n\n if (confirmed === true) {\n await handleDelete();\n } else if (confirmed === null) {\n setIsConfirmingDelete(true);\n }\n };\n\n return (\n <div\n className={`border rounded-lg bg-bg-surface p-4 ${\n method.isDefault ? 'border-primary' : 'border-border-subtle'\n }`}\n >\n <div className=\"flex items-start justify-between\">\n <div className=\"flex items-center gap-3\">\n <span className=\"text-2xl\">{CARD_ICONS[method.brand?.toLowerCase() ?? 'default']}</span>\n <div>\n <div className=\"flex items-center gap-2\">\n <p className=\"font-medium text-text-primary\">\n {method.brand ?? METHOD_TYPE_LABELS[method.type]} •••• {method.last4}\n </p>\n {method.isDefault && (\n <span className=\"px-1.5 py-0.5 text-xs font-medium bg-action-primary-bg/10 text-primary rounded\">\n Default\n </span>\n )}\n </div>\n {method.expiryMonth && method.expiryYear && (\n <p\n className={`text-sm ${isExpired ? 'text-status-error-text' : 'text-text-secondary'}`}\n >\n {isExpired ? 'Expired' : 'Expires'} {method.expiryMonth}/{method.expiryYear}\n </p>\n )}\n </div>\n </div>\n </div>\n\n {canManage && (\n <div className=\"flex items-center gap-2 mt-4 pt-4 border-t border-border-subtle\">\n {!method.isDefault && (\n <button\n type=\"button\"\n onClick={handleSetDefault}\n disabled={isSettingDefault || isDeleting}\n className=\"text-sm text-primary hover:underline disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {isSettingDefault ? 'Setting default…' : 'Set as default'}\n </button>\n )}\n <button\n type=\"button\"\n onClick={handleDeleteRequest}\n disabled={isSettingDefault || isDeleting}\n className=\"text-sm text-status-error-text hover:underline ml-auto disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {isDeleting ? 'Removing…' : 'Remove'}\n </button>\n </div>\n )}\n\n {isConfirmingDelete && (\n <div className=\"mt-4 rounded-lg border border-status-error-border bg-status-error-bg-subtle p-3\">\n <p className=\"text-sm font-medium text-status-error-text\">\n Remove this payment method from your billing account?\n </p>\n <div className=\"mt-3 flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={() => setIsConfirmingDelete(false)}\n className=\"rounded-button border border-border-subtle bg-bg-surface px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={handleDelete}\n disabled={isDeleting}\n className=\"rounded-button bg-action-danger-bg px-3 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-danger-bgHover disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {isDeleting ? 'Removing…' : 'Remove'}\n </button>\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,IAAMA,IAAqC;CACzC,MAAM;CACN,YAAY;CACZ,MAAM;CACN,SAAS;AACX,GAEMC,IAAwD;CAC5D,aAAa;CACb,YAAY;CACZ,QAAQ;CACR,YAAY;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D;IAAK,WAAU;IAAf,UAAA,CACG,CAACb,EAAO,aACP,kBAAC,UAAD;KACE,MAAK;KACL,SAASpB;KACT,UAAUwB,KAAoBE;KAC9B,WAAU;KAET,UAAAF,IAAmB,qBAAqB;IACnC,CAAA,GAEV,kBAAC,UAAD;KACE,MAAK;KACL,SAAS,YA7DqB;MACtC,EAAkB,QAAQ;MAC1B,IAAMU,IAAY,MAAMC,EAAc;OACpC,OAAO;OACP,SAAS;OACT,eAAe;OACf,mBAAmB;MACrB,CAAC;MAED,AAAID,MAAc,KAChB,MAAMzB,EAAa,IACVyB,MAAc,QACvBL,EAAsB,EAAI;KAE9B;KAgDU,UAAUL,KAAoBE;KAC9B,WAAU;KAET,UAAAA,IAAa,cAAc;IACtB,CAAA,CACL;;GAGNE,KACC,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,KAAD;KAAG,WAAU;KAA6C,UAAA;IAEvD,CAAA,GACH,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,kBAAC,UAAD;MACE,MAAK;MACL,eAAeC,EAAsB,EAAK;MAC1C,WAAU;MACX,UAAA;KAEO,CAAA,GACR,kBAAC,UAAD;MACE,MAAK;MACL,SAASpB;MACT,UAAUiB;MACV,WAAU;MAET,UAAAA,IAAa,cAAc;KACtB,CAAA,CACL;IACF,CAAA,CAAA;;EAEJ;;AAET"}
1
+ {"version":3,"file":"PaymentMethodsPage.js","names":["CARD_ICONS","METHOD_TYPE_LABELS","PaymentMethodsPage","useI18n","tr","translated","t","key","fallback","permissions","useBillingPermissions","useBillingEventEmitter","useBilling","useLocation","useDefaultDashboardAccount","useDashboardMutations","showAddModal","setShowAddModal","useState","actionError","setActionError","toFullPath","useCallback","basePath","path","navigateToAdd","navigate","handleSetDefault","billingAccountId","billingAccount","setDefaultPaymentMethod","paymentMethodId","refetch","nativeNotify","emit","error","handleDelete","deletePaymentMethod","useEffect","pathname","isLoading","i","PageHeader","PagePurpose","paymentMethods","IllustratedEmptyState","PaymentMethodCard","method","AddPaymentMethodModal","toast","AccessDenied","isSettingDefault","setIsSettingDefault","isDeleting","setIsDeleting","isConfirmingDelete","setIsConfirmingDelete","isExpired","onSetDefault","onDelete","canManage","confirmed","nativeConfirm"],"sources":["../../../../../src/billing/modules/billing/pages/PaymentMethodsPage.tsx"],"sourcesContent":["/**\n * Billing Module - Payment Methods Page\n * Displays and manages payment methods\n */\n\nimport { useCallback, useEffect, useState, type FC } from 'react';\nimport { useLocation } from 'react-router';\nimport { toast } from 'sonner';\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useDashboardMutations, useDefaultDashboardAccount } from '../../dashboard/hooks';\nimport { AccessDenied, PageHeader } from '../../../shared/components';\nimport { AddPaymentMethodModal } from '../../dashboard/components/AddPaymentMethodModal';\nimport { nativeConfirm, nativeImpact, nativeNotify } from '../../../../utils/nativeBridge';\nimport type { PaymentMethod, PaymentMethodType } from '../../../shared/types';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PagePurpose, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\n\nconst CARD_ICONS: Record<string, string> = {\n visa: '💳',\n mastercard: '💳',\n amex: '💳',\n default: '💳',\n};\n\nconst METHOD_TYPE_LABELS: Record<PaymentMethodType, string> = {\n CREDIT_CARD: 'Credit Card',\n DEBIT_CARD: 'Debit Card',\n WALLET: 'Digital Wallet',\n NETBANKING: 'Net Banking',\n BANK_TRANSFER: 'Bank Transfer',\n PAYPAL: 'PayPal',\n CRYPTO: 'Cryptocurrency',\n};\n\nexport const PaymentMethodsPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const permissions = useBillingPermissions();\n const { emit } = useBillingEventEmitter();\n const { navigate, basePath } = useBilling();\n const { pathname } = useLocation();\n const { billingAccount, paymentMethods, isLoading, refetch } = useDefaultDashboardAccount();\n const { setDefaultPaymentMethod, deletePaymentMethod } = useDashboardMutations();\n const [showAddModal, setShowAddModal] = useState(false);\n const [actionError, setActionError] = useState<string | null>(null);\n\n // basePath-aware path join, mirroring OverviewPage's navigateTo helper.\n const toFullPath = useCallback(\n (path: string) => {\n if (basePath && basePath !== '/') {\n const base = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;\n return `${base}/${path}`;\n }\n return `/${path}`;\n },\n [basePath]\n );\n\n // Navigate (basePath-aware) to the dedicated add-payment-method route.\n const navigateToAdd = useCallback(() => {\n navigate(toFullPath('payment-methods/add'));\n }, [navigate, toFullPath]);\n\n const handleSetDefault = useCallback(\n async (paymentMethodId: string): Promise<void> => {\n const billingAccountId = billingAccount?.id;\n if (!billingAccountId) {\n setActionError('No billing account context');\n return;\n }\n\n setActionError(null);\n try {\n await setDefaultPaymentMethod(paymentMethodId, billingAccountId);\n await refetch();\n void nativeNotify('success');\n emit('billing.payment_method.default_set', {\n route: '/billing/payment-methods',\n entityId: paymentMethodId,\n source: 'payment-methods',\n });\n } catch (error) {\n setActionError(\n error instanceof Error ? error.message : 'Failed to set default payment method'\n );\n void nativeNotify('error');\n }\n },\n [billingAccount?.id, emit, refetch, setDefaultPaymentMethod]\n );\n\n const handleDelete = useCallback(\n async (paymentMethodId: string): Promise<void> => {\n const billingAccountId = billingAccount?.id;\n if (!billingAccountId) {\n setActionError('No billing account context');\n return;\n }\n\n setActionError(null);\n try {\n await deletePaymentMethod(paymentMethodId, billingAccountId);\n await refetch();\n void nativeNotify('success');\n emit('billing.payment_method.deleted', {\n route: '/billing/payment-methods',\n entityId: paymentMethodId,\n source: 'payment-methods',\n });\n } catch (error) {\n setActionError(error instanceof Error ? error.message : 'Failed to remove payment method');\n void nativeNotify('error');\n }\n },\n [billingAccount?.id, deletePaymentMethod, emit, refetch]\n );\n\n // The /payment-methods/add route renders this same page; open the add modal\n // automatically when landing there so the route is actually functional.\n useEffect(() => {\n if (pathname.replace(/\\/+$/, '').endsWith('/payment-methods/add')) {\n setShowAddModal(true);\n }\n }, [pathname]);\n\n if (!permissions.canViewPaymentMethods) {\n return (\n <AccessDenied\n message={tr(\n 'billing.paymentMethods.noViewPermission',\n \"You don't have permission to view payment methods.\"\n )}\n />\n );\n }\n\n if (isLoading) {\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"h-8 w-48 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4\">\n {[1, 2, 3].map((i) => (\n <div key={i} className=\"h-32 bg-bg-sunken animate-pulse rounded-lg\" />\n ))}\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title={tr('billing.paymentMethods.title', 'Payment Methods')}\n description={tr('billing.paymentMethods.subtitle', 'Manage your saved payment methods')}\n actions={\n permissions.canManagePaymentMethods && (\n <button\n type=\"button\"\n onClick={navigateToAdd}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-md hover:bg-action-primary-bg/90 transition-colors\"\n >\n {tr('billing.paymentMethods.add', 'Add payment method')}\n </button>\n )\n }\n />\n\n <PagePurpose>\n {tr(\n 'billing.paymentMethods.purpose',\n 'Save and manage the cards and payment options used to pay invoices, subscriptions and one-off purchases. Add a method, mark one as default for automatic billing, or remove ones you no longer use.'\n )}\n </PagePurpose>\n\n {actionError && (\n <div className=\"rounded-button border border-status-error-border bg-status-error-bg-subtle p-3\">\n <p className=\"text-sm text-status-error-text\">{actionError}</p>\n </div>\n )}\n\n {/* Payment Methods List */}\n {paymentMethods.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-generic\"\n title={tr('billing.paymentMethods.noPaymentMethods', 'No payment methods')}\n description={tr(\n 'billing.paymentMethods.noPaymentMethodsDesc',\n 'Add a payment method to make purchases and manage subscriptions.'\n )}\n action={\n permissions.canManagePaymentMethods ? (\n <button\n type=\"button\"\n onClick={() => setShowAddModal(true)}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-md hover:bg-action-primary-bg/90\"\n >\n Add Payment Method\n </button>\n ) : undefined\n }\n glassIllustration=\"money\"\n />\n ) : (\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4\">\n {paymentMethods.map((method) => (\n <PaymentMethodCard\n key={method.id}\n method={method}\n canManage={permissions.canManagePaymentMethods}\n onSetDefault={handleSetDefault}\n onDelete={handleDelete}\n />\n ))}\n </div>\n )}\n\n {/* Add Payment Method Modal (Stripe + Razorpay) */}\n <AddPaymentMethodModal\n isOpen={showAddModal}\n onClose={() => {\n setShowAddModal(false);\n // If we arrived via the /add route, return to the list URL.\n if (pathname.replace(/\\/+$/, '').endsWith('/payment-methods/add')) {\n navigate(toFullPath('payment-methods'));\n }\n }}\n billingAccountId={billingAccount?.id ?? ''}\n currency={billingAccount?.currency ?? 'USD'}\n country={billingAccount?.billingAddresses?.[0]?.country ?? undefined}\n onSuccess={() => {\n emit('billing.payment_method.added', {\n route: '/billing/payment-methods',\n entityId: billingAccount?.id,\n source: 'payment-methods',\n });\n setActionError(null);\n void nativeNotify('success');\n toast.success('Payment method added successfully');\n setShowAddModal(false);\n if (pathname.replace(/\\/+$/, '').endsWith('/payment-methods/add')) {\n navigate(toFullPath('payment-methods'));\n }\n // The new PaymentMethod row is created by the provider's webhook\n // (e.g. Stripe's setup_intent.succeeded), which can land a beat\n // after the client-side confirm resolves — a single immediate\n // refetch can race it and show the stale list. Refetch again\n // shortly after as a safety net so the new card reliably appears\n // without the user needing to manually reload the page.\n void refetch();\n setTimeout(() => {\n void refetch();\n }, 2500);\n }}\n />\n </div>\n );\n};\n\n// ============================================================================\n// Payment Method Card Component\n// ============================================================================\n\ninterface PaymentMethodCardProps {\n method: PaymentMethod;\n canManage: boolean;\n onSetDefault: (id: string) => Promise<void>;\n onDelete: (id: string) => Promise<void>;\n}\n\nconst PaymentMethodCard: FC<PaymentMethodCardProps> = ({\n method,\n canManage,\n onSetDefault,\n onDelete,\n}) => {\n const [isSettingDefault, setIsSettingDefault] = useState(false);\n const [isDeleting, setIsDeleting] = useState(false);\n const [isConfirmingDelete, setIsConfirmingDelete] = useState(false);\n const isExpired =\n method.expiryYear && method.expiryMonth\n ? new Date(method.expiryYear, method.expiryMonth - 1) < new Date()\n : false;\n\n const handleSetDefault = async () => {\n setIsSettingDefault(true);\n try {\n await onSetDefault(method.id);\n } finally {\n setIsSettingDefault(false);\n }\n };\n\n const handleDelete = async () => {\n setIsDeleting(true);\n try {\n await onDelete(method.id);\n } finally {\n setIsDeleting(false);\n setIsConfirmingDelete(false);\n }\n };\n\n const handleDeleteRequest = async () => {\n void nativeImpact('medium');\n const confirmed = await nativeConfirm({\n title: 'Delete payment method',\n message: 'Are you sure you want to remove this payment method?',\n okButtonTitle: 'Delete',\n cancelButtonTitle: 'Cancel',\n });\n\n if (confirmed === true) {\n await handleDelete();\n } else if (confirmed === null) {\n setIsConfirmingDelete(true);\n }\n };\n\n return (\n <div\n className={`border rounded-lg bg-bg-surface p-4 ${\n method.isDefault ? 'border-primary' : 'border-border-subtle'\n }`}\n >\n <div className=\"flex items-start justify-between\">\n <div className=\"flex items-center gap-3\">\n <span className=\"text-2xl\">{CARD_ICONS[method.brand?.toLowerCase() ?? 'default']}</span>\n <div>\n <div className=\"flex items-center gap-2\">\n <p className=\"font-medium text-text-primary\">\n {method.brand ?? METHOD_TYPE_LABELS[method.type]} •••• {method.last4}\n </p>\n {method.isDefault && (\n <span className=\"px-1.5 py-0.5 text-xs font-medium bg-action-primary-bg/10 text-primary rounded\">\n Default\n </span>\n )}\n </div>\n {method.expiryMonth && method.expiryYear && (\n <p\n className={`text-sm ${isExpired ? 'text-status-error-text' : 'text-text-secondary'}`}\n >\n {isExpired ? 'Expired' : 'Expires'} {method.expiryMonth}/{method.expiryYear}\n </p>\n )}\n </div>\n </div>\n </div>\n\n {canManage && (\n <div className=\"flex items-center gap-2 mt-4 pt-4 border-t border-border-subtle\">\n {!method.isDefault && (\n <button\n type=\"button\"\n onClick={handleSetDefault}\n disabled={isSettingDefault || isDeleting}\n className=\"text-sm text-primary hover:underline disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {isSettingDefault ? 'Setting default…' : 'Set as default'}\n </button>\n )}\n <button\n type=\"button\"\n onClick={handleDeleteRequest}\n disabled={isSettingDefault || isDeleting}\n className=\"text-sm text-status-error-text hover:underline ml-auto disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {isDeleting ? 'Removing…' : 'Remove'}\n </button>\n </div>\n )}\n\n {isConfirmingDelete && (\n <div className=\"mt-4 rounded-lg border border-status-error-border bg-status-error-bg-subtle p-3\">\n <p className=\"text-sm font-medium text-status-error-text\">\n Remove this payment method from your billing account?\n </p>\n <div className=\"mt-3 flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={() => setIsConfirmingDelete(false)}\n className=\"rounded-button border border-border-subtle bg-bg-surface px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={handleDelete}\n disabled={isDeleting}\n className=\"rounded-button bg-action-danger-bg px-3 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-danger-bgHover disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {isDeleting ? 'Removing…' : 'Remove'}\n </button>\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,IAAMA,IAAqC;CACzC,MAAM;CACN,YAAY;CACZ,MAAM;CACN,SAAS;AACX,GAEMC,IAAwD;CAC5D,aAAa;CACb,YAAY;CACZ,QAAQ;CACR,YAAY;CACZ,eAAe;CACf,QAAQ;CACR,QAAQ;AACV,GAEaC,UAA+B;CAC1C,IAAM,EAAE,SAAMC,EAAQ,GAChBC,KAAM,GAAa,MAA6B;EACpD,IAAMC,IAAaC,EAAEC,CAAG;EACxB,OAAOF,MAAeE,IAA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GAEV,kBAAC,UAAD;KACE,MAAK;KACL,SAAS,YA7DqB;MACtC,EAAkB,QAAQ;MAC1B,IAAMU,IAAY,MAAMC,EAAc;OACpC,OAAO;OACP,SAAS;OACT,eAAe;OACf,mBAAmB;MACrB,CAAC;MAED,AAAID,MAAc,KAChB,MAAMzB,EAAa,IACVyB,MAAc,QACvBL,EAAsB,EAAI;KAE9B;KAgDU,UAAUL,KAAoBE;KAC9B,WAAU;KAET,UAAAA,IAAa,cAAc;IACtB,CAAA,CACL;;GAGNE,KACC,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,KAAD;KAAG,WAAU;KAA6C,UAAA;IAEvD,CAAA,GACH,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,kBAAC,UAAD;MACE,MAAK;MACL,eAAeC,EAAsB,EAAK;MAC1C,WAAU;MACX,UAAA;KAEO,CAAA,GACR,kBAAC,UAAD;MACE,MAAK;MACL,SAASpB;MACT,UAAUiB;MACV,WAAU;MAET,UAAAA,IAAa,cAAc;KACtB,CAAA,CACL;IACF,CAAA,CAAA;;EAEJ;;AAET"}
@@ -178,7 +178,8 @@ var S = 25, C = 350, w = () => {
178
178
  }) : A.length === 0 ? /* @__PURE__ */ b(f, {
179
179
  illustration: D ? "empty-search" : "empty-data",
180
180
  title: D ? "No matching refund issues" : "No open refund issues",
181
- description: D ? `Nothing matched "${D}". Try the transaction ID, refund ID, or a payment/refund ID from the gateway.` : "Every completed refund reconciled cleanly — nothing here needs follow-up right now."
181
+ description: D ? `Nothing matched "${D}". Try the transaction ID, refund ID, or a payment/refund ID from the gateway.` : "Every completed refund reconciled cleanly — nothing here needs follow-up right now.",
182
+ kind: D ? "no-results" : "all-done"
182
183
  }) : /* @__PURE__ */ b("div", {
183
184
  className: "border border-border-subtle rounded-lg overflow-hidden",
184
185
  children: /* @__PURE__ */ b(p, {
@@ -1 +1 @@
1
- {"version":3,"file":"RefundIssueLogsPage.js","names":["PAGE_SIZE","SEARCH_DEBOUNCE_MS","RefundIssueLogsPage","permissions","useBillingPermissions","searchInput","setSearchInput","useState","debouncedSearch","setDebouncedSearch","timer","filters","useMemo","useRefundRecords","AccessDenied","error","isServerError","ServerError","refetch","columns","formatDateTime","record","statusTokens","formatCurrency","AlertTriangle","totalPages","pagination","PageHeader","Link","ArrowLeft","RefreshCw","Search","X","isLoading","records","i","IllustratedEmptyState","ResponsiveTable","goToPreviousPage","goToNextPage"],"sources":["../../../../../src/billing/modules/billing/pages/RefundIssueLogsPage.tsx"],"sourcesContent":["/**\n * Billing Module - Refund Issue Logs Page\n * Admin visibility into refunds that completed at the payment gateway but\n * carry an unresolved accounting/reconciliation issue (RefundRecord.errorMessage)\n * — e.g. a Zoho credit-note refund that couldn't be recorded because no bank\n * account is configured. These refunds are otherwise invisible: the customer\n * got their money back, so they don't show up as Failed, and the warning is\n * normally only visible by opening one refund's Details modal at a time.\n * This page surfaces every one of them in a single scannable list.\n */\n\nimport { useEffect, useMemo, useState, type FC } from 'react';\nimport { AlertTriangle, ArrowLeft, RefreshCw, Search, X } from 'lucide-react';\nimport { Link } from 'react-router';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useRefundRecords, type RefundRecord, type RefundRecordFilters } from '../hooks';\nimport { AccessDenied, PageHeader, ServerError } from '../../../shared/components';\nimport { formatCurrency, formatDateTime, isServerError } from '../../../shared/utils';\nimport { statusTokens } from '../../../shared/utils/tokens';\nimport {\n ResponsiveTable,\n type ResponsiveTableColumn,\n IllustratedEmptyState,\n} from '@burdenoff/fe-libs/ui';\n\nconst PAGE_SIZE = 25;\nconst SEARCH_DEBOUNCE_MS = 350;\n\nexport const RefundIssueLogsPage: FC = () => {\n const permissions = useBillingPermissions();\n\n // Debounced so every keystroke doesn't fire a new server query.\n const [searchInput, setSearchInput] = useState('');\n const [debouncedSearch, setDebouncedSearch] = useState('');\n useEffect(() => {\n const timer = setTimeout(() => setDebouncedSearch(searchInput.trim()), SEARCH_DEBOUNCE_MS);\n return () => clearTimeout(timer);\n }, [searchInput]);\n\n // Memoized so useRefundRecords' internal useEffect (keyed on options.filters\n // by reference) only re-fires when the debounced search actually changes,\n // not on every render — the same infinite-loop failure mode documented on\n // RefundsPage's tabFilters memo.\n const filters = useMemo<RefundRecordFilters>(\n () => ({ hasError: true, search: debouncedSearch || undefined }),\n [debouncedSearch]\n );\n\n const { records, pagination, isLoading, error, refetch, goToNextPage, goToPreviousPage } =\n useRefundRecords({\n pageSize: PAGE_SIZE,\n filters,\n });\n\n if (!permissions.canViewPayments) {\n return <AccessDenied message=\"You don't have permission to view refund logs.\" />;\n }\n\n if (error && isServerError(error)) {\n return (\n <div className=\"p-6\">\n <ServerError\n title=\"Server Unavailable\"\n message=\"Unable to load refund issue logs. The server might be down or experiencing issues.\"\n onRetry={() => refetch()}\n showRetry\n />\n </div>\n );\n }\n\n const columns: ResponsiveTableColumn<RefundRecord>[] = [\n {\n key: 'date',\n header: 'Date',\n priority: 'primary',\n cellClassName: 'whitespace-nowrap',\n cell: (record) => (\n <div className=\"flex flex-col\">\n <span className=\"text-sm text-text-primary\">\n {formatDateTime(record.createdAt).split(' ')[0]}\n </span>\n <span className=\"text-xs text-text-muted\">\n {formatDateTime(record.createdAt).split(' ')[1]}\n </span>\n </div>\n ),\n },\n {\n key: 'status',\n header: 'Status',\n cellClassName: 'whitespace-nowrap',\n cell: (record) => (\n <span\n className={`inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded ${statusTokens.success.bg} ${statusTokens.success.text}`}\n >\n {record.status}\n </span>\n ),\n },\n {\n key: 'provider',\n header: 'Provider',\n priority: 'hidden-on-mobile',\n cellClassName: 'whitespace-nowrap',\n cell: (record) => (\n <span className=\"text-sm text-text-primary capitalize\">{record.provider}</span>\n ),\n },\n {\n key: 'transactionId',\n header: 'Transaction ID',\n priority: 'hidden-on-mobile',\n cellClassName: 'whitespace-nowrap max-w-[140px] truncate',\n cell: (record) => (\n <span className=\"text-sm font-mono text-text-muted\">{record.transactionId || '-'}</span>\n ),\n },\n {\n key: 'paymentId',\n header: 'Payment ID',\n cellClassName: 'whitespace-nowrap max-w-[140px] truncate',\n cell: (record) => (\n <span className=\"text-sm font-mono text-text-muted\">{record.gatewayPaymentId}</span>\n ),\n },\n {\n key: 'amount',\n header: 'Amount',\n headerClassName: 'text-right',\n cellClassName: 'text-right whitespace-nowrap',\n cell: (record) => (\n <span className=\"text-sm font-medium tabular-nums\">\n {formatCurrency(record.amount, record.currency)}\n </span>\n ),\n },\n {\n key: 'purchaseType',\n header: 'Type',\n priority: 'hidden-on-mobile',\n cellClassName: 'whitespace-nowrap',\n cell: (record) => (\n <span className=\"text-sm text-text-muted\">{record.purchaseType || '-'}</span>\n ),\n },\n {\n key: 'issue',\n header: 'Issue',\n cellClassName: 'max-w-[360px]',\n cell: (record) => (\n <div className=\"flex items-start gap-1.5 py-1\">\n <AlertTriangle className={`size-3.5 mt-0.5 shrink-0 ${statusTokens.warning.icon}`} />\n <span className=\"text-sm text-status-warning-text\">{record.errorMessage}</span>\n </div>\n ),\n },\n ];\n\n const totalPages = Math.max(1, Math.ceil(pagination.totalCount / PAGE_SIZE));\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title=\"Refund Issue Log\"\n description=\"Refunds that succeeded with the payment gateway but left an accounting or reconciliation issue behind — e.g. a Zoho credit note that couldn't be recorded. The customer was refunded; these still need manual follow-up.\"\n actions={\n <div className=\"flex items-center gap-2\">\n <Link\n to=\"../refunds\"\n className=\"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50\"\n >\n <ArrowLeft className=\"size-4\" />\n Back to Refunds\n </Link>\n <button\n type=\"button\"\n onClick={() => refetch()}\n className=\"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50\"\n >\n <RefreshCw className=\"size-4\" />\n Refresh\n </button>\n </div>\n }\n />\n\n {/* Search */}\n <div className=\"relative\">\n <Search className=\"absolute left-3 top-1/2 -translate-y-1/2 size-4 text-text-muted\" />\n <input\n type=\"text\"\n placeholder=\"Search by transaction ID, refund ID, gateway payment ID, or gateway refund ID…\"\n value={searchInput}\n onChange={(e) => setSearchInput(e.target.value)}\n className=\"w-full pl-[3.25rem] pr-10 py-2 border border-border-subtle rounded-md bg-bg-surface\"\n />\n {searchInput && (\n <button\n type=\"button\"\n onClick={() => setSearchInput('')}\n className=\"absolute right-3 top-1/2 -translate-y-1/2 p-0.5 rounded hover:bg-bg-sunken/50\"\n aria-label=\"Clear search\"\n >\n <X className=\"size-4 text-text-muted\" />\n </button>\n )}\n </div>\n\n {isLoading && records.length === 0 ? (\n <div className=\"space-y-2\">\n {[1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"h-16 bg-bg-sunken animate-pulse rounded\" />\n ))}\n </div>\n ) : records.length === 0 ? (\n <IllustratedEmptyState\n illustration={debouncedSearch ? 'empty-search' : 'empty-data'}\n title={debouncedSearch ? 'No matching refund issues' : 'No open refund issues'}\n description={\n debouncedSearch\n ? `Nothing matched \"${debouncedSearch}\". Try the transaction ID, refund ID, or a payment/refund ID from the gateway.`\n : 'Every completed refund reconciled cleanly — nothing here needs follow-up right now.'\n }\n />\n ) : (\n <div className=\"border border-border-subtle rounded-lg overflow-hidden\">\n <ResponsiveTable<RefundRecord>\n columns={columns}\n data={records}\n rowKey={(record) => record.id}\n />\n </div>\n )}\n\n {pagination.totalCount > 0 && (\n <div className=\"flex flex-col sm:flex-row items-center justify-between gap-4 border-t border-border-subtle pt-4\">\n <p className=\"text-sm text-text-muted text-center sm:text-left\">\n Showing {pagination.page * PAGE_SIZE + 1} to{' '}\n {Math.min((pagination.page + 1) * PAGE_SIZE, pagination.totalCount)} of{' '}\n {pagination.totalCount} refunds with an open issue\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={goToPreviousPage}\n disabled={!pagination.hasPrevious}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-button border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors\"\n >\n Previous\n </button>\n <span className=\"text-sm text-text-muted px-2\">\n Page {pagination.page + 1} of {totalPages}\n </span>\n <button\n type=\"button\"\n onClick={goToNextPage}\n disabled={!pagination.hasMore}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-button border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors\"\n >\n Next\n </button>\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,IAAMA,IAAY,IACZC,IAAqB,KAEdC,UAAgC;CAC3C,IAAMC,IAAcC,EAAsB,GAGpC,CAACC,GAAaC,KAAkBC,EAAS,EAAE,GAC3C,CAACC,GAAiBC,KAAsBF,EAAS,EAAE;CACzD,QAAgB;EACd,IAAMG,IAAQ,iBAAiBD,EAAmBJ,EAAY,KAAK,CAAC,GAAGJ,CAAkB;EACzF,aAAa,aAAaS,CAAK;CACjC,GAAG,CAACL,CAAW,CAAC;CAMhB,IAAMM,IAAUC,SACP;EAAE,UAAU;EAAM,QAAQJ,KAAmB,KAAA;CAAU,IAC9D,CAACA,CAAe,CAClB,GAEM,EAAE,YAAS,eAAY,cAAW,UAAO,YAAS,iBAAc,wBACpEK,EAAiB;EACf,UAAUb;EACV;CACF,CAAC;CAEH,IAAI,CAACG,EAAY,iBACf,OAAO,kBAACW,GAAD,EAAc,SAAQ,iDAAkD,CAAA;CAGjF,IAAIC,KAASC,EAAcD,CAAK,GAC9B,OACE,kBAAC,OAAD;EAAK,WAAU;EACb,UAAA,kBAACE,GAAD;GACE,OAAM;GACN,SAAQ;GACR,eAAeC,EAAQ;GACvB,WAAA;EACD,CAAA;CACE,CAAA;CAIT,IAAMC,IAAiD;EACrD;GACE,KAAK;GACL,QAAQ;GACR,UAAU;GACV,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ACE,GAAD;IACE,cAAc5B,IAAkB,iBAAiB;IACjD,OAAOA,IAAkB,8BAA8B;IACvD,aACEA,IACI,oBAAoBA,EAAgB,kFACpC;GAEP,CAAA,IAED,kBAAC,OAAD;IAAK,WAAU;IACb,UAAA,kBAAC6B,GAAD;KACW;KACT,MAAMH;KACN,SAAS,MAAWb,EAAO;IAC5B,CAAA;GACE,CAAA;GAGNK,EAAW,aAAa,KACvB,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA;MAAgE;MACrDA,EAAW,OAAO1B,IAAY;MAAE;MAAI;MAC5C,KAAK,KAAK0B,EAAW,OAAO,KAAK1B,GAAW0B,EAAW,UAAU;MAAE;MAAI;MACvEA,EAAW;MAAW;KACtB;IACH,CAAA,GAAA,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA;MACE,kBAAC,UAAD;OACE,MAAK;OACL,SAASY;OACT,UAAU,CAACZ,EAAW;OACtB,WAAU;OACX,UAAA;MAEO,CAAA;MACR,kBAAC,QAAD;OAAM,WAAU;OAAhB,UAAA;QAA+C;QACvCA,EAAW,OAAO;QAAE;QAAKD;OAC3B;;MACN,kBAAC,UAAD;OACE,MAAK;OACL,SAASc;OACT,UAAU,CAACb,EAAW;OACtB,WAAU;OACX,UAAA;MAEO,CAAA;KACL;IACF,CAAA,CAAA;;EAEJ;;AAET"}
1
+ {"version":3,"file":"RefundIssueLogsPage.js","names":["PAGE_SIZE","SEARCH_DEBOUNCE_MS","RefundIssueLogsPage","permissions","useBillingPermissions","searchInput","setSearchInput","useState","debouncedSearch","setDebouncedSearch","timer","filters","useMemo","useRefundRecords","AccessDenied","error","isServerError","ServerError","refetch","columns","formatDateTime","record","statusTokens","formatCurrency","AlertTriangle","totalPages","pagination","PageHeader","Link","ArrowLeft","RefreshCw","Search","X","isLoading","records","i","IllustratedEmptyState","ResponsiveTable","goToPreviousPage","goToNextPage"],"sources":["../../../../../src/billing/modules/billing/pages/RefundIssueLogsPage.tsx"],"sourcesContent":["/**\n * Billing Module - Refund Issue Logs Page\n * Admin visibility into refunds that completed at the payment gateway but\n * carry an unresolved accounting/reconciliation issue (RefundRecord.errorMessage)\n * — e.g. a Zoho credit-note refund that couldn't be recorded because no bank\n * account is configured. These refunds are otherwise invisible: the customer\n * got their money back, so they don't show up as Failed, and the warning is\n * normally only visible by opening one refund's Details modal at a time.\n * This page surfaces every one of them in a single scannable list.\n */\n\nimport { useEffect, useMemo, useState, type FC } from 'react';\nimport { AlertTriangle, ArrowLeft, RefreshCw, Search, X } from 'lucide-react';\nimport { Link } from 'react-router';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useRefundRecords, type RefundRecord, type RefundRecordFilters } from '../hooks';\nimport { AccessDenied, PageHeader, ServerError } from '../../../shared/components';\nimport { formatCurrency, formatDateTime, isServerError } from '../../../shared/utils';\nimport { statusTokens } from '../../../shared/utils/tokens';\nimport {\n ResponsiveTable,\n type ResponsiveTableColumn,\n IllustratedEmptyState,\n} from '@burdenoff/fe-libs/ui';\n\nconst PAGE_SIZE = 25;\nconst SEARCH_DEBOUNCE_MS = 350;\n\nexport const RefundIssueLogsPage: FC = () => {\n const permissions = useBillingPermissions();\n\n // Debounced so every keystroke doesn't fire a new server query.\n const [searchInput, setSearchInput] = useState('');\n const [debouncedSearch, setDebouncedSearch] = useState('');\n useEffect(() => {\n const timer = setTimeout(() => setDebouncedSearch(searchInput.trim()), SEARCH_DEBOUNCE_MS);\n return () => clearTimeout(timer);\n }, [searchInput]);\n\n // Memoized so useRefundRecords' internal useEffect (keyed on options.filters\n // by reference) only re-fires when the debounced search actually changes,\n // not on every render — the same infinite-loop failure mode documented on\n // RefundsPage's tabFilters memo.\n const filters = useMemo<RefundRecordFilters>(\n () => ({ hasError: true, search: debouncedSearch || undefined }),\n [debouncedSearch]\n );\n\n const { records, pagination, isLoading, error, refetch, goToNextPage, goToPreviousPage } =\n useRefundRecords({\n pageSize: PAGE_SIZE,\n filters,\n });\n\n if (!permissions.canViewPayments) {\n return <AccessDenied message=\"You don't have permission to view refund logs.\" />;\n }\n\n if (error && isServerError(error)) {\n return (\n <div className=\"p-6\">\n <ServerError\n title=\"Server Unavailable\"\n message=\"Unable to load refund issue logs. The server might be down or experiencing issues.\"\n onRetry={() => refetch()}\n showRetry\n />\n </div>\n );\n }\n\n const columns: ResponsiveTableColumn<RefundRecord>[] = [\n {\n key: 'date',\n header: 'Date',\n priority: 'primary',\n cellClassName: 'whitespace-nowrap',\n cell: (record) => (\n <div className=\"flex flex-col\">\n <span className=\"text-sm text-text-primary\">\n {formatDateTime(record.createdAt).split(' ')[0]}\n </span>\n <span className=\"text-xs text-text-muted\">\n {formatDateTime(record.createdAt).split(' ')[1]}\n </span>\n </div>\n ),\n },\n {\n key: 'status',\n header: 'Status',\n cellClassName: 'whitespace-nowrap',\n cell: (record) => (\n <span\n className={`inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded ${statusTokens.success.bg} ${statusTokens.success.text}`}\n >\n {record.status}\n </span>\n ),\n },\n {\n key: 'provider',\n header: 'Provider',\n priority: 'hidden-on-mobile',\n cellClassName: 'whitespace-nowrap',\n cell: (record) => (\n <span className=\"text-sm text-text-primary capitalize\">{record.provider}</span>\n ),\n },\n {\n key: 'transactionId',\n header: 'Transaction ID',\n priority: 'hidden-on-mobile',\n cellClassName: 'whitespace-nowrap max-w-[140px] truncate',\n cell: (record) => (\n <span className=\"text-sm font-mono text-text-muted\">{record.transactionId || '-'}</span>\n ),\n },\n {\n key: 'paymentId',\n header: 'Payment ID',\n cellClassName: 'whitespace-nowrap max-w-[140px] truncate',\n cell: (record) => (\n <span className=\"text-sm font-mono text-text-muted\">{record.gatewayPaymentId}</span>\n ),\n },\n {\n key: 'amount',\n header: 'Amount',\n headerClassName: 'text-right',\n cellClassName: 'text-right whitespace-nowrap',\n cell: (record) => (\n <span className=\"text-sm font-medium tabular-nums\">\n {formatCurrency(record.amount, record.currency)}\n </span>\n ),\n },\n {\n key: 'purchaseType',\n header: 'Type',\n priority: 'hidden-on-mobile',\n cellClassName: 'whitespace-nowrap',\n cell: (record) => (\n <span className=\"text-sm text-text-muted\">{record.purchaseType || '-'}</span>\n ),\n },\n {\n key: 'issue',\n header: 'Issue',\n cellClassName: 'max-w-[360px]',\n cell: (record) => (\n <div className=\"flex items-start gap-1.5 py-1\">\n <AlertTriangle className={`size-3.5 mt-0.5 shrink-0 ${statusTokens.warning.icon}`} />\n <span className=\"text-sm text-status-warning-text\">{record.errorMessage}</span>\n </div>\n ),\n },\n ];\n\n const totalPages = Math.max(1, Math.ceil(pagination.totalCount / PAGE_SIZE));\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title=\"Refund Issue Log\"\n description=\"Refunds that succeeded with the payment gateway but left an accounting or reconciliation issue behind — e.g. a Zoho credit note that couldn't be recorded. The customer was refunded; these still need manual follow-up.\"\n actions={\n <div className=\"flex items-center gap-2\">\n <Link\n to=\"../refunds\"\n className=\"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50\"\n >\n <ArrowLeft className=\"size-4\" />\n Back to Refunds\n </Link>\n <button\n type=\"button\"\n onClick={() => refetch()}\n className=\"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50\"\n >\n <RefreshCw className=\"size-4\" />\n Refresh\n </button>\n </div>\n }\n />\n\n {/* Search */}\n <div className=\"relative\">\n <Search className=\"absolute left-3 top-1/2 -translate-y-1/2 size-4 text-text-muted\" />\n <input\n type=\"text\"\n placeholder=\"Search by transaction ID, refund ID, gateway payment ID, or gateway refund ID…\"\n value={searchInput}\n onChange={(e) => setSearchInput(e.target.value)}\n className=\"w-full pl-[3.25rem] pr-10 py-2 border border-border-subtle rounded-md bg-bg-surface\"\n />\n {searchInput && (\n <button\n type=\"button\"\n onClick={() => setSearchInput('')}\n className=\"absolute right-3 top-1/2 -translate-y-1/2 p-0.5 rounded hover:bg-bg-sunken/50\"\n aria-label=\"Clear search\"\n >\n <X className=\"size-4 text-text-muted\" />\n </button>\n )}\n </div>\n\n {isLoading && records.length === 0 ? (\n <div className=\"space-y-2\">\n {[1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"h-16 bg-bg-sunken animate-pulse rounded\" />\n ))}\n </div>\n ) : records.length === 0 ? (\n <IllustratedEmptyState\n illustration={debouncedSearch ? 'empty-search' : 'empty-data'}\n title={debouncedSearch ? 'No matching refund issues' : 'No open refund issues'}\n description={\n debouncedSearch\n ? `Nothing matched \"${debouncedSearch}\". Try the transaction ID, refund ID, or a payment/refund ID from the gateway.`\n : 'Every completed refund reconciled cleanly — nothing here needs follow-up right now.'\n }\n kind={debouncedSearch ? 'no-results' : 'all-done'}\n />\n ) : (\n <div className=\"border border-border-subtle rounded-lg overflow-hidden\">\n <ResponsiveTable<RefundRecord>\n columns={columns}\n data={records}\n rowKey={(record) => record.id}\n />\n </div>\n )}\n\n {pagination.totalCount > 0 && (\n <div className=\"flex flex-col sm:flex-row items-center justify-between gap-4 border-t border-border-subtle pt-4\">\n <p className=\"text-sm text-text-muted text-center sm:text-left\">\n Showing {pagination.page * PAGE_SIZE + 1} to{' '}\n {Math.min((pagination.page + 1) * PAGE_SIZE, pagination.totalCount)} of{' '}\n {pagination.totalCount} refunds with an open issue\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={goToPreviousPage}\n disabled={!pagination.hasPrevious}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-button border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors\"\n >\n Previous\n </button>\n <span className=\"text-sm text-text-muted px-2\">\n Page {pagination.page + 1} of {totalPages}\n </span>\n <button\n type=\"button\"\n onClick={goToNextPage}\n disabled={!pagination.hasMore}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-button border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors\"\n >\n Next\n </button>\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,IAAMA,IAAY,IACZC,IAAqB,KAEdC,UAAgC;CAC3C,IAAMC,IAAcC,EAAsB,GAGpC,CAACC,GAAaC,KAAkBC,EAAS,EAAE,GAC3C,CAACC,GAAiBC,KAAsBF,EAAS,EAAE;CACzD,QAAgB;EACd,IAAMG,IAAQ,iBAAiBD,EAAmBJ,EAAY,KAAK,CAAC,GAAGJ,CAAkB;EACzF,aAAa,aAAaS,CAAK;CACjC,GAAG,CAACL,CAAW,CAAC;CAMhB,IAAMM,IAAUC,SACP;EAAE,UAAU;EAAM,QAAQJ,KAAmB,KAAA;CAAU,IAC9D,CAACA,CAAe,CAClB,GAEM,EAAE,YAAS,eAAY,cAAW,UAAO,YAAS,iBAAc,wBACpEK,EAAiB;EACf,UAAUb;EACV;CACF,CAAC;CAEH,IAAI,CAACG,EAAY,iBACf,OAAO,kBAACW,GAAD,EAAc,SAAQ,iDAAkD,CAAA;CAGjF,IAAIC,KAASC,EAAcD,CAAK,GAC9B,OACE,kBAAC,OAAD;EAAK,WAAU;EACb,UAAA,kBAACE,GAAD;GACE,OAAM;GACN,SAAQ;GACR,eAAeC,EAAQ;GACvB,WAAA;EACD,CAAA;CACE,CAAA;CAIT,IAAMC,IAAiD;EACrD;GACE,KAAK;GACL,QAAQ;GACR,UAAU;GACV,eAAe;GACf,OAAO,MACL,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,QAAD;KAAM,WAAU;KACb,UAAAC,EAAeC,EAAO,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACzC,CAAA,GACN,kBAAC,QAAD;KAAM,WAAU;KACb,UAAAD,EAAeC,EAAO,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACz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AGNK,EAAW,aAAa,KACvB,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA;MAAgE;MACrDA,EAAW,OAAO1B,IAAY;MAAE;MAAI;MAC5C,KAAK,KAAK0B,EAAW,OAAO,KAAK1B,GAAW0B,EAAW,UAAU;MAAE;MAAI;MACvEA,EAAW;MAAW;KACtB;IACH,CAAA,GAAA,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA;MACE,kBAAC,UAAD;OACE,MAAK;OACL,SAASY;OACT,UAAU,CAACZ,EAAW;OACtB,WAAU;OACX,UAAA;MAEO,CAAA;MACR,kBAAC,QAAD;OAAM,WAAU;OAAhB,UAAA;QAA+C;QACvCA,EAAW,OAAO;QAAE;QAAKD;OAC3B;;MACN,kBAAC,UAAD;OACE,MAAK;OACL,SAASc;OACT,UAAU,CAACb,EAAW;OACtB,WAAU;OACX,UAAA;MAEO,CAAA;KACL;IACF,CAAA,CAAA;;EAEJ;;AAET"}
@@ -982,7 +982,9 @@ var z = {
982
982
  je.length === 0 ? /* @__PURE__ */ I(g, {
983
983
  illustration: Object.values(T).filter(Boolean).length > 0 ? "empty-search" : "empty-data",
984
984
  title: "No refund records found",
985
- description: Object.values(T).filter(Boolean).length > 0 ? "Try adjusting your filters." : d === "PENDING" ? "No pending refunds to process." : "Refund records will appear here when created."
985
+ description: Object.values(T).filter(Boolean).length > 0 ? "Try adjusting your filters." : d === "PENDING" ? "No pending refunds to process." : "Refund records will appear here when created.",
986
+ kind: x ? "no-results" : Object.values(T).filter(Boolean).length > 0 ? "filtered" : d === "PENDING" ? "all-done" : "first-use",
987
+ glassIllustration: "money"
986
988
  }) : /* @__PURE__ */ I("div", {
987
989
  className: "border border-border-subtle rounded-lg overflow-hidden",
988
990
  children: /* @__PURE__ */ I(v, {