@burdenoff/microfe-billing 2026.1109.1 → 2026.1112.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 (25) hide show
  1. package/dist/billing/BillingUserRoutes.js +202 -188
  2. package/dist/billing/BillingUserRoutes.js.map +1 -1
  3. package/dist/billing/hooks/useBillingVariant.d.ts +6 -0
  4. package/dist/billing/hooks/useBillingVariant.js +8 -0
  5. package/dist/billing/hooks/useBillingVariant.js.map +1 -0
  6. package/dist/billing/modules/billing/pages/InvoiceDetailPage.js +169 -140
  7. package/dist/billing/modules/billing/pages/InvoiceDetailPage.js.map +1 -1
  8. package/dist/billing/modules/billing/pages/InvoicesListPage.js +191 -156
  9. package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
  10. package/dist/billing/modules/billing/pages/UserRefundsPage.js +160 -157
  11. package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
  12. package/dist/billing/modules/settings/pages/TeamPermissionsPage.js +4 -1
  13. package/dist/billing/modules/settings/pages/TeamPermissionsPage.js.map +1 -1
  14. package/dist/billing/providers/BillingProvider.js +16 -15
  15. package/dist/billing/providers/BillingProvider.js.map +1 -1
  16. package/dist/billing/shared/components/MoneyActionDialog.d.ts +27 -0
  17. package/dist/billing/shared/components/MoneyActionDialog.js +53 -0
  18. package/dist/billing/shared/components/MoneyActionDialog.js.map +1 -0
  19. package/dist/billing/shared/components/index.d.ts +1 -0
  20. package/dist/billing/shared/components/index.js +2 -1
  21. package/dist/billing/shared/utils/accessRules.d.ts +16 -0
  22. package/dist/billing/shared/utils/accessRules.js +10 -0
  23. package/dist/billing/shared/utils/accessRules.js.map +1 -0
  24. package/dist/billing/types/index.d.ts +6 -0
  25. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"UserRefundsPage.js","names":["UUID_RE","STATUS_CONFIG","RefundRecordStatus","Clock","Loader2","className","CheckCircle","XCircle","StatusBadge","cfg","status","Icon","UserRefundsPage","useI18n","tr","v","t","key","fallback","navigateTo","useBillingNavigate","showForm","setShowForm","useState","txnIdInput","setTxnIdInput","lookedUpTxn","setLookedUpTxn","txnNotFound","setTxnNotFound","reason","setReason","amount","setAmount","formError","setFormError","formSuccess","setFormSuccess","accountsData","accountsLoading","useGetBillingAccountsCheckoutQuery","accounts","useMemo","selectedAccountId","setSelectedAccountId","selectedAccount","a","fetchTxn","txnLookupData","txnLookupLoading","txnLookupError","useGetTransactionLazyQuery","lastLookupKey","useRef","txn","triggerLookup","txnId","accountId","handleTxnIdChange","value","handleAccountChange","refundsData","refundsLoading","refetchRefunds","useGetRefundRecordsQuery","refunds","createRefund","isSubmitting","useCreateRefundRecordMutation","getGatewayInfo","handleSubmit","gatewayInfo","parsedAmount","formatCurrency","resetFormFields","err","resetForm","PageHeader","PlusCircle","PagePurpose","CreditCard","X","Search","formatDateTime","IllustratedEmptyState","r"],"sources":["../../../../../src/billing/modules/billing/pages/UserRefundsPage.tsx"],"sourcesContent":["/**\n * Billing Module - User Refunds Page\n * Shows the user's refund request history and allows submitting new requests.\n */\n\nimport { useState, useEffect, useMemo, useRef, type FC, type FormEvent } from 'react';\nimport {\n PlusCircle,\n X,\n Clock,\n CheckCircle,\n XCircle,\n Loader2,\n Search,\n CreditCard,\n} from 'lucide-react';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { formatCurrency, formatDateTime } from '../../../shared/utils';\nimport { PageHeader } from '../../../shared/components';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PagePurpose, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\nimport {\n useGetBillingAccountsCheckoutQuery,\n useGetTransactionLazyQuery,\n useGetRefundRecordsQuery,\n useCreateRefundRecordMutation,\n type GetRefundRecordsQuery,\n type GetTransactionQuery,\n} from '../../../../generated/global-operations';\nimport { RefundRecordStatus } from '../../../../generated/global-types';\n\ntype RefundItem = NonNullable<GetRefundRecordsQuery['getRefundRecords']['records']>[number];\ntype TxnLookup = NonNullable<GetTransactionQuery['getTransaction']>;\n\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n// ============================================================================\n// Status helpers\n// ============================================================================\n\nconst STATUS_CONFIG: Record<\n RefundRecordStatus,\n { label: string; className: string; icon: FC<{ className?: string }> }\n> = {\n [RefundRecordStatus.Pending]: {\n label: 'In Review',\n className: 'bg-status-warning-bg/20 text-status-warning-text border-status-warning-border',\n icon: ({ className }) => <Clock className={className} />,\n },\n [RefundRecordStatus.Processing]: {\n label: 'Processing',\n className: 'bg-action-primary-bg/15 text-action-primary-bg border-action-primary-bg/30',\n icon: ({ className }) => <Loader2 className={`${className} animate-spin`} />,\n },\n [RefundRecordStatus.Completed]: {\n label: 'Refunded',\n className: 'bg-status-success-bg/20 text-status-success-text border-status-success-border',\n icon: ({ className }) => <CheckCircle className={className} />,\n },\n [RefundRecordStatus.Failed]: {\n label: 'Failed',\n className: 'bg-status-error-bg/20 text-status-error-text border-status-error-border',\n icon: ({ className }) => <XCircle className={className} />,\n },\n [RefundRecordStatus.Skipped]: {\n label: 'Closed',\n className: 'bg-bg-sunken text-text-secondary border-border-subtle',\n icon: ({ className }) => <XCircle className={className} />,\n },\n};\n\nfunction StatusBadge({ status }: { status: string }) {\n const cfg = STATUS_CONFIG[status as RefundRecordStatus] ?? {\n label: status,\n className: 'bg-bg-sunken text-text-secondary border-border-subtle',\n icon: ({ className }: { className?: string }) => <Clock className={className} />,\n };\n const Icon = cfg.icon;\n return (\n <span\n className={`inline-flex items-center gap-1 px-2 py-0.5 rounded-full border text-xs font-medium ${cfg.className}`}\n >\n <Icon className=\"size-3\" />\n {cfg.label}\n </span>\n );\n}\n\n// ============================================================================\n// Main page\n// ============================================================================\n\nexport const UserRefundsPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string) => {\n const v = t(key);\n return v === key ? fallback : v;\n };\n const navigateTo = useBillingNavigate();\n\n // Form state\n const [showForm, setShowForm] = useState(false);\n const [txnIdInput, setTxnIdInput] = useState('');\n const [lookedUpTxn, setLookedUpTxn] = useState<TxnLookup | null>(null);\n const [txnNotFound, setTxnNotFound] = useState(false);\n const [reason, setReason] = useState('');\n const [amount, setAmount] = useState('');\n const [formError, setFormError] = useState<string | null>(null);\n const [formSuccess, setFormSuccess] = useState(false);\n\n // All billing accounts\n const { data: accountsData, loading: accountsLoading } = useGetBillingAccountsCheckoutQuery({\n fetchPolicy: 'cache-and-network',\n });\n type BillingAccount = NonNullable<typeof accountsData>['getBillingAccountsByOrg'][number];\n const accounts = useMemo<BillingAccount[]>(\n () => accountsData?.getBillingAccountsByOrg ?? [],\n [accountsData]\n );\n\n // Default to the first account; user can switch\n const [selectedAccountId, setSelectedAccountId] = useState<string | undefined>(undefined);\n useEffect(() => {\n if (!selectedAccountId && accounts.length > 0) {\n setSelectedAccountId(accounts[0].id);\n }\n }, [accounts, selectedAccountId]);\n\n const selectedAccount = accounts.find((a) => a.id === selectedAccountId);\n\n // Transaction lookup by ID (lazy — fires when user enters a valid UUID)\n const [fetchTxn, { data: txnLookupData, loading: txnLookupLoading, error: txnLookupError }] =\n useGetTransactionLazyQuery({ fetchPolicy: 'network-only' });\n\n // Track the \"active\" lookup key so we only apply results for the latest request\n const lastLookupKey = useRef('');\n\n useEffect(() => {\n if (txnLookupLoading) return;\n const txn = txnLookupData?.getTransaction;\n if (txn) {\n setLookedUpTxn(txn);\n setTxnNotFound(false);\n setAmount(String(txn.amount));\n } else if (txnLookupData !== undefined || txnLookupError) {\n setLookedUpTxn(null);\n setTxnNotFound(true);\n setAmount('');\n }\n }, [txnLookupData, txnLookupLoading, txnLookupError]);\n\n const triggerLookup = (txnId: string, accountId: string) => {\n const key = `${txnId}::${accountId}`;\n lastLookupKey.current = key;\n setLookedUpTxn(null);\n setTxnNotFound(false);\n setAmount('');\n fetchTxn({ variables: { id: txnId, billingAccountId: accountId } });\n };\n\n const handleTxnIdChange = (value: string) => {\n setTxnIdInput(value);\n setLookedUpTxn(null);\n setTxnNotFound(false);\n setAmount('');\n if (UUID_RE.test(value.trim()) && selectedAccountId) {\n triggerLookup(value.trim(), selectedAccountId);\n }\n };\n\n // When account changes, re-fetch the transaction if one is entered\n const handleAccountChange = (accountId: string) => {\n setSelectedAccountId(accountId);\n setLookedUpTxn(null);\n setTxnNotFound(false);\n setAmount('');\n if (UUID_RE.test(txnIdInput.trim())) {\n triggerLookup(txnIdInput.trim(), accountId);\n }\n };\n\n // Refund history for selected account\n const {\n data: refundsData,\n loading: refundsLoading,\n refetch: refetchRefunds,\n } = useGetRefundRecordsQuery({\n variables: { billingAccountId: selectedAccountId, pageSize: 20, page: 1 },\n skip: !selectedAccountId,\n fetchPolicy: 'cache-and-network',\n });\n const refunds = refundsData?.getRefundRecords.records ?? [];\n\n const [createRefund, { loading: isSubmitting }] = useCreateRefundRecordMutation({\n refetchQueries: ['GetRefundRecords'],\n });\n\n const getGatewayInfo = (txn: TxnLookup | null) => {\n if (!txn) return null;\n if (txn.stripePaymentId) return { provider: 'STRIPE', gatewayPaymentId: txn.stripePaymentId };\n if (txn.razorpayPaymentId)\n return { provider: 'RAZORPAY', gatewayPaymentId: txn.razorpayPaymentId };\n return null;\n };\n\n const handleSubmit = async (e: FormEvent) => {\n e.preventDefault();\n setFormError(null);\n\n if (!lookedUpTxn || !reason.trim() || !amount) {\n setFormError('Enter a valid transaction ID, an amount, and a reason.');\n return;\n }\n const gatewayInfo = getGatewayInfo(lookedUpTxn);\n if (!gatewayInfo) {\n setFormError('No payment gateway info found for this transaction. Please contact support.');\n return;\n }\n const parsedAmount = parseFloat(amount);\n if (isNaN(parsedAmount) || parsedAmount <= 0) {\n setFormError('Please enter a valid amount greater than 0.');\n return;\n }\n if (parsedAmount > lookedUpTxn.amount) {\n setFormError(\n `Cannot exceed the original payment amount (${formatCurrency(lookedUpTxn.amount, lookedUpTxn.currency)}).`\n );\n return;\n }\n\n try {\n await createRefund({\n variables: {\n billingAccountId: selectedAccountId,\n provider: gatewayInfo.provider,\n gatewayPaymentId: gatewayInfo.gatewayPaymentId,\n amount: parsedAmount,\n currency: lookedUpTxn.currency ?? selectedAccount?.currency ?? 'USD',\n transactionId: lookedUpTxn.id,\n reason: reason.trim(),\n notes: `Requested by user via billing portal`,\n },\n });\n setFormSuccess(true);\n setShowForm(false);\n resetFormFields();\n await refetchRefunds();\n } catch (err) {\n setFormError(err instanceof Error ? err.message : 'Failed to submit refund request.');\n }\n };\n\n const resetFormFields = () => {\n setTxnIdInput('');\n setLookedUpTxn(null);\n setTxnNotFound(false);\n setReason('');\n setAmount('');\n setFormError(null);\n };\n\n const resetForm = () => {\n setShowForm(false);\n setFormSuccess(false);\n resetFormFields();\n };\n\n return (\n <div className=\"space-y-6 p-6 max-w-3xl\">\n <PageHeader\n title={tr('billing.refunds.title', 'Refunds')}\n description={tr(\n 'billing.refunds.description',\n 'View your refund requests and submit new ones'\n )}\n actions={\n !showForm ? (\n <button\n type=\"button\"\n onClick={() => {\n setShowForm(true);\n setFormSuccess(false);\n }}\n className=\"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors\"\n >\n <PlusCircle className=\"size-4\" />\n {tr('billing.refunds.requestRefund', 'Request Refund')}\n </button>\n ) : undefined\n }\n />\n\n <PagePurpose>\n {tr(\n 'billing.refunds.userPurpose',\n 'Request money back for a payment and follow where each request stands. Paste the transaction ID of the charge you want refunded, tell us how much and why, and track every request here from \"In Review\" through to \"Refunded\".'\n )}\n </PagePurpose>\n\n {/* Billing account switcher */}\n {!accountsLoading && accounts.length > 1 && (\n <div className=\"flex items-center gap-3\">\n <CreditCard className=\"size-4 text-text-secondary shrink-0\" />\n <label htmlFor=\"accountSwitch\" className=\"text-sm text-text-secondary shrink-0\">\n {tr('billing.refunds.account', 'Billing account')}\n </label>\n <select\n id=\"accountSwitch\"\n value={selectedAccountId ?? ''}\n onChange={(e) => handleAccountChange(e.target.value)}\n className=\"flex-1 px-3 py-1.5 border border-border-subtle rounded-button bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] text-sm scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n {accounts.map((a) => (\n <option key={a.id} value={a.id}>\n {a.name} ({a.currency}) — {a.email}\n </option>\n ))}\n </select>\n </div>\n )}\n\n {/* Success banner */}\n {formSuccess && (\n <div className=\"flex items-center justify-between p-4 rounded-lg border border-status-success-border bg-status-success-bg/10\">\n <div className=\"flex items-center gap-2\">\n <CheckCircle className=\"size-4 text-status-success-text\" />\n <p className=\"text-sm text-status-success-text font-medium\">\n {tr(\n 'billing.refunds.submitted',\n 'Refund request submitted. Our team will review it shortly.'\n )}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => setFormSuccess(false)}\n className=\"text-status-success-text hover:opacity-70\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n )}\n\n {/* Request Refund Form */}\n {showForm && (\n <div className=\"border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 overflow-hidden\">\n <div className=\"flex items-center justify-between p-4 border-b border-border-subtle bg-bg-sunken\">\n <h2 className=\"font-semibold text-text-primary\">\n {tr('billing.refunds.newRequest', 'New Refund Request')}\n </h2>\n <button\n type=\"button\"\n onClick={resetForm}\n className=\"p-1 rounded hover:bg-bg-sunken transition-colors\"\n >\n <X className=\"size-4 text-text-secondary\" />\n </button>\n </div>\n\n <form onSubmit={handleSubmit} className=\"p-4 space-y-4\">\n {formError && (\n <div className=\"p-3 rounded-lg border border-status-error-border bg-status-error-bg/10\">\n <p className=\"text-sm text-status-error-text\">{formError}</p>\n </div>\n )}\n\n {/* Transaction ID lookup */}\n <div>\n <label htmlFor=\"txnId\" className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('billing.refunds.transactionId', 'Transaction ID')} *\n </label>\n <div className=\"relative\">\n <input\n id=\"txnId\"\n type=\"text\"\n value={txnIdInput}\n onChange={(e) => handleTxnIdChange(e.target.value)}\n placeholder=\"Paste your transaction ID...\"\n className=\"w-full pl-3 pr-9 py-2 border border-border-subtle rounded-button bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] text-sm font-mono\"\n />\n <div className=\"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-secondary\">\n {txnLookupLoading ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <Search className=\"size-4\" />\n )}\n </div>\n </div>\n\n {/* Transaction lookup result */}\n {lookedUpTxn && (\n <div className=\"mt-2 p-3 rounded-button border border-status-success-border bg-status-success-bg/10 text-sm space-y-0.5\">\n <div className=\"flex items-center gap-2\">\n <CheckCircle className=\"size-3.5 text-status-success-text shrink-0\" />\n <span className=\"font-medium text-text-primary\">\n {formatCurrency(lookedUpTxn.amount, lookedUpTxn.currency)}\n </span>\n <span className=\"text-text-secondary\">·</span>\n <span className=\"text-text-secondary\">\n {formatDateTime(lookedUpTxn.createdAt)}\n </span>\n {lookedUpTxn.stripePaymentId && (\n <span className=\"text-xs text-text-secondary\">Stripe</span>\n )}\n {lookedUpTxn.razorpayPaymentId && (\n <span className=\"text-xs text-text-secondary\">Razorpay</span>\n )}\n </div>\n {lookedUpTxn.description && (\n <p className=\"text-xs text-text-secondary pl-5\">{lookedUpTxn.description}</p>\n )}\n </div>\n )}\n {txnNotFound && txnIdInput.length > 0 && !txnLookupLoading && (\n <p className=\"mt-1 text-xs text-status-error-text\">\n {tr(\n 'billing.refunds.txnNotFound',\n 'Transaction not found in this billing account.'\n )}\n </p>\n )}\n {!UUID_RE.test(txnIdInput.trim()) && txnIdInput.length > 4 && (\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'billing.refunds.txnIdHint',\n 'Transaction IDs look like: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'\n )}\n </p>\n )}\n </div>\n\n {/* Amount — only shown once transaction is found */}\n {lookedUpTxn && (\n <div>\n <label\n htmlFor=\"refundAmount\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.refunds.amount', 'Refund Amount')} *\n </label>\n <div className=\"flex items-center gap-2\">\n <input\n id=\"refundAmount\"\n type=\"number\"\n step=\"0.01\"\n min=\"0.01\"\n max={lookedUpTxn.amount}\n value={amount}\n onChange={(e) => setAmount(e.target.value)}\n required\n className=\"w-40 px-3 py-2 border border-border-subtle rounded-button bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] text-sm\"\n placeholder=\"0.00\"\n />\n <span className=\"text-sm text-text-secondary\">\n {lookedUpTxn.currency ?? selectedAccount?.currency ?? 'USD'}\n </span>\n <span className=\"text-xs text-text-secondary\">\n max {formatCurrency(lookedUpTxn.amount, lookedUpTxn.currency)}\n </span>\n </div>\n </div>\n )}\n\n {/* Reason */}\n <div>\n <label htmlFor=\"reason\" className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('billing.refunds.reason', 'Reason for refund')} *\n </label>\n <textarea\n id=\"reason\"\n value={reason}\n onChange={(e) => setReason(e.target.value)}\n required\n rows={3}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-button bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] text-sm resize-none\"\n placeholder={tr(\n 'billing.refunds.reasonPlaceholder',\n 'Describe why you are requesting a refund...'\n )}\n />\n </div>\n\n <div className=\"flex items-center gap-3 pt-1\">\n <button\n type=\"submit\"\n disabled={isSubmitting || !lookedUpTxn || !reason.trim() || !amount}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n {isSubmitting\n ? tr('billing.refunds.submitting', 'Submitting...')\n : tr('billing.refunds.submitRequest', 'Submit Request')}\n </button>\n <button\n type=\"button\"\n onClick={resetForm}\n className=\"px-4 py-2 text-sm border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors\"\n >\n {tr('billing.common.cancel', 'Cancel')}\n </button>\n </div>\n </form>\n </div>\n )}\n\n {/* Refund history */}\n <div className=\"border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 overflow-hidden\">\n <div className=\"p-4 border-b border-border-subtle bg-bg-sunken\">\n <h2 className=\"font-semibold text-text-primary\">\n {tr('billing.refunds.history', 'Refund History')}\n </h2>\n </div>\n\n {accountsLoading || refundsLoading ? (\n <div className=\"p-8 flex items-center justify-center\">\n <Loader2 className=\"size-5 animate-spin text-text-secondary\" />\n </div>\n ) : refunds.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title={tr('billing.refunds.noRefunds', 'No refund requests yet')}\n description={tr(\n 'billing.refunds.noRefundsHint',\n 'If you have an issue with a payment, click \"Request Refund\" to get started.'\n )}\n />\n ) : (\n <ul className=\"divide-y divide-border-subtle\">\n {refunds.map((r: RefundItem) => (\n <li\n key={r.id}\n className=\"flex items-start gap-4 p-4 hover:bg-bg-sunken transition-colors\"\n >\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2 flex-wrap\">\n <span className=\"text-sm font-medium text-text-primary\">\n {formatCurrency(r.amount, r.currency)}\n </span>\n <StatusBadge status={r.status} />\n {r.purchaseDetail && (\n <span className=\"text-xs text-text-secondary truncate\">\n {r.purchaseDetail}\n </span>\n )}\n </div>\n {r.reason && (\n <p className=\"text-xs text-text-secondary mt-1 line-clamp-2\">{r.reason}</p>\n )}\n {r.errorMessage && r.status === RefundRecordStatus.Failed && (\n <p className=\"text-xs text-status-error-text mt-1\">{r.errorMessage}</p>\n )}\n </div>\n <div className=\"text-right shrink-0\">\n <p className=\"text-xs text-text-secondary\">{formatDateTime(r.createdAt)}</p>\n {r.processedAt && (\n <p className=\"text-xs text-text-secondary mt-0.5\">\n Processed {formatDateTime(r.processedAt)}\n </p>\n )}\n </div>\n </li>\n ))}\n </ul>\n )}\n </div>\n\n <p className=\"text-xs text-text-secondary\">\n {tr(\n 'billing.refunds.footer',\n 'Refund requests are reviewed by our team within 3–5 business days. For urgent issues, contact support.'\n )}{' '}\n <button\n type=\"button\"\n onClick={() => navigateTo('/transactions/' + selectedAccountId)}\n className=\"underline hover:no-underline\"\n >\n {tr('billing.refunds.viewTransactions', 'View all transactions')}\n </button>\n </p>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAkCA,IAAMA,IAAU,mEAMVC,IAGF;EACDC,EAAmB,UAAU;EAC5B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAACC,GAAD,EAAkB,aAAY,CAAA;CACzD;EACCD,EAAmB,aAAa;EAC/B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAACE,GAAD,EAAS,WAAW,GAAGC,EAAU,eAAiB,CAAA;CAC7E;EACCH,EAAmB,YAAY;EAC9B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAACI,GAAD,EAAwB,aAAY,CAAA;CAC/D;EACCJ,EAAmB,SAAS;EAC3B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAACK,GAAD,EAAoB,aAAY,CAAA;CAC3D;EACCL,EAAmB,UAAU;EAC5B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAACK,GAAD,EAAoB,aAAY,CAAA;CAC3D;AACF;AAEA,SAASC,GAAY,EAAE,aAA8B;CACnD,IAAMC,IAAMR,EAAcS,MAAiC;EACzD,OAAOA;EACP,WAAW;EACX,OAAO,EAAE,mBAAwC,kBAACP,GAAD,EAAkB,aAAY,CAAA;CACjF,GACMQ,IAAOF,EAAI;CACjB,OACE,kBAAC,QAAD;EACE,WAAW,sFAAsFA,EAAI;EADvG,UAAA,CAGE,kBAACE,GAAD,EAAM,WAAU,SAAU,CAAA,GACzBF,EAAI,KACD;;AAEV;AAMA,IAAaG,UAA4B;CACvC,IAAM,EAAE,SAAMC,EAAQ,GACh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,KAAD;SAAG,WAAU;SAAiD,UAAAA,EAAE;QAAU,CAAA;QAE3EA,EAAE,gBAAgBA,EAAE,WAAWnF,EAAmB,UACjD,kBAAC,KAAD;SAAG,WAAU;SAAuC,UAAAmF,EAAE;QAAgB,CAAA;OAErE;MACL,CAAA,GAAA,kBAAC,OAAD;OAAK,WAAU;OAAf,UAAA,CACE,kBAAC,KAAD;QAAG,WAAU;QAA+B,UAAAF,EAAeE,EAAE,SAAS;OAAK,CAAA,GAC1EA,EAAE,eACD,kBAAC,KAAD;QAAG,WAAU;QAAb,UAAA,CAAkD,cACrCF,EAAeE,EAAE,WAAW,CACtC;OAEF,CAAA,CAAA;MACH,CAAA,CAAA;KA9BG,GAAAA,EAAE,EA8BL,CACL;IACC,CAAA,CAEH;;GAEL,kBAAC,KAAD;IAAG,WAAU;IAAb,UAAA;KACGvE,EACC,0BACA,wGACF;KAAG;KACH,kBAAC,UAAD;MACE,MAAK;MACL,eAAeK,EAAW,mBAAmBwB,CAAiB;MAC9D,WAAU;MAET,UAAA7B,EAAG,oCAAoC,uBAAuB;KACzD,CAAA;IACP;;EACA;;AAET"}
1
+ {"version":3,"file":"UserRefundsPage.js","names":["UUID_RE","STATUS_CONFIG","RefundRecordStatus","Clock","Loader2","className","CheckCircle","XCircle","StatusBadge","cfg","status","Icon","UserRefundsPage","useI18n","tr","v","t","key","fallback","navigateTo","useBillingNavigate","permissions","useBillingPermissions","canRequestRefund","canShowRefundRequest","useIsFluidgridsVariant","showForm","setShowForm","useState","txnIdInput","setTxnIdInput","lookedUpTxn","setLookedUpTxn","txnNotFound","setTxnNotFound","reason","setReason","amount","setAmount","formError","setFormError","formSuccess","setFormSuccess","accountsData","accountsLoading","useGetBillingAccountsCheckoutQuery","accounts","useMemo","selectedAccountId","setSelectedAccountId","selectedAccount","a","fetchTxn","txnLookupData","txnLookupLoading","txnLookupError","useGetTransactionLazyQuery","lastLookupKey","useRef","txn","triggerLookup","txnId","accountId","handleTxnIdChange","value","handleAccountChange","refundsData","refundsLoading","refetchRefunds","useGetRefundRecordsQuery","refunds","createRefund","isSubmitting","useCreateRefundRecordMutation","getGatewayInfo","handleSubmit","gatewayInfo","parsedAmount","formatCurrency","resetFormFields","err","resetForm","PageHeader","PlusCircle","PagePurpose","CreditCard","X","Search","formatDateTime","IllustratedEmptyState","r"],"sources":["../../../../../src/billing/modules/billing/pages/UserRefundsPage.tsx"],"sourcesContent":["/**\n * Billing Module - User Refunds Page\n * Shows the user's refund request history and allows submitting new requests.\n */\n\nimport { useState, useEffect, useMemo, useRef, type FC, type FormEvent } from 'react';\nimport {\n PlusCircle,\n X,\n Clock,\n CheckCircle,\n XCircle,\n Loader2,\n Search,\n CreditCard,\n} from 'lucide-react';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport { formatCurrency, formatDateTime } from '../../../shared/utils';\nimport { PageHeader } from '../../../shared/components';\nimport { canShowRefundRequest } from '../../../shared/utils/accessRules';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PagePurpose, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\nimport {\n useGetBillingAccountsCheckoutQuery,\n useGetTransactionLazyQuery,\n useGetRefundRecordsQuery,\n useCreateRefundRecordMutation,\n type GetRefundRecordsQuery,\n type GetTransactionQuery,\n} from '../../../../generated/global-operations';\nimport { RefundRecordStatus } from '../../../../generated/global-types';\n\ntype RefundItem = NonNullable<GetRefundRecordsQuery['getRefundRecords']['records']>[number];\ntype TxnLookup = NonNullable<GetTransactionQuery['getTransaction']>;\n\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n// ============================================================================\n// Status helpers\n// ============================================================================\n\nconst STATUS_CONFIG: Record<\n RefundRecordStatus,\n { label: string; className: string; icon: FC<{ className?: string }> }\n> = {\n [RefundRecordStatus.Pending]: {\n label: 'In Review',\n className: 'bg-status-warning-bg/20 text-status-warning-text border-status-warning-border',\n icon: ({ className }) => <Clock className={className} />,\n },\n [RefundRecordStatus.Processing]: {\n label: 'Processing',\n className: 'bg-action-primary-bg/15 text-action-primary-bg border-action-primary-bg/30',\n icon: ({ className }) => <Loader2 className={`${className} animate-spin`} />,\n },\n [RefundRecordStatus.Completed]: {\n label: 'Refunded',\n className: 'bg-status-success-bg/20 text-status-success-text border-status-success-border',\n icon: ({ className }) => <CheckCircle className={className} />,\n },\n [RefundRecordStatus.Failed]: {\n label: 'Failed',\n className: 'bg-status-error-bg/20 text-status-error-text border-status-error-border',\n icon: ({ className }) => <XCircle className={className} />,\n },\n [RefundRecordStatus.Skipped]: {\n label: 'Closed',\n className: 'bg-bg-sunken text-text-secondary border-border-subtle',\n icon: ({ className }) => <XCircle className={className} />,\n },\n};\n\nfunction StatusBadge({ status }: { status: string }) {\n const cfg = STATUS_CONFIG[status as RefundRecordStatus] ?? {\n label: status,\n className: 'bg-bg-sunken text-text-secondary border-border-subtle',\n icon: ({ className }: { className?: string }) => <Clock className={className} />,\n };\n const Icon = cfg.icon;\n return (\n <span\n className={`inline-flex items-center gap-1 px-2 py-0.5 rounded-full border text-xs font-medium ${cfg.className}`}\n >\n <Icon className=\"size-3\" />\n {cfg.label}\n </span>\n );\n}\n\n// ============================================================================\n// Main page\n// ============================================================================\n\nexport const UserRefundsPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string) => {\n const v = t(key);\n return v === key ? fallback : v;\n };\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n // FluidGrids: createRefundRecord is `manage`-gated on the gateway, so the\n // request button only shows to people whose request can succeed (BOFF-11860).\n const canRequestRefund = canShowRefundRequest(\n useIsFluidgridsVariant(),\n permissions.canProcessRefund\n );\n\n // Form state\n const [showForm, setShowForm] = useState(false);\n const [txnIdInput, setTxnIdInput] = useState('');\n const [lookedUpTxn, setLookedUpTxn] = useState<TxnLookup | null>(null);\n const [txnNotFound, setTxnNotFound] = useState(false);\n const [reason, setReason] = useState('');\n const [amount, setAmount] = useState('');\n const [formError, setFormError] = useState<string | null>(null);\n const [formSuccess, setFormSuccess] = useState(false);\n\n // All billing accounts\n const { data: accountsData, loading: accountsLoading } = useGetBillingAccountsCheckoutQuery({\n fetchPolicy: 'cache-and-network',\n });\n type BillingAccount = NonNullable<typeof accountsData>['getBillingAccountsByOrg'][number];\n const accounts = useMemo<BillingAccount[]>(\n () => accountsData?.getBillingAccountsByOrg ?? [],\n [accountsData]\n );\n\n // Default to the first account; user can switch\n const [selectedAccountId, setSelectedAccountId] = useState<string | undefined>(undefined);\n useEffect(() => {\n if (!selectedAccountId && accounts.length > 0) {\n setSelectedAccountId(accounts[0].id);\n }\n }, [accounts, selectedAccountId]);\n\n const selectedAccount = accounts.find((a) => a.id === selectedAccountId);\n\n // Transaction lookup by ID (lazy — fires when user enters a valid UUID)\n const [fetchTxn, { data: txnLookupData, loading: txnLookupLoading, error: txnLookupError }] =\n useGetTransactionLazyQuery({ fetchPolicy: 'network-only' });\n\n // Track the \"active\" lookup key so we only apply results for the latest request\n const lastLookupKey = useRef('');\n\n useEffect(() => {\n if (txnLookupLoading) return;\n const txn = txnLookupData?.getTransaction;\n if (txn) {\n setLookedUpTxn(txn);\n setTxnNotFound(false);\n setAmount(String(txn.amount));\n } else if (txnLookupData !== undefined || txnLookupError) {\n setLookedUpTxn(null);\n setTxnNotFound(true);\n setAmount('');\n }\n }, [txnLookupData, txnLookupLoading, txnLookupError]);\n\n const triggerLookup = (txnId: string, accountId: string) => {\n const key = `${txnId}::${accountId}`;\n lastLookupKey.current = key;\n setLookedUpTxn(null);\n setTxnNotFound(false);\n setAmount('');\n fetchTxn({ variables: { id: txnId, billingAccountId: accountId } });\n };\n\n const handleTxnIdChange = (value: string) => {\n setTxnIdInput(value);\n setLookedUpTxn(null);\n setTxnNotFound(false);\n setAmount('');\n if (UUID_RE.test(value.trim()) && selectedAccountId) {\n triggerLookup(value.trim(), selectedAccountId);\n }\n };\n\n // When account changes, re-fetch the transaction if one is entered\n const handleAccountChange = (accountId: string) => {\n setSelectedAccountId(accountId);\n setLookedUpTxn(null);\n setTxnNotFound(false);\n setAmount('');\n if (UUID_RE.test(txnIdInput.trim())) {\n triggerLookup(txnIdInput.trim(), accountId);\n }\n };\n\n // Refund history for selected account\n const {\n data: refundsData,\n loading: refundsLoading,\n refetch: refetchRefunds,\n } = useGetRefundRecordsQuery({\n variables: { billingAccountId: selectedAccountId, pageSize: 20, page: 1 },\n skip: !selectedAccountId,\n fetchPolicy: 'cache-and-network',\n });\n const refunds = refundsData?.getRefundRecords.records ?? [];\n\n const [createRefund, { loading: isSubmitting }] = useCreateRefundRecordMutation({\n refetchQueries: ['GetRefundRecords'],\n });\n\n const getGatewayInfo = (txn: TxnLookup | null) => {\n if (!txn) return null;\n if (txn.stripePaymentId) return { provider: 'STRIPE', gatewayPaymentId: txn.stripePaymentId };\n if (txn.razorpayPaymentId)\n return { provider: 'RAZORPAY', gatewayPaymentId: txn.razorpayPaymentId };\n return null;\n };\n\n const handleSubmit = async (e: FormEvent) => {\n e.preventDefault();\n setFormError(null);\n\n if (!lookedUpTxn || !reason.trim() || !amount) {\n setFormError('Enter a valid transaction ID, an amount, and a reason.');\n return;\n }\n const gatewayInfo = getGatewayInfo(lookedUpTxn);\n if (!gatewayInfo) {\n setFormError('No payment gateway info found for this transaction. Please contact support.');\n return;\n }\n const parsedAmount = parseFloat(amount);\n if (isNaN(parsedAmount) || parsedAmount <= 0) {\n setFormError('Please enter a valid amount greater than 0.');\n return;\n }\n if (parsedAmount > lookedUpTxn.amount) {\n setFormError(\n `Cannot exceed the original payment amount (${formatCurrency(lookedUpTxn.amount, lookedUpTxn.currency)}).`\n );\n return;\n }\n\n try {\n await createRefund({\n variables: {\n billingAccountId: selectedAccountId,\n provider: gatewayInfo.provider,\n gatewayPaymentId: gatewayInfo.gatewayPaymentId,\n amount: parsedAmount,\n currency: lookedUpTxn.currency ?? selectedAccount?.currency ?? 'USD',\n transactionId: lookedUpTxn.id,\n reason: reason.trim(),\n notes: `Requested by user via billing portal`,\n },\n });\n setFormSuccess(true);\n setShowForm(false);\n resetFormFields();\n await refetchRefunds();\n } catch (err) {\n setFormError(err instanceof Error ? err.message : 'Failed to submit refund request.');\n }\n };\n\n const resetFormFields = () => {\n setTxnIdInput('');\n setLookedUpTxn(null);\n setTxnNotFound(false);\n setReason('');\n setAmount('');\n setFormError(null);\n };\n\n const resetForm = () => {\n setShowForm(false);\n setFormSuccess(false);\n resetFormFields();\n };\n\n return (\n <div className=\"space-y-6 p-6 max-w-3xl\">\n <PageHeader\n title={tr('billing.refunds.title', 'Refunds')}\n description={tr(\n 'billing.refunds.description',\n 'View your refund requests and submit new ones'\n )}\n actions={\n !showForm && canRequestRefund ? (\n <button\n type=\"button\"\n onClick={() => {\n setShowForm(true);\n setFormSuccess(false);\n }}\n className=\"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors\"\n >\n <PlusCircle className=\"size-4\" />\n {tr('billing.refunds.requestRefund', 'Request Refund')}\n </button>\n ) : undefined\n }\n />\n\n <PagePurpose>\n {tr(\n 'billing.refunds.userPurpose',\n 'Request money back for a payment and follow where each request stands. Paste the transaction ID of the charge you want refunded, tell us how much and why, and track every request here from \"In Review\" through to \"Refunded\".'\n )}\n </PagePurpose>\n\n {/* Billing account switcher */}\n {!accountsLoading && accounts.length > 1 && (\n <div className=\"flex items-center gap-3\">\n <CreditCard className=\"size-4 text-text-secondary shrink-0\" />\n <label htmlFor=\"accountSwitch\" className=\"text-sm text-text-secondary shrink-0\">\n {tr('billing.refunds.account', 'Billing account')}\n </label>\n <select\n id=\"accountSwitch\"\n value={selectedAccountId ?? ''}\n onChange={(e) => handleAccountChange(e.target.value)}\n className=\"flex-1 px-3 py-1.5 border border-border-subtle rounded-button bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] text-sm scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n {accounts.map((a) => (\n <option key={a.id} value={a.id}>\n {a.name} ({a.currency}) — {a.email}\n </option>\n ))}\n </select>\n </div>\n )}\n\n {/* Success banner */}\n {formSuccess && (\n <div className=\"flex items-center justify-between p-4 rounded-lg border border-status-success-border bg-status-success-bg/10\">\n <div className=\"flex items-center gap-2\">\n <CheckCircle className=\"size-4 text-status-success-text\" />\n <p className=\"text-sm text-status-success-text font-medium\">\n {tr(\n 'billing.refunds.submitted',\n 'Refund request submitted. Our team will review it shortly.'\n )}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => setFormSuccess(false)}\n className=\"text-status-success-text hover:opacity-70\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n )}\n\n {/* Request Refund Form */}\n {showForm && (\n <div className=\"border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 overflow-hidden\">\n <div className=\"flex items-center justify-between p-4 border-b border-border-subtle bg-bg-sunken\">\n <h2 className=\"font-semibold text-text-primary\">\n {tr('billing.refunds.newRequest', 'New Refund Request')}\n </h2>\n <button\n type=\"button\"\n onClick={resetForm}\n className=\"p-1 rounded hover:bg-bg-sunken transition-colors\"\n >\n <X className=\"size-4 text-text-secondary\" />\n </button>\n </div>\n\n <form onSubmit={handleSubmit} className=\"p-4 space-y-4\">\n {formError && (\n <div className=\"p-3 rounded-lg border border-status-error-border bg-status-error-bg/10\">\n <p className=\"text-sm text-status-error-text\">{formError}</p>\n </div>\n )}\n\n {/* Transaction ID lookup */}\n <div>\n <label htmlFor=\"txnId\" className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('billing.refunds.transactionId', 'Transaction ID')} *\n </label>\n <div className=\"relative\">\n <input\n id=\"txnId\"\n type=\"text\"\n value={txnIdInput}\n onChange={(e) => handleTxnIdChange(e.target.value)}\n placeholder=\"Paste your transaction ID...\"\n className=\"w-full pl-3 pr-9 py-2 border border-border-subtle rounded-button bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] text-sm font-mono\"\n />\n <div className=\"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-secondary\">\n {txnLookupLoading ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <Search className=\"size-4\" />\n )}\n </div>\n </div>\n\n {/* Transaction lookup result */}\n {lookedUpTxn && (\n <div className=\"mt-2 p-3 rounded-button border border-status-success-border bg-status-success-bg/10 text-sm space-y-0.5\">\n <div className=\"flex items-center gap-2\">\n <CheckCircle className=\"size-3.5 text-status-success-text shrink-0\" />\n <span className=\"font-medium text-text-primary\">\n {formatCurrency(lookedUpTxn.amount, lookedUpTxn.currency)}\n </span>\n <span className=\"text-text-secondary\">·</span>\n <span className=\"text-text-secondary\">\n {formatDateTime(lookedUpTxn.createdAt)}\n </span>\n {lookedUpTxn.stripePaymentId && (\n <span className=\"text-xs text-text-secondary\">Stripe</span>\n )}\n {lookedUpTxn.razorpayPaymentId && (\n <span className=\"text-xs text-text-secondary\">Razorpay</span>\n )}\n </div>\n {lookedUpTxn.description && (\n <p className=\"text-xs text-text-secondary pl-5\">{lookedUpTxn.description}</p>\n )}\n </div>\n )}\n {txnNotFound && txnIdInput.length > 0 && !txnLookupLoading && (\n <p className=\"mt-1 text-xs text-status-error-text\">\n {tr(\n 'billing.refunds.txnNotFound',\n 'Transaction not found in this billing account.'\n )}\n </p>\n )}\n {!UUID_RE.test(txnIdInput.trim()) && txnIdInput.length > 4 && (\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'billing.refunds.txnIdHint',\n 'Transaction IDs look like: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'\n )}\n </p>\n )}\n </div>\n\n {/* Amount — only shown once transaction is found */}\n {lookedUpTxn && (\n <div>\n <label\n htmlFor=\"refundAmount\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.refunds.amount', 'Refund Amount')} *\n </label>\n <div className=\"flex items-center gap-2\">\n <input\n id=\"refundAmount\"\n type=\"number\"\n step=\"0.01\"\n min=\"0.01\"\n max={lookedUpTxn.amount}\n value={amount}\n onChange={(e) => setAmount(e.target.value)}\n required\n className=\"w-40 px-3 py-2 border border-border-subtle rounded-button bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] text-sm\"\n placeholder=\"0.00\"\n />\n <span className=\"text-sm text-text-secondary\">\n {lookedUpTxn.currency ?? selectedAccount?.currency ?? 'USD'}\n </span>\n <span className=\"text-xs text-text-secondary\">\n max {formatCurrency(lookedUpTxn.amount, lookedUpTxn.currency)}\n </span>\n </div>\n </div>\n )}\n\n {/* Reason */}\n <div>\n <label htmlFor=\"reason\" className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('billing.refunds.reason', 'Reason for refund')} *\n </label>\n <textarea\n id=\"reason\"\n value={reason}\n onChange={(e) => setReason(e.target.value)}\n required\n rows={3}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-button bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] text-sm resize-none\"\n placeholder={tr(\n 'billing.refunds.reasonPlaceholder',\n 'Describe why you are requesting a refund...'\n )}\n />\n </div>\n\n <div className=\"flex items-center gap-3 pt-1\">\n <button\n type=\"submit\"\n disabled={isSubmitting || !lookedUpTxn || !reason.trim() || !amount}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n {isSubmitting\n ? tr('billing.refunds.submitting', 'Submitting...')\n : tr('billing.refunds.submitRequest', 'Submit Request')}\n </button>\n <button\n type=\"button\"\n onClick={resetForm}\n className=\"px-4 py-2 text-sm border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors\"\n >\n {tr('billing.common.cancel', 'Cancel')}\n </button>\n </div>\n </form>\n </div>\n )}\n\n {/* Refund history */}\n <div className=\"border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 overflow-hidden\">\n <div className=\"p-4 border-b border-border-subtle bg-bg-sunken\">\n <h2 className=\"font-semibold text-text-primary\">\n {tr('billing.refunds.history', 'Refund History')}\n </h2>\n </div>\n\n {accountsLoading || refundsLoading ? (\n <div className=\"p-8 flex items-center justify-center\">\n <Loader2 className=\"size-5 animate-spin text-text-secondary\" />\n </div>\n ) : refunds.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title={tr('billing.refunds.noRefunds', 'No refund requests yet')}\n description={tr(\n 'billing.refunds.noRefundsHint',\n 'If you have an issue with a payment, click \"Request Refund\" to get started.'\n )}\n />\n ) : (\n <ul className=\"divide-y divide-border-subtle\">\n {refunds.map((r: RefundItem) => (\n <li\n key={r.id}\n className=\"flex items-start gap-4 p-4 hover:bg-bg-sunken transition-colors\"\n >\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2 flex-wrap\">\n <span className=\"text-sm font-medium text-text-primary\">\n {formatCurrency(r.amount, r.currency)}\n </span>\n <StatusBadge status={r.status} />\n {r.purchaseDetail && (\n <span className=\"text-xs text-text-secondary truncate\">\n {r.purchaseDetail}\n </span>\n )}\n </div>\n {r.reason && (\n <p className=\"text-xs text-text-secondary mt-1 line-clamp-2\">{r.reason}</p>\n )}\n {r.errorMessage && r.status === RefundRecordStatus.Failed && (\n <p className=\"text-xs text-status-error-text mt-1\">{r.errorMessage}</p>\n )}\n </div>\n <div className=\"text-right shrink-0\">\n <p className=\"text-xs text-text-secondary\">{formatDateTime(r.createdAt)}</p>\n {r.processedAt && (\n <p className=\"text-xs text-text-secondary mt-0.5\">\n Processed {formatDateTime(r.processedAt)}\n </p>\n )}\n </div>\n </li>\n ))}\n </ul>\n )}\n </div>\n\n <p className=\"text-xs text-text-secondary\">\n {tr(\n 'billing.refunds.footer',\n 'Refund requests are reviewed by our team within 3–5 business days. For urgent issues, contact support.'\n )}{' '}\n <button\n type=\"button\"\n onClick={() => navigateTo('/transactions/' + selectedAccountId)}\n className=\"underline hover:no-underline\"\n >\n {tr('billing.refunds.viewTransactions', 'View all transactions')}\n </button>\n </p>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,IAAMA,IAAU,mEAMVC,IAGF;EACDC,EAAmB,UAAU;EAC5B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAACC,GAAD,EAAkB,aAAY,CAAA;CACzD;EACCD,EAAmB,aAAa;EAC/B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAACE,GAAD,EAAS,WAAW,GAAGC,EAAU,eAAiB,CAAA;CAC7E;EACCH,EAAmB,YAAY;EAC9B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAACI,GAAD,EAAwB,aAAY,CAAA;CAC/D;EACCJ,EAAmB,SAAS;EAC3B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAACK,GAAD,EAAoB,aAAY,CAAA;CAC3D;EACCL,EAAmB,UAAU;EAC5B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAACK,GAAD,EAAoB,aAAY,CAAA;CAC3D;AACF;AAEA,SAASC,EAAY,EAAE,aAA8B;CACnD,IAAMC,IAAMR,EAAcS,MAAiC;EACzD,OAAOA;EACP,WAAW;EACX,OAAO,EAAE,mBAAwC,kBAACP,GAAD,EAAkB,aAAY,CAAA;CACjF,GACMQ,IAAOF,EAAI;CACjB,OACE,kBAAC,QAAD;EACE,WAAW,sFAAsFA,EAAI;EADvG,UAAA,CAGE,kBAACE,GAAD,EAAM,WAAU,SAAU,CAAA,GACzBF,EAAI,KACD;;AAEV;AAMA,IAAaG,UAA4B;CACvC,IAAM,EAAE,SAAMC,GAAQ,GAChBC,KAAM,GAAa,MAAqB;EAC5C,IAAMC,IAAIC,EAAEC,CAAG;EACf,OAAOF,MAAME,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BAAC,KAAD;SAAG,WAAU;SAAiD,UAAAA,EAAE;QAAU,CAAA;QAE3EA,EAAE,gBAAgBA,EAAE,WAAWxF,EAAmB,UACjD,kBAAC,KAAD;SAAG,WAAU;SAAuC,UAAAwF,EAAE;QAAgB,CAAA;OAErE;MACL,CAAA,GAAA,kBAAC,OAAD;OAAK,WAAU;OAAf,UAAA,CACE,kBAAC,KAAD;QAAG,WAAU;QAA+B,UAAAF,EAAeE,EAAE,SAAS;OAAK,CAAA,GAC1EA,EAAE,eACD,kBAAC,KAAD;QAAG,WAAU;QAAb,UAAA,CAAkD,cACrCF,EAAeE,EAAE,WAAW,CACtC;OAEF,CAAA,CAAA;MACH,CAAA,CAAA;KA9BG,GAAAA,EAAE,EA8BL,CACL;IACC,CAAA,CAEH;;GAEL,kBAAC,KAAD;IAAG,WAAU;IAAb,UAAA;KACG5E,EACC,0BACA,wGACF;KAAG;KACH,kBAAC,UAAD;MACE,MAAK;MACL,eAAeK,EAAW,mBAAmB6B,CAAiB;MAC9D,WAAU;MAET,UAAAlC,EAAG,oCAAoC,uBAAuB;KACzD,CAAA;IACP;;EACA;;AAET"}
@@ -83,7 +83,10 @@ var C = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, w = "
83
83
  H(e instanceof Error ? e.message : "Failed to remove role");
84
84
  }
85
85
  };
86
- return P.canManageBillingAccount ? N ? /* @__PURE__ */ m("div", {
86
+ return P.isLoading ? /* @__PURE__ */ p("div", {
87
+ className: "flex min-h-[400px] items-center justify-center",
88
+ children: /* @__PURE__ */ p("div", { className: "size-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
89
+ }) : P.isBillingAdmin ? N ? /* @__PURE__ */ m("div", {
87
90
  className: "space-y-6 p-6",
88
91
  children: [
89
92
  /* @__PURE__ */ p(n, {
@@ -1 +1 @@
1
- {"version":3,"file":"TeamPermissionsPage.js","names":["UUID_RE","ROLES_QUERY","ACTORS_QUERY","ASSIGN_ROLE_MUTATION","REMOVE_ROLE_MUTATION","TeamPermissionsPage","useBilling","useBillingAccounts","useBillingAccountSelection","billingAccountId","selectedAccountId","permissions","useBillingPermissions","roles","setRoles","useState","actors","setActors","isLoading","setIsLoading","error","setError","newActorId","setNewActorId","newRoleId","setNewRoleId","isAdding","setIsAdding","removeAssignmentId","setRemoveAssignmentId","gqlPost","useCallback","directBillingGraphqlRequest","apiGatewayUrl","authToken","orgId","loadData","rolesResp","actorsResp","viewer","r","err","sortedActors","useMemo","priA","a","ra","b","profileInputs","profileMap","useActorProfiles","billingAccountName","billingAccounts","acct","handleAddMember","trimmedActorId","handleRemoveAssignment","PageHeader","PagePurpose","ActorIdentity","actor","AlertDialog","open","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","id","IllustratedEmptyState","AccessDenied"],"sources":["../../../../../src/billing/modules/settings/pages/TeamPermissionsPage.tsx"],"sourcesContent":["/**\n * Settings Module - Team & Permissions Page\n *\n * Lets a Billing Admin manage billing-scope role assignments for a specific\n * billing account. Calls global-rbac-svc directly via the same gateway URL\n * used by the rest of the billing module.\n *\n * Scope: `scopeType: \"billing\"`, `scopeId: <billingAccountId>`\n * Roles cloned per billing account at creation time:\n * - Billing Admin (full access to this billing account)\n * - Billing Viewer (read-only access to this billing account)\n */\nimport { useCallback, useEffect, useMemo, useState, type FC } from 'react';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n PagePurpose,\n IllustratedEmptyState,\n} from '@burdenoff/fe-libs/ui';\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { AccessDenied, ActorIdentity, PageHeader } from '../../../shared/components';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useBillingAccountSelection } from '../../../hooks/useBillingAccountSelection';\nimport { useBillingAccounts } from '../../dashboard/hooks/useDashboard';\nimport { directBillingGraphqlRequest } from '../../../shared/utils';\nimport { useActorProfiles } from '../../../shared/hooks';\n\n// Basic UUID-v1-through-v5 shape — accept any 8-4-4-4-12 hex pattern.\n// We intentionally don't strictly validate the version nibble; the rbac\n// service is the authoritative ID validator.\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\ninterface Role {\n id: string;\n name: string;\n description?: string | null;\n priority: number;\n isSystem: boolean;\n}\n\ninterface ActorRoleAssignment {\n id: string;\n actorId: string;\n actorType: string;\n roleId: string;\n scopeId: string;\n isActive: boolean;\n expiresAt?: string | null;\n role?: Role;\n}\n\ninterface ActorRbacSummary {\n actorId: string;\n actorType: string;\n roleAssignments: ActorRoleAssignment[];\n effectivePermissionCount?: number;\n}\n\nconst ROLES_QUERY = `\n query BillingScopeRoles($scopeId: String!) {\n roles(scopeId: $scopeId) {\n id\n name\n description\n priority\n isSystem\n }\n }\n`;\n\nconst ACTORS_QUERY = `\n query BillingScopeActors($scopeId: String!) {\n actors(scopeId: $scopeId) {\n actorId\n actorType\n roleAssignments {\n id\n actorId\n actorType\n roleId\n scopeId\n isActive\n expiresAt\n role { id name priority }\n }\n }\n }\n`;\n\nconst ASSIGN_ROLE_MUTATION = `\n mutation AssignBillingRole($input: AssignRoleInput!) {\n assignRoleToActor(input: $input) {\n id\n actorId\n roleId\n scopeId\n }\n }\n`;\n\nconst REMOVE_ROLE_MUTATION = `\n mutation RemoveBillingRole($assignmentId: String!) {\n removeRoleFromActor(assignmentId: $assignmentId)\n }\n`;\n\nexport const TeamPermissionsPage: FC = () => {\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n\n // Resolution priority: URL `?billingAccountId=` → persisted localStorage →\n // default/first available account. Pass `billingAccounts` so first-time\n // users with empty localStorage still land on the default account\n // (without it the hook's auto-select effect can't fire and the page\n // dead-ends on \"No billing account selected\").\n const { billingAccounts } = useBillingAccounts();\n const { selectedAccountId } = useBillingAccountSelection({\n orgId,\n billingAccounts,\n syncFromUrl: true,\n urlParamName: 'billingAccountId',\n });\n const billingAccountId = selectedAccountId ?? undefined;\n\n // Share the resolved account with `useBillingPermissions` so its\n // billing-scope permissions fetch observes the same ID. Without this,\n // a first-time user (no URL param, empty localStorage) would see the\n // page resolve to the default account here while the permissions hook\n // still sat at null — billing-scope-only admins would see AccessDenied\n // until a navigation/reload propagated the localStorage write.\n const permissions = useBillingPermissions({ billingAccountIdOverride: billingAccountId });\n\n const [roles, setRoles] = useState<Role[]>([]);\n const [actors, setActors] = useState<ActorRbacSummary[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n // Add-member form\n const [newActorId, setNewActorId] = useState('');\n const [newRoleId, setNewRoleId] = useState('');\n const [isAdding, setIsAdding] = useState(false);\n const [removeAssignmentId, setRemoveAssignmentId] = useState<string | null>(null);\n\n const gqlPost = useCallback(\n async <T,>(query: string, variables: Record<string, unknown>): Promise<T> => {\n return directBillingGraphqlRequest<T>({\n apiGatewayUrl,\n authToken,\n orgId,\n query,\n variables,\n });\n },\n [apiGatewayUrl, authToken, orgId]\n );\n\n const loadData = useCallback(async () => {\n if (!billingAccountId) return;\n setIsLoading(true);\n setError(null);\n try {\n const [rolesResp, actorsResp] = await Promise.all([\n gqlPost<{ roles: Role[] }>(ROLES_QUERY, { scopeId: billingAccountId }),\n gqlPost<{ actors: ActorRbacSummary[] }>(ACTORS_QUERY, {\n scopeId: billingAccountId,\n }),\n ]);\n setRoles(rolesResp.roles ?? []);\n setActors(actorsResp.actors ?? []);\n // Default the role-picker to \"Billing Viewer\" if available, else first role\n const viewer = (rolesResp.roles ?? []).find((r) => /viewer/i.test(r.name));\n setNewRoleId(viewer?.id ?? rolesResp.roles?.[0]?.id ?? '');\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to load team data');\n } finally {\n setIsLoading(false);\n }\n }, [billingAccountId, gqlPost]);\n\n useEffect(() => {\n void loadData();\n }, [loadData]);\n\n const sortedActors = useMemo(\n () =>\n [...actors].sort((a, b) => {\n const priA = Math.max(...a.roleAssignments.map((ra) => ra.role?.priority ?? 0), 0);\n const priB = Math.max(...b.roleAssignments.map((ra) => ra.role?.priority ?? 0), 0);\n return priB - priA;\n }),\n [actors]\n );\n\n const profileInputs = useMemo(\n () =>\n sortedActors.map((a) => ({\n actorId: a.actorId,\n actorType: a.actorType,\n })),\n [sortedActors]\n );\n const profileMap = useActorProfiles(profileInputs);\n\n const billingAccountName = useMemo(() => {\n if (!billingAccountId) return undefined;\n return billingAccounts.find((acct) => acct.id === billingAccountId)?.name ?? undefined;\n }, [billingAccountId, billingAccounts]);\n\n const handleAddMember = async (e: React.FormEvent) => {\n e.preventDefault();\n if (!billingAccountId || !newActorId.trim() || !newRoleId) return;\n const trimmedActorId = newActorId.trim();\n if (!UUID_RE.test(trimmedActorId)) {\n setError('User ID must be a UUID (e.g. 1a2b3c4d-...). Get it from the user profile page.');\n return;\n }\n setIsAdding(true);\n setError(null);\n try {\n await gqlPost(ASSIGN_ROLE_MUTATION, {\n input: {\n actorId: trimmedActorId,\n actorType: 'USER',\n roleId: newRoleId,\n scopeId: billingAccountId,\n },\n });\n setNewActorId('');\n await loadData();\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to assign role');\n } finally {\n setIsAdding(false);\n }\n };\n\n const handleRemoveAssignment = async (assignmentId: string) => {\n setError(null);\n try {\n await gqlPost(REMOVE_ROLE_MUTATION, { assignmentId });\n await loadData();\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to remove role');\n }\n };\n\n if (!permissions.canManageBillingAccount) {\n return (\n <AccessDenied message=\"You don't have permission to manage team and permissions for this billing account.\" />\n );\n }\n\n if (!billingAccountId) {\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title=\"Team & Permissions\"\n description=\"Select a billing account to manage who can access it.\"\n />\n <IllustratedEmptyState\n illustration=\"empty-people\"\n title=\"No billing account selected\"\n description=\"Pick one from the billing account selector to manage its members and roles.\"\n />\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title=\"Team & Permissions\"\n description=\"Control who can manage this billing account and what they can do.\"\n />\n\n <PagePurpose>\n Decide who on your team can see and manage this billing account. Assign the Billing Admin\n role (full access) or Billing Viewer (read-only) to specific people, and revoke access when\n someone no longer needs it.\n </PagePurpose>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm\">\n <span className=\"font-medium text-text-primary\">Billing account:</span>{' '}\n <span className=\"text-text-primary\">{billingAccountName ?? 'Unnamed account'}</span>\n {billingAccountId ? (\n <details className=\"mt-2 text-xs text-text-secondary\">\n <summary className=\"cursor-pointer\">Account ID</summary>\n <span className=\"mt-1 inline-block font-mono\">{billingAccountId}</span>\n </details>\n ) : null}\n </div>\n\n {error && (\n <div className=\"rounded-lg border border-status-error-border/30 bg-status-error-bg/5 p-4 text-sm text-status-error-text\">\n {error}\n </div>\n )}\n\n {/* Add member form */}\n <form\n onSubmit={(e) => void handleAddMember(e)}\n className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 space-y-3\"\n >\n <h3 className=\"text-sm font-semibold text-text-primary\">Add member</h3>\n <div className=\"grid grid-cols-1 gap-3 md:grid-cols-3\">\n <div className=\"md:col-span-2\">\n <label htmlFor=\"newActorId\" className=\"block text-xs font-medium text-text-secondary\">\n User ID\n </label>\n <input\n id=\"newActorId\"\n type=\"text\"\n value={newActorId}\n onChange={(e) => setNewActorId(e.target.value)}\n placeholder=\"Paste the user ID from their profile page\"\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm\"\n required\n />\n <p className=\"mt-1 text-[11px] text-text-secondary\">\n Find this on the user&apos;s profile page.\n </p>\n </div>\n <div>\n <label htmlFor=\"newRoleId\" className=\"block text-xs font-medium text-text-secondary\">\n Role\n </label>\n <select\n id=\"newRoleId\"\n value={newRoleId}\n onChange={(e) => setNewRoleId(e.target.value)}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n required\n >\n {roles.map((r) => (\n <option key={r.id} value={r.id}>\n {r.name}\n </option>\n ))}\n </select>\n </div>\n </div>\n <button\n type=\"submit\"\n disabled={isAdding || !newActorId.trim() || !newRoleId}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text disabled:opacity-50\"\n >\n {isAdding ? 'Adding…' : 'Add member'}\n </button>\n </form>\n\n {/* Members table */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface\">\n <div className=\"border-b border-border-subtle px-4 py-3\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Members</h3>\n <p className=\"text-xs text-text-secondary\">\n Each member&apos;s role applies only to this billing account.\n </p>\n </div>\n {isLoading ? (\n <div className=\"p-6 text-sm text-text-secondary\">Loading…</div>\n ) : sortedActors.length === 0 ? (\n <div className=\"p-6 text-sm text-text-secondary\">No members assigned yet.</div>\n ) : (\n <table className=\"w-full text-sm\">\n <thead>\n <tr className=\"border-b border-border-subtle text-left text-xs text-text-secondary\">\n <th className=\"px-4 py-2\">Member</th>\n <th className=\"px-4 py-2\">Type</th>\n <th className=\"px-4 py-2\">Roles</th>\n <th className=\"px-4 py-2 text-right\">Actions</th>\n </tr>\n </thead>\n <tbody>\n {sortedActors.map((actor) => (\n <tr key={actor.actorId} className=\"border-b border-border-subtle last:border-0\">\n <td className=\"px-4 py-3\">\n <ActorIdentity\n profile={\n profileMap[actor.actorId] ?? {\n actorId: actor.actorId,\n actorType: actor.actorType,\n displayName:\n actor.actorType.toLowerCase() === 'user'\n ? `User ${actor.actorId.slice(0, 8)}…`\n : actor.actorType,\n secondaryLabel: actor.actorId.slice(0, 12),\n resolved: false,\n }\n }\n variant=\"cell\"\n />\n </td>\n <td className=\"px-4 py-3 text-xs capitalize text-text-secondary\">\n {actor.actorType.toLowerCase()}\n </td>\n <td className=\"px-4 py-3\">\n <div className=\"flex flex-wrap gap-1\">\n {actor.roleAssignments\n .filter((ra) => ra.isActive)\n .map((ra) => (\n <span\n key={ra.id}\n className=\"inline-flex items-center gap-1 rounded-full border border-border-subtle bg-bg-sunken px-2 py-0.5 text-xs\"\n >\n {ra.role?.name ?? ra.roleId}\n <button\n type=\"button\"\n onClick={() => setRemoveAssignmentId(ra.id)}\n className=\"text-text-secondary hover:text-status-error-text\"\n aria-label={`Remove ${ra.role?.name ?? 'role'}`}\n >\n ×\n </button>\n </span>\n ))}\n </div>\n </td>\n <td className=\"px-4 py-3 text-right\">\n <span className=\"text-xs text-text-secondary\">\n {actor.effectivePermissionCount ?? '—'} permissions\n </span>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n )}\n </div>\n\n {/* Roles reference */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Available roles</h3>\n <p className=\"mt-1 text-xs text-text-secondary\">\n Roles are cloned from the system templates when a billing account is created.\n </p>\n <ul className=\"mt-3 space-y-2\">\n {roles.map((r) => (\n <li\n key={r.id}\n className=\"flex items-start gap-3 rounded-md border border-border-subtle bg-bg-surface p-3\"\n >\n <div className=\"flex-1\">\n <div className=\"text-sm font-medium text-text-primary\">{r.name}</div>\n {r.description && (\n <p className=\"mt-1 text-xs text-text-secondary\">{r.description}</p>\n )}\n </div>\n <span className=\"text-xs text-text-secondary\">priority {r.priority}</span>\n </li>\n ))}\n </ul>\n </div>\n\n <AlertDialog\n open={removeAssignmentId !== null}\n onOpenChange={(open) => {\n if (!open) setRemoveAssignmentId(null);\n }}\n >\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Remove role assignment?</AlertDialogTitle>\n <AlertDialogDescription>\n Remove this role assignment? The member will lose the access this role grants for this\n billing account.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Cancel</AlertDialogCancel>\n <AlertDialogAction\n onClick={() => {\n const id = removeAssignmentId;\n setRemoveAssignmentId(null);\n if (id) void handleRemoveAssignment(id);\n }}\n >\n Remove\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,IAAMA,IAAU,mEA4BVC,IAAc,2KAYdC,IAAe,+TAmBfC,IAAuB,0KAWvBC,IAAuB,yHAMhBC,UAAgC;CAC3C,IAAM,EAAE,kBAAe,cAAW,aAAUC,EAAW,GAOjD,EAAE,uBAAoBC,EAAmB,GACzC,EAAE,yBAAsBC,EAA2B;EACvD;EACA;EACA,aAAa;EACb,cAAc;CAChB,CAAC,GACKC,IAAmBC,KAAqB,KAAA,GAQxCC,IAAcC,EAAsB,EAAE,0BAA0BH,EAAiB,CAAC,GAElF,CAACI,GAAOC,KAAYC,EAAiB,CAAC,CAAC,GACvC,CAACC,GAAQC,KAAaF,EAA6B,CAAC,CAAC,GACrD,CAACG,GAAWC,KAAgBJ,EAAS,EAAK,GAC1C,CAACK,GAAOC,KAAYN,EAAwB,IAAI,GAGhD,CAACO,GAAYC,KAAiBR,EAAS,EAAE,GACzC,CAACS,GAAWC,KAAgBV,EAAS,EAAE,GACvC,CAACW,GAAUC,KAAeZ,EAAS,EAAK,GACxC,CAACa,GAAoBC,KAAyBd,EAAwB,IAAI,GAE1Ee,IAAUC,EACd,OAAW,GAAe,MACjBC,EAA+B;EACpC;EACA;EACA;EACA;EACA;CACF,CAAC,GAEH;EAACC;EAAeC;EAAWC;CAAK,CAClC,GAEMC,IAAWL,EAAY,YAAY;EACvC,IAAKtB,GACL;GACA,AADAU,EAAa,EAAI,GACjBE,EAAS,IAAI;GACb,IAAI;IACF,IAAM,CAACgB,GAAWC,KAAc,MAAM,QAAQ,IAAI,CAChDR,EAA2B7B,GAAa,EAAE,SAASQ,EAAiB,CAAC,GACrEqB,EAAwC5B,GAAc,EACpD,SA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AAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAmB,SAAyB,CAAA,GAC5C,kBAACC,GAAD;KACE,eAAe;MACb,IAAMC,IAAK1C;MAEX,AADAC,EAAsB,IAAI,GACtByC,KAAId,GAA4Bc,CAAE;KACxC;KACD,UAAA;IAEkB,CAAA,CACF,EAAA,CAAA,CACD,EAAA,CAAA;GACT,CAAA;EACV;C,KAnOH,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACb,GAAD;GACE,OAAM;GACN,aAAY;EACb,CAAA,GACD,kBAACc,GAAD;GACE,cAAa;GACb,OAAM;GACN,aAAY;EACb,CAAA,CACE;C,KAhBL,kBAACC,GAAD,EAAc,SAAQ,qFAAsF,CAAA;AA2OlH"}
1
+ {"version":3,"file":"TeamPermissionsPage.js","names":["UUID_RE","ROLES_QUERY","ACTORS_QUERY","ASSIGN_ROLE_MUTATION","REMOVE_ROLE_MUTATION","TeamPermissionsPage","useBilling","useBillingAccounts","useBillingAccountSelection","billingAccountId","selectedAccountId","permissions","useBillingPermissions","roles","setRoles","useState","actors","setActors","isLoading","setIsLoading","error","setError","newActorId","setNewActorId","newRoleId","setNewRoleId","isAdding","setIsAdding","removeAssignmentId","setRemoveAssignmentId","gqlPost","useCallback","directBillingGraphqlRequest","apiGatewayUrl","authToken","orgId","loadData","rolesResp","actorsResp","viewer","r","err","sortedActors","useMemo","priA","a","ra","b","profileInputs","profileMap","useActorProfiles","billingAccountName","billingAccounts","acct","handleAddMember","trimmedActorId","handleRemoveAssignment","PageHeader","PagePurpose","ActorIdentity","actor","AlertDialog","open","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","id","IllustratedEmptyState","AccessDenied"],"sources":["../../../../../src/billing/modules/settings/pages/TeamPermissionsPage.tsx"],"sourcesContent":["/**\n * Settings Module - Team & Permissions Page\n *\n * Lets a Billing Admin manage billing-scope role assignments for a specific\n * billing account. Calls global-rbac-svc directly via the same gateway URL\n * used by the rest of the billing module.\n *\n * Scope: `scopeType: \"billing\"`, `scopeId: <billingAccountId>`\n * Roles cloned per billing account at creation time:\n * - Billing Admin (full access to this billing account)\n * - Billing Viewer (read-only access to this billing account)\n */\nimport { useCallback, useEffect, useMemo, useState, type FC } from 'react';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n PagePurpose,\n IllustratedEmptyState,\n} from '@burdenoff/fe-libs/ui';\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { AccessDenied, ActorIdentity, PageHeader } from '../../../shared/components';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useBillingAccountSelection } from '../../../hooks/useBillingAccountSelection';\nimport { useBillingAccounts } from '../../dashboard/hooks/useDashboard';\nimport { directBillingGraphqlRequest } from '../../../shared/utils';\nimport { useActorProfiles } from '../../../shared/hooks';\n\n// Basic UUID-v1-through-v5 shape — accept any 8-4-4-4-12 hex pattern.\n// We intentionally don't strictly validate the version nibble; the rbac\n// service is the authoritative ID validator.\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\ninterface Role {\n id: string;\n name: string;\n description?: string | null;\n priority: number;\n isSystem: boolean;\n}\n\ninterface ActorRoleAssignment {\n id: string;\n actorId: string;\n actorType: string;\n roleId: string;\n scopeId: string;\n isActive: boolean;\n expiresAt?: string | null;\n role?: Role;\n}\n\ninterface ActorRbacSummary {\n actorId: string;\n actorType: string;\n roleAssignments: ActorRoleAssignment[];\n effectivePermissionCount?: number;\n}\n\nconst ROLES_QUERY = `\n query BillingScopeRoles($scopeId: String!) {\n roles(scopeId: $scopeId) {\n id\n name\n description\n priority\n isSystem\n }\n }\n`;\n\nconst ACTORS_QUERY = `\n query BillingScopeActors($scopeId: String!) {\n actors(scopeId: $scopeId) {\n actorId\n actorType\n roleAssignments {\n id\n actorId\n actorType\n roleId\n scopeId\n isActive\n expiresAt\n role { id name priority }\n }\n }\n }\n`;\n\nconst ASSIGN_ROLE_MUTATION = `\n mutation AssignBillingRole($input: AssignRoleInput!) {\n assignRoleToActor(input: $input) {\n id\n actorId\n roleId\n scopeId\n }\n }\n`;\n\nconst REMOVE_ROLE_MUTATION = `\n mutation RemoveBillingRole($assignmentId: String!) {\n removeRoleFromActor(assignmentId: $assignmentId)\n }\n`;\n\nexport const TeamPermissionsPage: FC = () => {\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n\n // Resolution priority: URL `?billingAccountId=` → persisted localStorage →\n // default/first available account. Pass `billingAccounts` so first-time\n // users with empty localStorage still land on the default account\n // (without it the hook's auto-select effect can't fire and the page\n // dead-ends on \"No billing account selected\").\n const { billingAccounts } = useBillingAccounts();\n const { selectedAccountId } = useBillingAccountSelection({\n orgId,\n billingAccounts,\n syncFromUrl: true,\n urlParamName: 'billingAccountId',\n });\n const billingAccountId = selectedAccountId ?? undefined;\n\n // Share the resolved account with `useBillingPermissions` so its\n // billing-scope permissions fetch observes the same ID. Without this,\n // a first-time user (no URL param, empty localStorage) would see the\n // page resolve to the default account here while the permissions hook\n // still sat at null — billing-scope-only admins would see AccessDenied\n // until a navigation/reload propagated the localStorage write.\n const permissions = useBillingPermissions({ billingAccountIdOverride: billingAccountId });\n\n const [roles, setRoles] = useState<Role[]>([]);\n const [actors, setActors] = useState<ActorRbacSummary[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n // Add-member form\n const [newActorId, setNewActorId] = useState('');\n const [newRoleId, setNewRoleId] = useState('');\n const [isAdding, setIsAdding] = useState(false);\n const [removeAssignmentId, setRemoveAssignmentId] = useState<string | null>(null);\n\n const gqlPost = useCallback(\n async <T,>(query: string, variables: Record<string, unknown>): Promise<T> => {\n return directBillingGraphqlRequest<T>({\n apiGatewayUrl,\n authToken,\n orgId,\n query,\n variables,\n });\n },\n [apiGatewayUrl, authToken, orgId]\n );\n\n const loadData = useCallback(async () => {\n if (!billingAccountId) return;\n setIsLoading(true);\n setError(null);\n try {\n const [rolesResp, actorsResp] = await Promise.all([\n gqlPost<{ roles: Role[] }>(ROLES_QUERY, { scopeId: billingAccountId }),\n gqlPost<{ actors: ActorRbacSummary[] }>(ACTORS_QUERY, {\n scopeId: billingAccountId,\n }),\n ]);\n setRoles(rolesResp.roles ?? []);\n setActors(actorsResp.actors ?? []);\n // Default the role-picker to \"Billing Viewer\" if available, else first role\n const viewer = (rolesResp.roles ?? []).find((r) => /viewer/i.test(r.name));\n setNewRoleId(viewer?.id ?? rolesResp.roles?.[0]?.id ?? '');\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to load team data');\n } finally {\n setIsLoading(false);\n }\n }, [billingAccountId, gqlPost]);\n\n useEffect(() => {\n void loadData();\n }, [loadData]);\n\n const sortedActors = useMemo(\n () =>\n [...actors].sort((a, b) => {\n const priA = Math.max(...a.roleAssignments.map((ra) => ra.role?.priority ?? 0), 0);\n const priB = Math.max(...b.roleAssignments.map((ra) => ra.role?.priority ?? 0), 0);\n return priB - priA;\n }),\n [actors]\n );\n\n const profileInputs = useMemo(\n () =>\n sortedActors.map((a) => ({\n actorId: a.actorId,\n actorType: a.actorType,\n })),\n [sortedActors]\n );\n const profileMap = useActorProfiles(profileInputs);\n\n const billingAccountName = useMemo(() => {\n if (!billingAccountId) return undefined;\n return billingAccounts.find((acct) => acct.id === billingAccountId)?.name ?? undefined;\n }, [billingAccountId, billingAccounts]);\n\n const handleAddMember = async (e: React.FormEvent) => {\n e.preventDefault();\n if (!billingAccountId || !newActorId.trim() || !newRoleId) return;\n const trimmedActorId = newActorId.trim();\n if (!UUID_RE.test(trimmedActorId)) {\n setError('User ID must be a UUID (e.g. 1a2b3c4d-...). Get it from the user profile page.');\n return;\n }\n setIsAdding(true);\n setError(null);\n try {\n await gqlPost(ASSIGN_ROLE_MUTATION, {\n input: {\n actorId: trimmedActorId,\n actorType: 'USER',\n roleId: newRoleId,\n scopeId: billingAccountId,\n },\n });\n setNewActorId('');\n await loadData();\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to assign role');\n } finally {\n setIsAdding(false);\n }\n };\n\n const handleRemoveAssignment = async (assignmentId: string) => {\n setError(null);\n try {\n await gqlPost(REMOVE_ROLE_MUTATION, { assignmentId });\n await loadData();\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to remove role');\n }\n };\n\n if (permissions.isLoading) {\n return (\n <div className=\"flex min-h-[400px] items-center justify-center\">\n <div className=\"size-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!permissions.isBillingAdmin) {\n return (\n <AccessDenied message=\"You don't have permission to manage team and permissions for this billing account.\" />\n );\n }\n\n if (!billingAccountId) {\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title=\"Team & Permissions\"\n description=\"Select a billing account to manage who can access it.\"\n />\n <IllustratedEmptyState\n illustration=\"empty-people\"\n title=\"No billing account selected\"\n description=\"Pick one from the billing account selector to manage its members and roles.\"\n />\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title=\"Team & Permissions\"\n description=\"Control who can manage this billing account and what they can do.\"\n />\n\n <PagePurpose>\n Decide who on your team can see and manage this billing account. Assign the Billing Admin\n role (full access) or Billing Viewer (read-only) to specific people, and revoke access when\n someone no longer needs it.\n </PagePurpose>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm\">\n <span className=\"font-medium text-text-primary\">Billing account:</span>{' '}\n <span className=\"text-text-primary\">{billingAccountName ?? 'Unnamed account'}</span>\n {billingAccountId ? (\n <details className=\"mt-2 text-xs text-text-secondary\">\n <summary className=\"cursor-pointer\">Account ID</summary>\n <span className=\"mt-1 inline-block font-mono\">{billingAccountId}</span>\n </details>\n ) : null}\n </div>\n\n {error && (\n <div className=\"rounded-lg border border-status-error-border/30 bg-status-error-bg/5 p-4 text-sm text-status-error-text\">\n {error}\n </div>\n )}\n\n {/* Add member form */}\n <form\n onSubmit={(e) => void handleAddMember(e)}\n className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 space-y-3\"\n >\n <h3 className=\"text-sm font-semibold text-text-primary\">Add member</h3>\n <div className=\"grid grid-cols-1 gap-3 md:grid-cols-3\">\n <div className=\"md:col-span-2\">\n <label htmlFor=\"newActorId\" className=\"block text-xs font-medium text-text-secondary\">\n User ID\n </label>\n <input\n id=\"newActorId\"\n type=\"text\"\n value={newActorId}\n onChange={(e) => setNewActorId(e.target.value)}\n placeholder=\"Paste the user ID from their profile page\"\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm\"\n required\n />\n <p className=\"mt-1 text-[11px] text-text-secondary\">\n Find this on the user&apos;s profile page.\n </p>\n </div>\n <div>\n <label htmlFor=\"newRoleId\" className=\"block text-xs font-medium text-text-secondary\">\n Role\n </label>\n <select\n id=\"newRoleId\"\n value={newRoleId}\n onChange={(e) => setNewRoleId(e.target.value)}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n required\n >\n {roles.map((r) => (\n <option key={r.id} value={r.id}>\n {r.name}\n </option>\n ))}\n </select>\n </div>\n </div>\n <button\n type=\"submit\"\n disabled={isAdding || !newActorId.trim() || !newRoleId}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text disabled:opacity-50\"\n >\n {isAdding ? 'Adding…' : 'Add member'}\n </button>\n </form>\n\n {/* Members table */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface\">\n <div className=\"border-b border-border-subtle px-4 py-3\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Members</h3>\n <p className=\"text-xs text-text-secondary\">\n Each member&apos;s role applies only to this billing account.\n </p>\n </div>\n {isLoading ? (\n <div className=\"p-6 text-sm text-text-secondary\">Loading…</div>\n ) : sortedActors.length === 0 ? (\n <div className=\"p-6 text-sm text-text-secondary\">No members assigned yet.</div>\n ) : (\n <table className=\"w-full text-sm\">\n <thead>\n <tr className=\"border-b border-border-subtle text-left text-xs text-text-secondary\">\n <th className=\"px-4 py-2\">Member</th>\n <th className=\"px-4 py-2\">Type</th>\n <th className=\"px-4 py-2\">Roles</th>\n <th className=\"px-4 py-2 text-right\">Actions</th>\n </tr>\n </thead>\n <tbody>\n {sortedActors.map((actor) => (\n <tr key={actor.actorId} className=\"border-b border-border-subtle last:border-0\">\n <td className=\"px-4 py-3\">\n <ActorIdentity\n profile={\n profileMap[actor.actorId] ?? {\n actorId: actor.actorId,\n actorType: actor.actorType,\n displayName:\n actor.actorType.toLowerCase() === 'user'\n ? `User ${actor.actorId.slice(0, 8)}…`\n : actor.actorType,\n secondaryLabel: actor.actorId.slice(0, 12),\n resolved: false,\n }\n }\n variant=\"cell\"\n />\n </td>\n <td className=\"px-4 py-3 text-xs capitalize text-text-secondary\">\n {actor.actorType.toLowerCase()}\n </td>\n <td className=\"px-4 py-3\">\n <div className=\"flex flex-wrap gap-1\">\n {actor.roleAssignments\n .filter((ra) => ra.isActive)\n .map((ra) => (\n <span\n key={ra.id}\n className=\"inline-flex items-center gap-1 rounded-full border border-border-subtle bg-bg-sunken px-2 py-0.5 text-xs\"\n >\n {ra.role?.name ?? ra.roleId}\n <button\n type=\"button\"\n onClick={() => setRemoveAssignmentId(ra.id)}\n className=\"text-text-secondary hover:text-status-error-text\"\n aria-label={`Remove ${ra.role?.name ?? 'role'}`}\n >\n ×\n </button>\n </span>\n ))}\n </div>\n </td>\n <td className=\"px-4 py-3 text-right\">\n <span className=\"text-xs text-text-secondary\">\n {actor.effectivePermissionCount ?? '—'} permissions\n </span>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n )}\n </div>\n\n {/* Roles reference */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Available roles</h3>\n <p className=\"mt-1 text-xs text-text-secondary\">\n Roles are cloned from the system templates when a billing account is created.\n </p>\n <ul className=\"mt-3 space-y-2\">\n {roles.map((r) => (\n <li\n key={r.id}\n className=\"flex items-start gap-3 rounded-md border border-border-subtle bg-bg-surface p-3\"\n >\n <div className=\"flex-1\">\n <div className=\"text-sm font-medium text-text-primary\">{r.name}</div>\n {r.description && (\n <p className=\"mt-1 text-xs text-text-secondary\">{r.description}</p>\n )}\n </div>\n <span className=\"text-xs text-text-secondary\">priority {r.priority}</span>\n </li>\n ))}\n </ul>\n </div>\n\n <AlertDialog\n open={removeAssignmentId !== null}\n onOpenChange={(open) => {\n if (!open) setRemoveAssignmentId(null);\n }}\n >\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Remove role assignment?</AlertDialogTitle>\n <AlertDialogDescription>\n Remove this role assignment? The member will lose the access this role grants for this\n billing account.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Cancel</AlertDialogCancel>\n <AlertDialogAction\n onClick={() => {\n const id = removeAssignmentId;\n setRemoveAssignmentId(null);\n if (id) void handleRemoveAssignment(id);\n }}\n >\n Remove\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,IAAMA,IAAU,mEA4BVC,IAAc,2KAYdC,IAAe,+TAmBfC,IAAuB,0KAWvBC,IAAuB,yHAMhBC,UAAgC;CAC3C,IAAM,EAAE,kBAAe,cAAW,aAAUC,EAAW,GAOjD,EAAE,uBAAoBC,EAAmB,GACzC,EAAE,yBAAsBC,EAA2B;EACvD;EACA;EACA,aAAa;EACb,cAAc;CAChB,CAAC,GACKC,IAAmBC,KAAqB,KAAA,GAQxCC,IAAcC,EAAsB,EAAE,0BAA0BH,EAAiB,CAAC,GAElF,CAACI,GAAOC,KAAYC,EAAiB,CAAC,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38 +8,39 @@ var s = "burdenoff:nativeIapTransaction", c = t(null), l = () => {
8
8
  let e = n(c);
9
9
  if (!e) throw Error("useBilling must be used within BillingProvider");
10
10
  return e;
11
- }, u = ({ children: t, basePath: n, navigate: l, currentUser: u, workspaceId: d, orgId: f, productId: p, plansDocsUrl: m, apiGatewayUrl: h, authToken: g, stripePublishableKey: _, razorpayKey: v, onSubscriptionCreate: y, onSubscriptionUpdate: b, onPaymentProcess: x, registerNavItems: S, registerFooterItems: C }) => {
11
+ }, u = ({ children: t, basePath: n, navigate: l, currentUser: u, workspaceId: d, orgId: f, productId: p, variant: m, plansDocsUrl: h, apiGatewayUrl: g, authToken: _, stripePublishableKey: v, razorpayKey: y, onSubscriptionCreate: b, onSubscriptionUpdate: x, onPaymentProcess: S, registerNavItems: C, registerFooterItems: w }) => {
12
12
  r(() => {
13
13
  e((e) => {
14
14
  typeof window < "u" && window.dispatchEvent(new CustomEvent(s, { detail: e }));
15
15
  });
16
16
  }, []);
17
- let w = {
17
+ let T = {
18
18
  basePath: n,
19
19
  navigate: l,
20
20
  currentUser: u,
21
21
  workspaceId: d,
22
22
  orgId: f,
23
23
  productId: p,
24
- plansDocsUrl: m,
25
- apiGatewayUrl: h,
26
- authToken: g,
27
- stripePublishableKey: _,
28
- razorpayKey: v,
29
- onSubscriptionCreate: y,
30
- onSubscriptionUpdate: b,
31
- onPaymentProcess: x,
32
- registerNavItems: S,
33
- registerFooterItems: C
34
- }, T = /* @__PURE__ */ o(c.Provider, {
35
- value: w,
24
+ variant: m,
25
+ plansDocsUrl: h,
26
+ apiGatewayUrl: g,
27
+ authToken: _,
28
+ stripePublishableKey: v,
29
+ razorpayKey: y,
30
+ onSubscriptionCreate: b,
31
+ onSubscriptionUpdate: x,
32
+ onPaymentProcess: S,
33
+ registerNavItems: C,
34
+ registerFooterItems: w
35
+ }, E = /* @__PURE__ */ o(c.Provider, {
36
+ value: T,
36
37
  children: /* @__PURE__ */ o(a, {
37
38
  scopeId: f,
38
39
  gateway: "global",
39
40
  children: t
40
41
  })
41
42
  });
42
- return n ? T : /* @__PURE__ */ o(i, { children: T });
43
+ return n ? E : /* @__PURE__ */ o(i, { children: E });
43
44
  };
44
45
  export { u as BillingProvider, s as NATIVE_IAP_TRANSACTION_EVENT, l as useBilling };
45
46
 
@@ -1 +1 @@
1
- {"version":3,"file":"BillingProvider.js","names":["NATIVE_IAP_TRANSACTION_EVENT","BillingContext","createContext","useBilling","context","useContext","BillingProvider","transaction","contextValue","content","PermissionProvider","orgId","basePath","MemoryRouter"],"sources":["../../../src/billing/providers/BillingProvider.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from 'react';\nimport { createContext, useContext, useEffect } from 'react';\nimport { MemoryRouter } from 'react-router';\nimport { PermissionProvider } from '@burdenoff/fe-libs/shared/providers/shell';\nimport type { BillingRootProps } from '../types';\nimport { installNativeIAP, type NativeTransaction } from '../lib/native-purchases';\n\n/** Dispatched when the background StoreKit 2/Play Billing listener observes a\n * transaction (renewal, restore, or an interrupted purchase resumed on launch).\n * Background transactions are reconciled authoritatively server-side via the\n * Apple/Google webhooks; this just lets mounted UI react (e.g. refresh entitlements). */\nexport const NATIVE_IAP_TRANSACTION_EVENT = 'burdenoff:nativeIapTransaction';\n\n/**\n * Context value for Billing microfrontend\n */\ntype BillingContextValue = BillingRootProps;\n\nconst BillingContext = createContext<BillingContextValue | null>(null);\n\n/**\n * Hook to access Billing context\n */\nexport const useBilling = () => {\n const context = useContext(BillingContext);\n if (!context) {\n throw new Error('useBilling must be used within BillingProvider');\n }\n return context;\n};\n\n/**\n * Provider component for Billing microfrontend\n * Sets up routing and context\n *\n * When integrated into a shell (basePath provided), the shell already has a router\n * so we don't create another one. When standalone (no basePath), use MemoryRouter.\n */\nexport const BillingProvider: FC<PropsWithChildren<BillingRootProps>> = ({\n children,\n basePath,\n navigate,\n currentUser,\n workspaceId,\n orgId,\n productId,\n plansDocsUrl,\n apiGatewayUrl,\n authToken,\n stripePublishableKey,\n razorpayKey,\n onSubscriptionCreate,\n onSubscriptionUpdate,\n onPaymentProcess,\n registerNavItems,\n registerFooterItems,\n}) => {\n // Register the native IAP background listener once billing context (and\n // therefore the signed-in user) is known. No-op on web. See `NATIVE_IAP_TRANSACTION_EVENT`.\n useEffect(() => {\n void installNativeIAP((transaction: NativeTransaction) => {\n if (typeof window === 'undefined') return;\n window.dispatchEvent(\n new CustomEvent<NativeTransaction>(NATIVE_IAP_TRANSACTION_EVENT, { detail: transaction })\n );\n });\n }, []);\n\n const contextValue: BillingContextValue = {\n basePath,\n navigate,\n currentUser,\n workspaceId,\n orgId,\n productId,\n plansDocsUrl,\n apiGatewayUrl,\n authToken,\n stripePublishableKey,\n razorpayKey,\n onSubscriptionCreate,\n onSubscriptionUpdate,\n onPaymentProcess,\n registerNavItems,\n registerFooterItems,\n };\n\n const content = (\n <BillingContext.Provider value={contextValue}>\n <PermissionProvider scopeId={orgId} gateway=\"global\">\n {children}\n </PermissionProvider>\n </BillingContext.Provider>\n );\n\n // When integrated into a shell (basePath provided), the shell already has a router\n // so we don't create another one. When standalone (no basePath), use MemoryRouter.\n if (basePath) {\n return content;\n }\n\n // Standalone mode: create MemoryRouter for independent operation\n return <MemoryRouter>{content}</MemoryRouter>;\n};\n"],"mappings":";;;;;;AAWA,IAAaA,IAA+B,kCAOtCC,IAAiBC,EAA0C,IAAI,GAKxDC,UAAmB;CAC9B,IAAMC,IAAUC,EAAWJ,CAAc;CACzC,IAAI,CAACG,GACH,MAAU,MAAM,gDAAgD;CAElE,OAAOA;AACT,GASaE,KAA4D,EACvE,aACA,aACA,aACA,gBACA,gBACA,UACA,cACA,iBACA,kBACA,cACA,yBACA,gBACA,yBACA,yBACA,qBACA,qBACA,6BACI;CAGJ,QAAgB;EACd,GAAuB,MAAmC;GACxD,AAAI,OAAO,SAAW,OACtB,OAAO,cACL,IAAI,YAA+BN,GAA8B,EAAE,QAAQO,EAAY,CAAC,CAC1F;EACF,CAAC;CACH,GAAG,CAAC,CAAC;CAEL,IAAMC,IAAoC;EACxC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,GAEMC,IACJ,kBAACR,EAAe,UAAhB;EAAyB,OAAOO;EAC9B,UAAA,kBAACE,GAAD;GAAoB,SAASC;GAAO,SAAQ;GACzC;EACiB,CAAA;CACG,CAAA;CAU3B,OALIC,IACKH,IAIF,kBAACI,GAAD,EAAA,UAAeJ,EAAsB,CAAA;AAC9C"}
1
+ {"version":3,"file":"BillingProvider.js","names":["NATIVE_IAP_TRANSACTION_EVENT","BillingContext","createContext","useBilling","context","useContext","BillingProvider","transaction","contextValue","content","PermissionProvider","orgId","basePath","MemoryRouter"],"sources":["../../../src/billing/providers/BillingProvider.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from 'react';\nimport { createContext, useContext, useEffect } from 'react';\nimport { MemoryRouter } from 'react-router';\nimport { PermissionProvider } from '@burdenoff/fe-libs/shared/providers/shell';\nimport type { BillingRootProps } from '../types';\nimport { installNativeIAP, type NativeTransaction } from '../lib/native-purchases';\n\n/** Dispatched when the background StoreKit 2/Play Billing listener observes a\n * transaction (renewal, restore, or an interrupted purchase resumed on launch).\n * Background transactions are reconciled authoritatively server-side via the\n * Apple/Google webhooks; this just lets mounted UI react (e.g. refresh entitlements). */\nexport const NATIVE_IAP_TRANSACTION_EVENT = 'burdenoff:nativeIapTransaction';\n\n/**\n * Context value for Billing microfrontend\n */\ntype BillingContextValue = BillingRootProps;\n\nconst BillingContext = createContext<BillingContextValue | null>(null);\n\n/**\n * Hook to access Billing context\n */\nexport const useBilling = () => {\n const context = useContext(BillingContext);\n if (!context) {\n throw new Error('useBilling must be used within BillingProvider');\n }\n return context;\n};\n\n/**\n * Provider component for Billing microfrontend\n * Sets up routing and context\n *\n * When integrated into a shell (basePath provided), the shell already has a router\n * so we don't create another one. When standalone (no basePath), use MemoryRouter.\n */\nexport const BillingProvider: FC<PropsWithChildren<BillingRootProps>> = ({\n children,\n basePath,\n navigate,\n currentUser,\n workspaceId,\n orgId,\n productId,\n variant,\n plansDocsUrl,\n apiGatewayUrl,\n authToken,\n stripePublishableKey,\n razorpayKey,\n onSubscriptionCreate,\n onSubscriptionUpdate,\n onPaymentProcess,\n registerNavItems,\n registerFooterItems,\n}) => {\n // Register the native IAP background listener once billing context (and\n // therefore the signed-in user) is known. No-op on web. See `NATIVE_IAP_TRANSACTION_EVENT`.\n useEffect(() => {\n void installNativeIAP((transaction: NativeTransaction) => {\n if (typeof window === 'undefined') return;\n window.dispatchEvent(\n new CustomEvent<NativeTransaction>(NATIVE_IAP_TRANSACTION_EVENT, { detail: transaction })\n );\n });\n }, []);\n\n const contextValue: BillingContextValue = {\n basePath,\n navigate,\n currentUser,\n workspaceId,\n orgId,\n productId,\n variant,\n plansDocsUrl,\n apiGatewayUrl,\n authToken,\n stripePublishableKey,\n razorpayKey,\n onSubscriptionCreate,\n onSubscriptionUpdate,\n onPaymentProcess,\n registerNavItems,\n registerFooterItems,\n };\n\n const content = (\n <BillingContext.Provider value={contextValue}>\n <PermissionProvider scopeId={orgId} gateway=\"global\">\n {children}\n </PermissionProvider>\n </BillingContext.Provider>\n );\n\n // When integrated into a shell (basePath provided), the shell already has a router\n // so we don't create another one. When standalone (no basePath), use MemoryRouter.\n if (basePath) {\n return content;\n }\n\n // Standalone mode: create MemoryRouter for independent operation\n return <MemoryRouter>{content}</MemoryRouter>;\n};\n"],"mappings":";;;;;;AAWA,IAAaA,IAA+B,kCAOtCC,IAAiBC,EAA0C,IAAI,GAKxDC,UAAmB;CAC9B,IAAMC,IAAUC,EAAWJ,CAAc;CACzC,IAAI,CAACG,GACH,MAAU,MAAM,gDAAgD;CAElE,OAAOA;AACT,GASaE,KAA4D,EACvE,aACA,aACA,aACA,gBACA,gBACA,UACA,cACA,YACA,iBACA,kBACA,cACA,yBACA,gBACA,yBACA,yBACA,qBACA,qBACA,6BACI;CAGJ,QAAgB;EACd,GAAuB,MAAmC;GACxD,AAAI,OAAO,SAAW,OACtB,OAAO,cACL,IAAI,YAA+BN,GAA8B,EAAE,QAAQO,EAAY,CAAC,CAC1F;EACF,CAAC;CACH,GAAG,CAAC,CAAC;CAEL,IAAMC,IAAoC;EACxC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,GAEMC,IACJ,kBAACR,EAAe,UAAhB;EAAyB,OAAOO;EAC9B,UAAA,kBAACE,GAAD;GAAoB,SAASC;GAAO,SAAQ;GACzC;EACiB,CAAA;CACG,CAAA;CAU3B,OALIC,IACKH,IAIF,kBAACI,GAAD,EAAA,UAAeJ,EAAsB,CAAA;AAC9C"}
@@ -0,0 +1,27 @@
1
+ import { FC, ReactNode } from 'react';
2
+ export interface MoneyActionDetail {
3
+ label: string;
4
+ value: ReactNode;
5
+ }
6
+ export interface MoneyActionDialogProps {
7
+ open: boolean;
8
+ title: string;
9
+ description?: string;
10
+ /** The exact facts the action acts on (invoice, amount, card…). */
11
+ details: MoneyActionDetail[];
12
+ confirmLabel: string;
13
+ /** Present-tense label shown on the confirm button while the action runs. */
14
+ busyLabel: string;
15
+ isBusy: boolean;
16
+ /** Visible, never swallowed: a failed action keeps the dialog open with this text. */
17
+ error?: string | null;
18
+ tone?: 'primary' | 'danger';
19
+ onConfirm: () => void;
20
+ onCancel: () => void;
21
+ }
22
+ /**
23
+ * Review step shown before money moves (pay) or an invoice is voided. It names
24
+ * the invoice, amount and account so the user confirms the exact effect, and it
25
+ * stays open with the error visible if the action fails.
26
+ */
27
+ export declare const MoneyActionDialog: FC<MoneyActionDialogProps>;
@@ -0,0 +1,53 @@
1
+ import { useTr as e } from "../hooks/useTr.js";
2
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
+ import { ResponsiveDialog as r, ResponsiveDialogContent as i, ResponsiveDialogDescription as a, ResponsiveDialogFooter as o, ResponsiveDialogHeader as s, ResponsiveDialogTitle as c } from "@burdenoff/fe-libs/ui";
4
+ // src/billing/shared/components/MoneyActionDialog.tsx
5
+ var l = ({ open: l, title: u, description: d, details: f, confirmLabel: p, busyLabel: m, isBusy: h, error: g, tone: _ = "primary", onConfirm: v, onCancel: y }) => {
6
+ let b = e(), x = _ === "danger" ? "bg-action-danger-bg text-action-primary-text hover:bg-action-danger-bgHover" : "bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bgHover";
7
+ return /* @__PURE__ */ t(r, {
8
+ open: l,
9
+ onOpenChange: (e) => {
10
+ !e && !h && y();
11
+ },
12
+ children: /* @__PURE__ */ n(i, {
13
+ className: "sm:max-w-md",
14
+ children: [
15
+ /* @__PURE__ */ n(s, { children: [/* @__PURE__ */ t(c, { children: u }), d ? /* @__PURE__ */ t(a, { children: d }) : null] }),
16
+ /* @__PURE__ */ t("dl", {
17
+ className: "divide-y divide-border-subtle rounded-card border border-border-subtle",
18
+ children: f.map((e) => /* @__PURE__ */ n("div", {
19
+ className: "flex items-baseline justify-between gap-4 p-3",
20
+ children: [/* @__PURE__ */ t("dt", {
21
+ className: "text-sm text-text-secondary",
22
+ children: e.label
23
+ }), /* @__PURE__ */ t("dd", {
24
+ className: "text-right text-sm font-medium text-text-primary",
25
+ children: e.value
26
+ })]
27
+ }, e.label))
28
+ }),
29
+ g ? /* @__PURE__ */ t("p", {
30
+ role: "alert",
31
+ className: "text-sm text-status-error-text",
32
+ children: g
33
+ }) : null,
34
+ /* @__PURE__ */ n(o, { children: [/* @__PURE__ */ t("button", {
35
+ type: "button",
36
+ onClick: y,
37
+ disabled: h,
38
+ className: "rounded-button border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50",
39
+ children: b("billing.common.cancel", "Cancel")
40
+ }), /* @__PURE__ */ t("button", {
41
+ type: "button",
42
+ onClick: v,
43
+ disabled: h,
44
+ className: `rounded-button px-4 py-2 text-sm font-medium transition-colors disabled:opacity-50 ${x}`,
45
+ children: h ? m : p
46
+ })] })
47
+ ]
48
+ })
49
+ });
50
+ };
51
+ export { l as MoneyActionDialog };
52
+
53
+ //# sourceMappingURL=MoneyActionDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MoneyActionDialog.js","names":["MoneyActionDialog","tr","useTr","confirmClass","tone","ResponsiveDialog","next","isBusy","onCancel","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","title","description","ResponsiveDialogDescription","details","detail","error","ResponsiveDialogFooter","onConfirm","busyLabel","confirmLabel"],"sources":["../../../../src/billing/shared/components/MoneyActionDialog.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport {\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n} from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../hooks/useTr';\n\nexport interface MoneyActionDetail {\n label: string;\n value: ReactNode;\n}\n\nexport interface MoneyActionDialogProps {\n open: boolean;\n title: string;\n description?: string;\n /** The exact facts the action acts on (invoice, amount, card…). */\n details: MoneyActionDetail[];\n confirmLabel: string;\n /** Present-tense label shown on the confirm button while the action runs. */\n busyLabel: string;\n isBusy: boolean;\n /** Visible, never swallowed: a failed action keeps the dialog open with this text. */\n error?: string | null;\n tone?: 'primary' | 'danger';\n onConfirm: () => void;\n onCancel: () => void;\n}\n\n/**\n * Review step shown before money moves (pay) or an invoice is voided. It names\n * the invoice, amount and account so the user confirms the exact effect, and it\n * stays open with the error visible if the action fails.\n */\nexport const MoneyActionDialog: FC<MoneyActionDialogProps> = ({\n open,\n title,\n description,\n details,\n confirmLabel,\n busyLabel,\n isBusy,\n error,\n tone = 'primary',\n onConfirm,\n onCancel,\n}) => {\n const tr = useTr();\n const confirmClass =\n tone === 'danger'\n ? 'bg-action-danger-bg text-action-primary-text hover:bg-action-danger-bgHover'\n : 'bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bgHover';\n\n return (\n <ResponsiveDialog\n open={open}\n onOpenChange={(next) => {\n if (!next && !isBusy) onCancel();\n }}\n >\n <ResponsiveDialogContent className=\"sm:max-w-md\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>{title}</ResponsiveDialogTitle>\n {description ? (\n <ResponsiveDialogDescription>{description}</ResponsiveDialogDescription>\n ) : null}\n </ResponsiveDialogHeader>\n\n <dl className=\"divide-y divide-border-subtle rounded-card border border-border-subtle\">\n {details.map((detail) => (\n <div key={detail.label} className=\"flex items-baseline justify-between gap-4 p-3\">\n <dt className=\"text-sm text-text-secondary\">{detail.label}</dt>\n <dd className=\"text-right text-sm font-medium text-text-primary\">{detail.value}</dd>\n </div>\n ))}\n </dl>\n\n {error ? (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {error}\n </p>\n ) : null}\n\n <ResponsiveDialogFooter>\n <button\n type=\"button\"\n onClick={onCancel}\n disabled={isBusy}\n className=\"rounded-button border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n {tr('billing.common.cancel', 'Cancel')}\n </button>\n <button\n type=\"button\"\n onClick={onConfirm}\n disabled={isBusy}\n className={`rounded-button px-4 py-2 text-sm font-medium transition-colors disabled:opacity-50 ${confirmClass}`}\n >\n {isBusy ? busyLabel : confirmLabel}\n </button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n};\n"],"mappings":";;;;AAsCA,IAAaA,KAAiD,EAC5D,SACA,UACA,gBACA,YACA,iBACA,cACA,WACA,UACA,UAAO,WACP,cACA,kBACI;CACJ,IAAMC,IAAKC,EAAM,GACXC,IACJC,MAAS,WACL,gFACA;CAEN,OACE,kBAACC,GAAD;EACQ;EACN,eAAe,MAAS;GACtB,AAAI,CAACC,KAAQ,CAACC,KAAQC,EAAS;EACjC;EAEA,UAAA,kBAACC,GAAD;GAAyB,WAAU;GAAnC,UAAA;IACE,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAwBC,EAA6B,CAAA,GACpDC,IACC,kBAACC,GAAD,EAAA,UAA8BD,EAAyC,CAAA,IACrE,IACkB,EAAA,CAAA;IAExB,kBAAC,MAAD;KAAI,WAAU;KACX,UAAAE,EAAQ,KAAK,MACZ,kBAAC,OAAD;MAAwB,WAAU;MAAlC,UAAA,CACE,kBAAC,MAAD;OAAI,WAAU;OAA+B,UAAAC,EAAO;MAAU,CAAA,GAC9D,kBAAC,MAAD;OAAI,WAAU;OAAoD,UAAAA,EAAO;MAAU,CAAA,CAChF;KAHK,GAAAA,EAAO,KAGZ,CACN;IACC,CAAA;IAEHC,IACC,kBAAC,KAAD;KAAG,MAAK;KAAQ,WAAU;KACvB,UAAAA;IACA,CAAA,IACD;IAEJ,kBAACC,GAAD,EAAA,UAAA,CACE,kBAAC,UAAD;KACE,MAAK;KACL,SAASV;KACT,UAAUD;KACV,WAAU;KAET,UAAAN,EAAG,yBAAyB,QAAQ;IAC/B,CAAA,GACR,kBAAC,UAAD;KACE,MAAK;KACL,SAASkB;KACT,UAAUZ;KACV,WAAW,sFAAsFJ;KAEhG,UAAAI,IAASa,IAAYC;IAChB,CAAA,CACc,EAAA,CAAA;GACD;;CACT,CAAA;AAEtB"}
@@ -10,3 +10,4 @@ export { GeoPricingOverridesEditor } from './GeoPricingOverridesEditor';
10
10
  export { CurrencyPriceOverridesEditor } from './CurrencyPriceOverridesEditor';
11
11
  export { ActorIdentity } from './ActorIdentity';
12
12
  export { PushPermissionNudge } from './PushPermissionNudge';
13
+ export { MoneyActionDialog, type MoneyActionDetail } from './MoneyActionDialog';
@@ -7,4 +7,5 @@ import "./GeoPricingOverridesEditor.js";
7
7
  import { CurrencyPriceOverridesEditor as a } from "./CurrencyPriceOverridesEditor.js";
8
8
  import { ActorIdentity as o } from "./ActorIdentity.js";
9
9
  import "./PushPermissionNudge.js";
10
- export { e as AccessDenied, o as ActorIdentity, a as CurrencyPriceOverridesEditor, r as EmptyState, t as PageHeader, i as ServerError, n as StatCard };
10
+ import { MoneyActionDialog as s } from "./MoneyActionDialog.js";
11
+ export { e as AccessDenied, o as ActorIdentity, a as CurrencyPriceOverridesEditor, r as EmptyState, s as MoneyActionDialog, t as PageHeader, i as ServerError, n as StatCard };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Pure access rules shared by billing route gates and pages, kept free of React
3
+ * so the route-versus-page agreement can be unit tested (BOFF-11860).
4
+ */
5
+ /**
6
+ * Route-level permission check. A `null` requirement means the wrapped page
7
+ * resolves its own account-scoped permission (Team & Permissions), so the route
8
+ * must not refuse before the page knows which billing account it is on.
9
+ */
10
+ export declare function isRouteAllowed<K extends string>(required: K | null, granted: Readonly<Record<K, boolean>>): boolean;
11
+ /**
12
+ * Whether the user sees the "Request refund" action. `createRefundRecord` is a
13
+ * `manage`-gated mutation, so in the FluidGrids variant the button only shows to
14
+ * people whose request can succeed. Other apps keep the button as before.
15
+ */
16
+ export declare function canShowRefundRequest(isFluidgrids: boolean, canProcessRefund: boolean): boolean;
@@ -0,0 +1,10 @@
1
+ // src/billing/shared/utils/accessRules.ts
2
+ function e(e, t) {
3
+ return e === null || !!t[e];
4
+ }
5
+ function t(e, t) {
6
+ return !e || t;
7
+ }
8
+ export { t as canShowRefundRequest, e as isRouteAllowed };
9
+
10
+ //# sourceMappingURL=accessRules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessRules.js","names":["isRouteAllowed","required","granted","canShowRefundRequest","isFluidgrids","canProcessRefund"],"sources":["../../../../src/billing/shared/utils/accessRules.ts"],"sourcesContent":["/**\n * Pure access rules shared by billing route gates and pages, kept free of React\n * so the route-versus-page agreement can be unit tested (BOFF-11860).\n */\n\n/**\n * Route-level permission check. A `null` requirement means the wrapped page\n * resolves its own account-scoped permission (Team & Permissions), so the route\n * must not refuse before the page knows which billing account it is on.\n */\nexport function isRouteAllowed<K extends string>(\n required: K | null,\n granted: Readonly<Record<K, boolean>>\n): boolean {\n return required === null ? true : Boolean(granted[required]);\n}\n\n/**\n * Whether the user sees the \"Request refund\" action. `createRefundRecord` is a\n * `manage`-gated mutation, so in the FluidGrids variant the button only shows to\n * people whose request can succeed. Other apps keep the button as before.\n */\nexport function canShowRefundRequest(isFluidgrids: boolean, canProcessRefund: boolean): boolean {\n return !isFluidgrids || canProcessRefund;\n}\n"],"mappings":";AAUA,SAAgBA,EACd,GACA,GACS;CACT,OAAOC,MAAa,QAAc,EAAQC,EAAQD;AACpD;AAOA,SAAgBE,EAAqB,GAAuB,GAAoC;CAC9F,OAAO,CAACC,KAAgBC;AAC1B"}
@@ -20,6 +20,12 @@ export interface BillingRootProps extends MicrofrontendRootProps {
20
20
  * In admin mode, this is ignored and all products' items are shown.
21
21
  */
22
22
  productId?: string;
23
+ /**
24
+ * Opt-in design variant. Only `fluidgrids-app` passes `"fluidgrids"`, which
25
+ * switches on the Navigation v2 billing changes (BOFF-11860). When unset the
26
+ * module looks and behaves exactly as it always has in every other app.
27
+ */
28
+ variant?: 'fluidgrids';
23
29
  /**
24
30
  * The host product's user-guide page about plans and quotas (e.g. the
25
31
  * environment-correct docs.vibecontrols.com/users/plans-and-quotas). When
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-billing",
3
- "version": "2026.1109.1",
3
+ "version": "2026.1112.1",
4
4
  "description": "Billing microfrontend for Burdenoff products",
5
5
  "type": "module",
6
6
  "files": [