@burdenoff/microfe-billing 2026.1109.1 → 2026.1112.2
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.
- package/dist/billing/BillingUserRoutes.js +202 -188
- package/dist/billing/BillingUserRoutes.js.map +1 -1
- package/dist/billing/hooks/useBillingVariant.d.ts +6 -0
- package/dist/billing/hooks/useBillingVariant.js +8 -0
- package/dist/billing/hooks/useBillingVariant.js.map +1 -0
- package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js +182 -150
- package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/InvoiceDetailPage.js +169 -140
- package/dist/billing/modules/billing/pages/InvoiceDetailPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/InvoicesListPage.js +191 -156
- package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/UserRefundsPage.js +160 -157
- package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js +153 -126
- package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditsPage.js +110 -109
- package/dist/billing/modules/credits/pages/CreditsPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/PayoutsPage.js +220 -181
- package/dist/billing/modules/earnings/pages/PayoutsPage.js.map +1 -1
- package/dist/billing/modules/settings/pages/TeamPermissionsPage.js +4 -1
- package/dist/billing/modules/settings/pages/TeamPermissionsPage.js.map +1 -1
- package/dist/billing/providers/BillingProvider.js +16 -15
- package/dist/billing/providers/BillingProvider.js.map +1 -1
- package/dist/billing/shared/components/MoneyActionDialog.d.ts +27 -0
- package/dist/billing/shared/components/MoneyActionDialog.js +53 -0
- package/dist/billing/shared/components/MoneyActionDialog.js.map +1 -0
- package/dist/billing/shared/components/index.d.ts +1 -0
- package/dist/billing/shared/components/index.js +2 -1
- package/dist/billing/shared/utils/accessRules.d.ts +16 -0
- package/dist/billing/shared/utils/accessRules.js +10 -0
- package/dist/billing/shared/utils/accessRules.js.map +1 -0
- package/dist/billing/types/index.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayoutsPage.js","names":["_Fragment","Fragment$1","payoutRequestColumns","formatCurrency","request","formatDateTime","PayoutsPage","permissions","useBillingPermissions","useBillingEventEmitter","useBilling","billingAccountData","useGetDefaultBillingAccountSettingsQuery","billingAccountId","accounts","setAccounts","useState","requests","setRequests","loading","setLoading","error","setError","accountForm","setAccountForm","requestAmount","setRequestAmount","selectedAccountId","setSelectedAccountId","editingAccountId","setEditingAccountId","archiveAccountId","setArchiveAccountId","notice","setNotice","requestContext","useMemo","apiGatewayUrl","authToken","orgId","loadData","useCallback","loadedAccounts","loadedRequests","fetchPayoutAccounts","fetchPayoutRequests","pickPayableAccountId","current","loadError","useEffect","AccessDenied","isServerError","ServerError","handleAddAccount","payload","updatePayoutAccount","emit","created","addPayoutAccount","handleSetDefault","setDefaultPayoutAccount","accountId","handleArchive","archivePayoutAccount","handleEditAccount","account","selectedAccount","hasPayableAccount","isPayoutAccountPayable","handleRequestPayout","requestPayout","PageHeader","PagePurpose","event","Landmark","RefreshCw","IllustratedEmptyState","payoutAccountStatusView","Send","statusView","PAYOUT_ACCOUNT_TONE_CLASSES","ResponsiveTable","AlertDialog","open","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","id"],"sources":["../../../../../src/billing/modules/earnings/pages/PayoutsPage.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState, type FC } from 'react';\nimport { Landmark, RefreshCw, Send } from 'lucide-react';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n ResponsiveTable,\n type ResponsiveTableColumn,\n} from '@burdenoff/fe-libs/ui';\n\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { AccessDenied, PageHeader, ServerError } from '../../../shared/components';\nimport { PagePurpose, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\nimport { formatCurrency, formatDateTime, isServerError } from '../../../shared/utils';\nimport { useGetDefaultBillingAccountSettingsQuery } from '../../../../generated/global-operations';\nimport {\n addPayoutAccount,\n archivePayoutAccount,\n fetchPayoutAccounts,\n fetchPayoutRequests,\n requestPayout,\n setDefaultPayoutAccount,\n updatePayoutAccount,\n type PayoutAccount,\n type PayoutRequest,\n} from '../api';\nimport {\n PAYOUT_ACCOUNT_TONE_CLASSES,\n isPayoutAccountPayable,\n payoutAccountStatusView,\n pickPayableAccountId,\n} from '../payoutAccountStatus';\n\nconst payoutRequestColumns: ResponsiveTableColumn<PayoutRequest>[] = [\n {\n key: 'amount',\n header: 'Amount',\n priority: 'primary',\n cell: (request) => (\n <span className=\"tabular-nums\">\n {formatCurrency(request.requestedAmount, request.currency)}\n </span>\n ),\n },\n { key: 'provider', header: 'Provider', cell: (request) => request.provider },\n { key: 'status', header: 'Status', cell: (request) => request.status },\n {\n key: 'account',\n header: 'Account',\n cell: (request) => request.payoutAccount?.label || '-',\n },\n {\n key: 'created',\n header: 'Created',\n cell: (request) => formatDateTime(request.createdAt),\n },\n];\n\nexport const PayoutsPage: FC = () => {\n const permissions = useBillingPermissions();\n const { emit } = useBillingEventEmitter();\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n const { data: billingAccountData } = useGetDefaultBillingAccountSettingsQuery({});\n const billingAccountId = billingAccountData?.getDefaultBillingAccount?.id;\n\n const [accounts, setAccounts] = useState<PayoutAccount[]>([]);\n const [requests, setRequests] = useState<PayoutRequest[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [accountForm, setAccountForm] = useState({\n label: '',\n type: 'BANK_ACCOUNT',\n providerPreference: 'AUTO',\n country: 'US',\n currency: 'USD',\n accountHolderName: '',\n bankName: '',\n accountNumber: '',\n routingNumber: '',\n ifsc: '',\n upiId: '',\n });\n const [requestAmount, setRequestAmount] = useState('');\n const [selectedAccountId, setSelectedAccountId] = useState<string>('');\n const [editingAccountId, setEditingAccountId] = useState<string | null>(null);\n const [archiveAccountId, setArchiveAccountId] = useState<string | null>(null);\n const [notice, setNotice] = useState<string | null>(null);\n\n const requestContext = useMemo(\n () => ({\n apiGatewayUrl,\n authToken,\n orgId,\n }),\n [apiGatewayUrl, authToken, orgId]\n );\n\n const loadData = useCallback(async () => {\n if (!billingAccountId) return;\n setLoading(true);\n setError(null);\n try {\n const [loadedAccounts, loadedRequests] = await Promise.all([\n fetchPayoutAccounts(billingAccountId, requestContext),\n fetchPayoutRequests(billingAccountId, requestContext),\n ]);\n setAccounts(loadedAccounts);\n setRequests(loadedRequests);\n // Only verified accounts can be paid out to (BOFF-10953).\n setSelectedAccountId((current) => pickPayableAccountId(loadedAccounts, current));\n } catch (loadError) {\n setError(loadError instanceof Error ? loadError : new Error('Failed to load payout data'));\n } finally {\n setLoading(false);\n }\n }, [billingAccountId, requestContext]);\n\n useEffect(() => {\n void loadData();\n }, [loadData]);\n\n if (!permissions.canManagePaymentMethods) {\n return <AccessDenied message=\"You don't have permission to manage payout accounts.\" />;\n }\n\n if (error && isServerError(error)) {\n return (\n <ServerError\n title=\"Payout data unavailable\"\n message={error.message}\n onRetry={() => void loadData()}\n showRetry\n />\n );\n }\n\n const handleAddAccount = async () => {\n if (!billingAccountId) return;\n setNotice(null);\n const payload = {\n billingAccountId,\n ...accountForm,\n };\n\n if (editingAccountId) {\n await updatePayoutAccount(editingAccountId, payload, requestContext);\n emit('billing.payout_account.updated', {\n route: '/billing/payouts',\n entityId: editingAccountId,\n source: 'payouts',\n });\n } else {\n const created = await addPayoutAccount(payload, requestContext);\n emit('billing.payout_account.added', {\n route: '/billing/payouts',\n entityId: billingAccountId,\n source: 'payouts',\n });\n // RazorpayX and Stripe Connect accounts stay pending until processor\n // onboarding verifies them (BOFF-10895); say so instead of implying the\n // account is ready to receive payouts.\n setNotice(\n created.status === 'ACTIVE'\n ? 'Payout account saved and ready to receive payouts.'\n : 'Payout account saved. It stays pending until the payout processor verifies it; you can request payouts to it once it is verified.'\n );\n }\n\n setAccountForm({\n label: '',\n type: 'BANK_ACCOUNT',\n providerPreference: 'AUTO',\n country: 'US',\n currency: 'USD',\n accountHolderName: '',\n bankName: '',\n accountNumber: '',\n routingNumber: '',\n ifsc: '',\n upiId: '',\n });\n setEditingAccountId(null);\n await loadData();\n };\n\n const handleSetDefault = async (accountId: string) => {\n setNotice(null);\n await setDefaultPayoutAccount(accountId, requestContext);\n await loadData();\n };\n\n const handleArchive = async (accountId: string) => {\n setNotice(null);\n await archivePayoutAccount(accountId, requestContext);\n emit('billing.payout_account.archived', {\n route: '/billing/payouts',\n entityId: accountId,\n source: 'payouts',\n });\n await loadData();\n };\n\n const handleEditAccount = (account: PayoutAccount) => {\n setNotice(null);\n setEditingAccountId(account.id);\n setAccountForm((current) => ({\n ...current,\n label: account.label,\n type: account.type,\n providerPreference: account.providerPreference,\n country: account.country || current.country,\n currency: account.currency,\n accountHolderName: account.displayName || current.accountHolderName,\n bankName: '',\n accountNumber: '',\n routingNumber: '',\n ifsc: '',\n upiId: '',\n }));\n };\n\n const selectedAccount = accounts.find((account) => account.id === selectedAccountId);\n const hasPayableAccount = accounts.some(isPayoutAccountPayable);\n\n const handleRequestPayout = async () => {\n if (!billingAccountId || !selectedAccountId || !requestAmount) return;\n if (!selectedAccount || !isPayoutAccountPayable(selectedAccount)) return;\n await requestPayout(\n {\n billingAccountId,\n payoutAccountId: selectedAccountId,\n amount: Number(requestAmount),\n currency: selectedAccount.currency,\n },\n requestContext\n );\n emit('billing.payout.requested', {\n route: '/billing/payouts',\n entityId: selectedAccountId,\n source: 'payouts',\n amount: Number(requestAmount),\n currency: selectedAccount.currency,\n });\n setRequestAmount('');\n await loadData();\n };\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title=\"Payouts\"\n description=\"Register payout accounts, request withdrawals, and track disbursement status.\"\n />\n\n <PagePurpose>\n Get your earnings paid out to a real bank account or UPI. Register where you want to be\n paid, request a withdrawal of your available balance, and track each request from submission\n through to disbursement here.\n </PagePurpose>\n\n {notice ? (\n <div\n role=\"status\"\n className=\"rounded-lg border border-border-subtle bg-status-info-bg-subtle p-4 text-sm text-status-info-text\"\n >\n {notice}\n </div>\n ) : null}\n\n {error && !isServerError(error) ? (\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm text-status-error-text\">\n {error.message}\n </div>\n ) : null}\n\n <div className=\"grid gap-6 xl:grid-cols-[1.05fr,1.95fr]\">\n <section className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">\n {editingAccountId ? 'Edit payout account' : 'Add payout account'}\n </h2>\n <div className=\"space-y-3\">\n <input\n value={accountForm.label}\n onChange={(event) =>\n setAccountForm((current) => ({ ...current, label: event.target.value }))\n }\n placeholder=\"Label\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <div className=\"grid gap-3 md:grid-cols-2\">\n <select\n value={accountForm.type}\n onChange={(event) =>\n setAccountForm((current) => ({ ...current, type: event.target.value }))\n }\n className=\"rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"BANK_ACCOUNT\">Bank account</option>\n <option value=\"UPI\">UPI</option>\n <option value=\"WALLET\">Wallet</option>\n </select>\n <select\n value={accountForm.providerPreference}\n onChange={(event) =>\n setAccountForm((current) => ({\n ...current,\n providerPreference: event.target.value,\n }))\n }\n className=\"rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"AUTO\">Auto</option>\n <option value=\"STRIPE\">Stripe</option>\n <option value=\"RAZORPAY\">Razorpay</option>\n <option value=\"MANUAL\">Manual</option>\n </select>\n </div>\n <div className=\"grid gap-3 md:grid-cols-2\">\n <input\n value={accountForm.country}\n onChange={(event) =>\n setAccountForm((current) => ({\n ...current,\n country: event.target.value.toUpperCase(),\n }))\n }\n placeholder=\"Country\"\n className=\"rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={accountForm.currency}\n onChange={(event) =>\n setAccountForm((current) => ({\n ...current,\n currency: event.target.value.toUpperCase(),\n }))\n }\n placeholder=\"Currency\"\n className=\"rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n </div>\n <input\n value={accountForm.accountHolderName}\n onChange={(event) =>\n setAccountForm((current) => ({ ...current, accountHolderName: event.target.value }))\n }\n placeholder=\"Account holder name\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n {accountForm.type === 'BANK_ACCOUNT' ? (\n <>\n <input\n value={accountForm.bankName}\n onChange={(event) =>\n setAccountForm((current) => ({ ...current, bankName: event.target.value }))\n }\n placeholder=\"Bank name\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={accountForm.accountNumber}\n onChange={(event) =>\n setAccountForm((current) => ({ ...current, accountNumber: event.target.value }))\n }\n placeholder=\"Account number\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={\n accountForm.country === 'IN' ? accountForm.ifsc : accountForm.routingNumber\n }\n onChange={(event) =>\n setAccountForm((current) =>\n current.country === 'IN'\n ? { ...current, ifsc: event.target.value }\n : { ...current, routingNumber: event.target.value }\n )\n }\n placeholder={accountForm.country === 'IN' ? 'IFSC' : 'Routing number'}\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n </>\n ) : accountForm.type === 'UPI' ? (\n <input\n value={accountForm.upiId}\n onChange={(event) =>\n setAccountForm((current) => ({ ...current, upiId: event.target.value }))\n }\n placeholder=\"UPI ID\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n ) : null}\n </div>\n <button\n type=\"button\"\n onClick={() => void handleAddAccount()}\n className=\"mt-4 inline-flex items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text\"\n >\n <Landmark className=\"size-4\" />\n {editingAccountId ? 'Update payout account' : 'Save payout account'}\n </button>\n {editingAccountId ? (\n <button\n type=\"button\"\n onClick={() => {\n setEditingAccountId(null);\n setAccountForm({\n label: '',\n type: 'BANK_ACCOUNT',\n providerPreference: 'AUTO',\n country: 'US',\n currency: 'USD',\n accountHolderName: '',\n bankName: '',\n accountNumber: '',\n routingNumber: '',\n ifsc: '',\n upiId: '',\n });\n }}\n className=\"mt-4 ml-3 inline-flex items-center gap-2 rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary\"\n >\n Cancel edit\n </button>\n ) : null}\n </section>\n\n <section className=\"space-y-4\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <div className=\"mb-4 flex items-center justify-between\">\n <h2 className=\"text-lg font-semibold text-text-primary\">Request payout</h2>\n <button\n type=\"button\"\n onClick={() => void loadData()}\n className=\"inline-flex items-center gap-2 rounded-md border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary\"\n >\n <RefreshCw className=\"size-4\" />\n Refresh\n </button>\n </div>\n {accounts.length === 0 && !loading ? (\n <IllustratedEmptyState\n illustration=\"empty-generic\"\n title=\"No payout accounts yet\"\n description=\"Add a payout account before requesting a withdrawal.\"\n />\n ) : (\n <div className=\"space-y-3\">\n <select\n value={selectedAccountId}\n onChange={(event) => setSelectedAccountId(event.target.value)}\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n {!hasPayableAccount ? (\n <option value=\"\">No verified payout account yet</option>\n ) : null}\n {accounts.map((account) => (\n <option\n key={account.id}\n value={account.id}\n disabled={!isPayoutAccountPayable(account)}\n >\n {account.label} · {account.currency} ·{' '}\n {payoutAccountStatusView(account.status).label}\n </option>\n ))}\n </select>\n {!hasPayableAccount ? (\n <p className=\"text-sm text-text-secondary\">\n Payouts can be requested once one of your payout accounts is verified.\n </p>\n ) : null}\n <label className=\"block space-y-1 text-sm font-medium text-text-primary\">\n <span>Amount</span>\n <input\n value={requestAmount}\n onChange={(event) => setRequestAmount(event.target.value)}\n inputMode=\"decimal\"\n placeholder=\"0.00\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm font-normal text-text-primary\"\n />\n </label>\n <button\n type=\"button\"\n onClick={() => void handleRequestPayout()}\n disabled={!selectedAccount || !isPayoutAccountPayable(selectedAccount)}\n className=\"inline-flex items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text disabled:cursor-not-allowed disabled:opacity-50\"\n >\n <Send className=\"size-4\" />\n Request payout\n </button>\n </div>\n )}\n\n {accounts.length > 0 ? (\n <div className=\"mt-4 space-y-3 rounded-md border border-border-subtle bg-bg-surface/60 p-3\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Saved payout accounts</h3>\n {accounts.map((account) => {\n const statusView = payoutAccountStatusView(account.status);\n return (\n <div\n key={account.id}\n className=\"flex flex-wrap items-center justify-between gap-3 rounded-md border border-border-subtle/70 bg-bg-surface px-3 py-2 text-sm\"\n >\n <div>\n <p className=\"flex flex-wrap items-center gap-2 font-medium text-text-primary\">\n {account.label} {account.isDefault ? '• Default' : ''}\n <span\n className={`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${PAYOUT_ACCOUNT_TONE_CLASSES[statusView.tone]}`}\n >\n {statusView.label}\n </span>\n </p>\n <p className=\"text-text-secondary\">\n {account.providerPreference} · {account.currency}\n </p>\n {statusView.hint ? (\n <p className=\"mt-1 text-xs text-text-secondary\">{statusView.hint}</p>\n ) : null}\n </div>\n <div className=\"flex flex-wrap gap-2\">\n <button\n type=\"button\"\n onClick={() => handleEditAccount(account)}\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary\"\n >\n Edit\n </button>\n {!account.isDefault ? (\n <button\n type=\"button\"\n onClick={() => void handleSetDefault(account.id)}\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary\"\n >\n Make default\n </button>\n ) : null}\n <button\n type=\"button\"\n onClick={() => setArchiveAccountId(account.id)}\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-status-error-text\"\n >\n Archive\n </button>\n </div>\n </div>\n );\n })}\n </div>\n ) : null}\n </div>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">Payout requests</h2>\n {requests.length === 0 && !loading ? (\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title=\"No payout requests yet\"\n description=\"Your payout requests and processing updates will appear here.\"\n />\n ) : (\n <ResponsiveTable\n data={requests}\n rowKey={(request) => request.id}\n columns={payoutRequestColumns}\n />\n )}\n </div>\n </section>\n </div>\n\n <AlertDialog\n open={archiveAccountId !== null}\n onOpenChange={(open) => {\n if (!open) setArchiveAccountId(null);\n }}\n >\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Archive payout account?</AlertDialogTitle>\n <AlertDialogDescription>\n Archive this payout account? You can add a new one at any time.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Cancel</AlertDialogCancel>\n <AlertDialogAction\n onClick={() => {\n const id = archiveAccountId;\n setArchiveAccountId(null);\n if (id) void handleArchive(id);\n }}\n >\n Archive\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwCA,IAAME,IAA+D;CACnE;EACE,KAAK;EACL,QAAQ;EACR,UAAU;EACV,OAAO,MACL,kBAAC,QAAD;GAAM,WAAU;GACb,UAAAC,EAAeC,EAAQ,iBAAiBA,EAAQ,QAAQ;EACrD,CAAA;CAEV;CACA;EAAE,KAAK;EAAY,QAAQ;EAAY,OAAO,MAAYA,EAAQ;CAAS;CAC3E;EAAE,KAAK;EAAU,QAAQ;EAAU,OAAO,MAAYA,EAAQ;CAAO;CACrE;EACE,KAAK;EACL,QAAQ;EACR,OAAO,MAAYA,EAAQ,eAAe,SAAS;CACrD;CACA;EACE,KAAK;EACL,QAAQ;EACR,OAAO,MAAYC,EAAeD,EAAQ,SAAS;CACrD;AACF,GAEaE,UAAwB;CACnC,IAAMC,IAAcC,EAAsB,GACpC,EAAE,YAASC,EAAuB,GAClC,EAAE,kBAAe,cAAW,aAAUC,EAAW,GACjD,EAAE,MAAMC,MAAuBC,GAAyC,CAAC,CAAC,GAC1EC,IAAmBF,GAAoB,0BAA0B,IAEjE,CAACG,GAAUC,KAAeC,EAA0B,CAAC,CAAC,GACtD,CAACC,GAAUC,KAAeF,EAA0B,CAAC,CAAC,GACtD,CAACG,GAASC,KAAcJ,EAAS,EAAI,GACrC,CAACK,GAAOC,KAAYN,EAAuB,IAAI,GAC/C,CAACO,GAAaC,KAAkBR,EAAS;EAC7C,OAAO;EACP,MAAM;EACN,oBAAoB;EACpB,SAAS;EACT,UAAU;EACV,mBAAmB;EACnB,UAAU;EACV,eAAe;EACf,eAAe;EACf,MAAM;EACN,OAAO;CACT,CAAC,GACK,CAACS,GAAeC,KAAoBV,EAAS,EAAE,GAC/C,CAACW,GAAmBC,KAAwBZ,EAAiB,EAAE,GAC/D,C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,IACzB,kBAACyD,GAAD;OACE,cAAa;OACb,OAAM;OACN,aAAY;MACb,CAAA,IAED,kBAACK,GAAD;OACE,MAAMhE;OACN,SAAS,MAAYb,EAAQ;OAC7B,SAASF;MACV,CAAA,CAEA;KACE,CAAA,CAAA;IACN,CAAA,CAAA;;GAEL,kBAACgF,IAAD;IACE,MAAMnD,MAAqB;IAC3B,eAAe,MAAS;KACtB,AAAKoD,KAAMnD,EAAoB,IAAI;IACrC;IAEA,UAAA,kBAACoD,IAAD,EAAA,UAAA,CACE,kBAACC,IAAD,EAAA,UAAA,CACE,kBAACC,IAAD,EAAA,UAAkB,0BAAyC,CAAA,GAC3D,kBAACC,IAAD,EAAA,UAAwB,kEAEA,CAAA,CACP,EAAA,CAAA,GACnB,kBAACC,IAAD,EAAA,UAAA,CACE,kBAACC,IAAD,EAAA,UAAmB,SAAyB,CAAA,GAC5C,kBAACC,IAAD;KACE,eAAe;MACb,IAAMC,IAAK5D;MAEX,AADAC,EAAoB,IAAI,GACpB2D,KAAI7B,GAAmB6B,CAAE;KAC/B;KACD,UAAA;IAEkB,CAAA,CACF,EAAA,CAAA,CACD,EAAA,CAAA;GACT,CAAA;EACV;;AAET"}
|
|
1
|
+
{"version":3,"file":"PayoutsPage.js","names":["_Fragment","Fragment$1","payoutRequestColumns","formatCurrency","request","formatDateTime","PayoutsPage","permissions","useBillingPermissions","isFluidgrids","useIsFluidgridsVariant","isReviewingPayout","setIsReviewingPayout","useState","isSubmittingPayout","setIsSubmittingPayout","payoutError","setPayoutError","payoutResult","setPayoutResult","useBillingEventEmitter","useBilling","billingAccountData","useGetDefaultBillingAccountSettingsQuery","billingAccountId","accounts","setAccounts","requests","setRequests","loading","setLoading","error","setError","accountForm","setAccountForm","requestAmount","setRequestAmount","selectedAccountId","setSelectedAccountId","editingAccountId","setEditingAccountId","archiveAccountId","setArchiveAccountId","notice","setNotice","requestContext","useMemo","apiGatewayUrl","authToken","orgId","loadData","useCallback","loadedAccounts","loadedRequests","fetchPayoutAccounts","fetchPayoutRequests","pickPayableAccountId","current","loadError","useEffect","AccessDenied","isServerError","ServerError","handleAddAccount","payload","updatePayoutAccount","emit","created","addPayoutAccount","handleSetDefault","setDefaultPayoutAccount","accountId","handleArchive","archivePayoutAccount","handleEditAccount","account","selectedAccount","hasPayableAccount","isPayoutAccountPayable","handleRequestPayout","requestPayout","confirmPayout","err","MoneyActionDialog","PageHeader","PagePurpose","event","Landmark","RefreshCw","IllustratedEmptyState","payoutAccountStatusView","Send","statusView","PAYOUT_ACCOUNT_TONE_CLASSES","ResponsiveTable","AlertDialog","open","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","id"],"sources":["../../../../../src/billing/modules/earnings/pages/PayoutsPage.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState, type FC } from 'react';\nimport { Landmark, RefreshCw, Send } from 'lucide-react';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n ResponsiveTable,\n type ResponsiveTableColumn,\n} from '@burdenoff/fe-libs/ui';\n\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport { MoneyActionDialog } from '../../../shared/components';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { AccessDenied, PageHeader, ServerError } from '../../../shared/components';\nimport { PagePurpose, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\nimport { formatCurrency, formatDateTime, isServerError } from '../../../shared/utils';\nimport { useGetDefaultBillingAccountSettingsQuery } from '../../../../generated/global-operations';\nimport {\n addPayoutAccount,\n archivePayoutAccount,\n fetchPayoutAccounts,\n fetchPayoutRequests,\n requestPayout,\n setDefaultPayoutAccount,\n updatePayoutAccount,\n type PayoutAccount,\n type PayoutRequest,\n} from '../api';\nimport {\n PAYOUT_ACCOUNT_TONE_CLASSES,\n isPayoutAccountPayable,\n payoutAccountStatusView,\n pickPayableAccountId,\n} from '../payoutAccountStatus';\n\nconst payoutRequestColumns: ResponsiveTableColumn<PayoutRequest>[] = [\n {\n key: 'amount',\n header: 'Amount',\n priority: 'primary',\n cell: (request) => (\n <span className=\"tabular-nums\">\n {formatCurrency(request.requestedAmount, request.currency)}\n </span>\n ),\n },\n { key: 'provider', header: 'Provider', cell: (request) => request.provider },\n { key: 'status', header: 'Status', cell: (request) => request.status },\n {\n key: 'account',\n header: 'Account',\n cell: (request) => request.payoutAccount?.label || '-',\n },\n {\n key: 'created',\n header: 'Created',\n cell: (request) => formatDateTime(request.createdAt),\n },\n];\n\nexport const PayoutsPage: FC = () => {\n const permissions = useBillingPermissions();\n const isFluidgrids = useIsFluidgridsVariant();\n // FluidGrids: a review step precedes the request, and the outcome is always shown.\n const [isReviewingPayout, setIsReviewingPayout] = useState(false);\n const [isSubmittingPayout, setIsSubmittingPayout] = useState(false);\n const [payoutError, setPayoutError] = useState<string | null>(null);\n const [payoutResult, setPayoutResult] = useState<{ ok: boolean; message: string } | null>(null);\n const { emit } = useBillingEventEmitter();\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n const { data: billingAccountData } = useGetDefaultBillingAccountSettingsQuery({});\n const billingAccountId = billingAccountData?.getDefaultBillingAccount?.id;\n\n const [accounts, setAccounts] = useState<PayoutAccount[]>([]);\n const [requests, setRequests] = useState<PayoutRequest[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [accountForm, setAccountForm] = useState({\n label: '',\n type: 'BANK_ACCOUNT',\n providerPreference: 'AUTO',\n country: 'US',\n currency: 'USD',\n accountHolderName: '',\n bankName: '',\n accountNumber: '',\n routingNumber: '',\n ifsc: '',\n upiId: '',\n });\n const [requestAmount, setRequestAmount] = useState('');\n const [selectedAccountId, setSelectedAccountId] = useState<string>('');\n const [editingAccountId, setEditingAccountId] = useState<string | null>(null);\n const [archiveAccountId, setArchiveAccountId] = useState<string | null>(null);\n const [notice, setNotice] = useState<string | null>(null);\n\n const requestContext = useMemo(\n () => ({\n apiGatewayUrl,\n authToken,\n orgId,\n }),\n [apiGatewayUrl, authToken, orgId]\n );\n\n const loadData = useCallback(async () => {\n if (!billingAccountId) return;\n setLoading(true);\n setError(null);\n try {\n const [loadedAccounts, loadedRequests] = await Promise.all([\n fetchPayoutAccounts(billingAccountId, requestContext),\n fetchPayoutRequests(billingAccountId, requestContext),\n ]);\n setAccounts(loadedAccounts);\n setRequests(loadedRequests);\n // Only verified accounts can be paid out to (BOFF-10953).\n setSelectedAccountId((current) => pickPayableAccountId(loadedAccounts, current));\n } catch (loadError) {\n setError(loadError instanceof Error ? loadError : new Error('Failed to load payout data'));\n } finally {\n setLoading(false);\n }\n }, [billingAccountId, requestContext]);\n\n useEffect(() => {\n void loadData();\n }, [loadData]);\n\n if (!permissions.canManagePaymentMethods) {\n return <AccessDenied message=\"You don't have permission to manage payout accounts.\" />;\n }\n\n if (error && isServerError(error)) {\n return (\n <ServerError\n title=\"Payout data unavailable\"\n message={error.message}\n onRetry={() => void loadData()}\n showRetry\n />\n );\n }\n\n const handleAddAccount = async () => {\n if (!billingAccountId) return;\n setNotice(null);\n const payload = {\n billingAccountId,\n ...accountForm,\n };\n\n if (editingAccountId) {\n await updatePayoutAccount(editingAccountId, payload, requestContext);\n emit('billing.payout_account.updated', {\n route: '/billing/payouts',\n entityId: editingAccountId,\n source: 'payouts',\n });\n } else {\n const created = await addPayoutAccount(payload, requestContext);\n emit('billing.payout_account.added', {\n route: '/billing/payouts',\n entityId: billingAccountId,\n source: 'payouts',\n });\n // RazorpayX and Stripe Connect accounts stay pending until processor\n // onboarding verifies them (BOFF-10895); say so instead of implying the\n // account is ready to receive payouts.\n setNotice(\n created.status === 'ACTIVE'\n ? 'Payout account saved and ready to receive payouts.'\n : 'Payout account saved. It stays pending until the payout processor verifies it; you can request payouts to it once it is verified.'\n );\n }\n\n setAccountForm({\n label: '',\n type: 'BANK_ACCOUNT',\n providerPreference: 'AUTO',\n country: 'US',\n currency: 'USD',\n accountHolderName: '',\n bankName: '',\n accountNumber: '',\n routingNumber: '',\n ifsc: '',\n upiId: '',\n });\n setEditingAccountId(null);\n await loadData();\n };\n\n const handleSetDefault = async (accountId: string) => {\n setNotice(null);\n await setDefaultPayoutAccount(accountId, requestContext);\n await loadData();\n };\n\n const handleArchive = async (accountId: string) => {\n setNotice(null);\n await archivePayoutAccount(accountId, requestContext);\n emit('billing.payout_account.archived', {\n route: '/billing/payouts',\n entityId: accountId,\n source: 'payouts',\n });\n await loadData();\n };\n\n const handleEditAccount = (account: PayoutAccount) => {\n setNotice(null);\n setEditingAccountId(account.id);\n setAccountForm((current) => ({\n ...current,\n label: account.label,\n type: account.type,\n providerPreference: account.providerPreference,\n country: account.country || current.country,\n currency: account.currency,\n accountHolderName: account.displayName || current.accountHolderName,\n bankName: '',\n accountNumber: '',\n routingNumber: '',\n ifsc: '',\n upiId: '',\n }));\n };\n\n const selectedAccount = accounts.find((account) => account.id === selectedAccountId);\n const hasPayableAccount = accounts.some(isPayoutAccountPayable);\n\n const handleRequestPayout = async () => {\n if (!billingAccountId || !selectedAccountId || !requestAmount) return;\n if (!selectedAccount || !isPayoutAccountPayable(selectedAccount)) return;\n await requestPayout(\n {\n billingAccountId,\n payoutAccountId: selectedAccountId,\n amount: Number(requestAmount),\n currency: selectedAccount.currency,\n },\n requestContext\n );\n emit('billing.payout.requested', {\n route: '/billing/payouts',\n entityId: selectedAccountId,\n source: 'payouts',\n amount: Number(requestAmount),\n currency: selectedAccount.currency,\n });\n setRequestAmount('');\n await loadData();\n };\n\n const confirmPayout = async () => {\n setIsSubmittingPayout(true);\n setPayoutError(null);\n try {\n await handleRequestPayout();\n setIsReviewingPayout(false);\n setPayoutResult({\n ok: true,\n message: `Payout of ${formatCurrency(Number(requestAmount), selectedAccount?.currency ?? '')} requested. We'll show its status below.`,\n });\n } catch (err) {\n setPayoutError(err instanceof Error ? err.message : 'The payout request failed.');\n } finally {\n setIsSubmittingPayout(false);\n }\n };\n\n return (\n <div className=\"space-y-6 p-6\">\n {isFluidgrids && (\n <MoneyActionDialog\n open={isReviewingPayout}\n title=\"Review your payout\"\n description=\"The amount is moved out of your available balance when you confirm.\"\n details={[\n {\n label: 'Amount',\n value: formatCurrency(Number(requestAmount), selectedAccount?.currency ?? ''),\n },\n {\n label: 'Paid to',\n value: selectedAccount\n ? `${selectedAccount.label} · ${selectedAccount.currency}`\n : '',\n },\n ]}\n confirmLabel=\"Request payout\"\n busyLabel=\"Requesting…\"\n isBusy={isSubmittingPayout}\n error={payoutError}\n onConfirm={() => void confirmPayout()}\n onCancel={() => setIsReviewingPayout(false)}\n />\n )}\n {isFluidgrids && payoutResult && (\n <div\n role={payoutResult.ok ? 'status' : 'alert'}\n className={`rounded-md border p-3 text-sm ${payoutResult.ok ? 'border-status-success-border text-status-success-text' : 'border-status-error-border text-status-error-text'}`}\n >\n {payoutResult.message}\n </div>\n )}\n <PageHeader\n title=\"Payouts\"\n description=\"Register payout accounts, request withdrawals, and track disbursement status.\"\n />\n\n <PagePurpose>\n Get your earnings paid out to a real bank account or UPI. Register where you want to be\n paid, request a withdrawal of your available balance, and track each request from submission\n through to disbursement here.\n </PagePurpose>\n\n {notice ? (\n <div\n role=\"status\"\n className=\"rounded-lg border border-border-subtle bg-status-info-bg-subtle p-4 text-sm text-status-info-text\"\n >\n {notice}\n </div>\n ) : null}\n\n {error && !isServerError(error) ? (\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm text-status-error-text\">\n {error.message}\n </div>\n ) : null}\n\n <div className=\"grid gap-6 xl:grid-cols-[1.05fr,1.95fr]\">\n <section className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">\n {editingAccountId ? 'Edit payout account' : 'Add payout account'}\n </h2>\n <div className=\"space-y-3\">\n <input\n value={accountForm.label}\n onChange={(event) =>\n setAccountForm((current) => ({ ...current, label: event.target.value }))\n }\n placeholder=\"Label\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <div className=\"grid gap-3 md:grid-cols-2\">\n <select\n value={accountForm.type}\n onChange={(event) =>\n setAccountForm((current) => ({ ...current, type: event.target.value }))\n }\n className=\"rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"BANK_ACCOUNT\">Bank account</option>\n <option value=\"UPI\">UPI</option>\n <option value=\"WALLET\">Wallet</option>\n </select>\n <select\n value={accountForm.providerPreference}\n onChange={(event) =>\n setAccountForm((current) => ({\n ...current,\n providerPreference: event.target.value,\n }))\n }\n className=\"rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"AUTO\">Auto</option>\n <option value=\"STRIPE\">Stripe</option>\n <option value=\"RAZORPAY\">Razorpay</option>\n <option value=\"MANUAL\">Manual</option>\n </select>\n </div>\n <div className=\"grid gap-3 md:grid-cols-2\">\n <input\n value={accountForm.country}\n onChange={(event) =>\n setAccountForm((current) => ({\n ...current,\n country: event.target.value.toUpperCase(),\n }))\n }\n placeholder=\"Country\"\n className=\"rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={accountForm.currency}\n onChange={(event) =>\n setAccountForm((current) => ({\n ...current,\n currency: event.target.value.toUpperCase(),\n }))\n }\n placeholder=\"Currency\"\n className=\"rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n </div>\n <input\n value={accountForm.accountHolderName}\n onChange={(event) =>\n setAccountForm((current) => ({ ...current, accountHolderName: event.target.value }))\n }\n placeholder=\"Account holder name\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n {accountForm.type === 'BANK_ACCOUNT' ? (\n <>\n <input\n value={accountForm.bankName}\n onChange={(event) =>\n setAccountForm((current) => ({ ...current, bankName: event.target.value }))\n }\n placeholder=\"Bank name\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={accountForm.accountNumber}\n onChange={(event) =>\n setAccountForm((current) => ({ ...current, accountNumber: event.target.value }))\n }\n placeholder=\"Account number\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={\n accountForm.country === 'IN' ? accountForm.ifsc : accountForm.routingNumber\n }\n onChange={(event) =>\n setAccountForm((current) =>\n current.country === 'IN'\n ? { ...current, ifsc: event.target.value }\n : { ...current, routingNumber: event.target.value }\n )\n }\n placeholder={accountForm.country === 'IN' ? 'IFSC' : 'Routing number'}\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n </>\n ) : accountForm.type === 'UPI' ? (\n <input\n value={accountForm.upiId}\n onChange={(event) =>\n setAccountForm((current) => ({ ...current, upiId: event.target.value }))\n }\n placeholder=\"UPI ID\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n ) : null}\n </div>\n <button\n type=\"button\"\n onClick={() => void handleAddAccount()}\n className=\"mt-4 inline-flex items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text\"\n >\n <Landmark className=\"size-4\" />\n {editingAccountId ? 'Update payout account' : 'Save payout account'}\n </button>\n {editingAccountId ? (\n <button\n type=\"button\"\n onClick={() => {\n setEditingAccountId(null);\n setAccountForm({\n label: '',\n type: 'BANK_ACCOUNT',\n providerPreference: 'AUTO',\n country: 'US',\n currency: 'USD',\n accountHolderName: '',\n bankName: '',\n accountNumber: '',\n routingNumber: '',\n ifsc: '',\n upiId: '',\n });\n }}\n className=\"mt-4 ml-3 inline-flex items-center gap-2 rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary\"\n >\n Cancel edit\n </button>\n ) : null}\n </section>\n\n <section className=\"space-y-4\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <div className=\"mb-4 flex items-center justify-between\">\n <h2 className=\"text-lg font-semibold text-text-primary\">Request payout</h2>\n <button\n type=\"button\"\n onClick={() => void loadData()}\n className=\"inline-flex items-center gap-2 rounded-md border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary\"\n >\n <RefreshCw className=\"size-4\" />\n Refresh\n </button>\n </div>\n {accounts.length === 0 && !loading ? (\n <IllustratedEmptyState\n illustration=\"empty-generic\"\n title=\"No payout accounts yet\"\n description=\"Add a payout account before requesting a withdrawal.\"\n />\n ) : (\n <div className=\"space-y-3\">\n <select\n value={selectedAccountId}\n onChange={(event) => setSelectedAccountId(event.target.value)}\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n {!hasPayableAccount ? (\n <option value=\"\">No verified payout account yet</option>\n ) : null}\n {accounts.map((account) => (\n <option\n key={account.id}\n value={account.id}\n disabled={!isPayoutAccountPayable(account)}\n >\n {account.label} · {account.currency} ·{' '}\n {payoutAccountStatusView(account.status).label}\n </option>\n ))}\n </select>\n {!hasPayableAccount ? (\n <p className=\"text-sm text-text-secondary\">\n Payouts can be requested once one of your payout accounts is verified.\n </p>\n ) : null}\n <label className=\"block space-y-1 text-sm font-medium text-text-primary\">\n <span>Amount</span>\n <input\n value={requestAmount}\n onChange={(event) => setRequestAmount(event.target.value)}\n inputMode=\"decimal\"\n placeholder=\"0.00\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm font-normal text-text-primary\"\n />\n </label>\n <button\n type=\"button\"\n onClick={() => {\n if (!isFluidgrids) {\n void handleRequestPayout();\n return;\n }\n setPayoutError(null);\n setPayoutResult(null);\n setIsReviewingPayout(true);\n }}\n disabled={!selectedAccount || !isPayoutAccountPayable(selectedAccount)}\n className=\"inline-flex items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text disabled:cursor-not-allowed disabled:opacity-50\"\n >\n <Send className=\"size-4\" />\n Request payout\n </button>\n </div>\n )}\n\n {accounts.length > 0 ? (\n <div className=\"mt-4 space-y-3 rounded-md border border-border-subtle bg-bg-surface/60 p-3\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Saved payout accounts</h3>\n {accounts.map((account) => {\n const statusView = payoutAccountStatusView(account.status);\n return (\n <div\n key={account.id}\n className=\"flex flex-wrap items-center justify-between gap-3 rounded-md border border-border-subtle/70 bg-bg-surface px-3 py-2 text-sm\"\n >\n <div>\n <p className=\"flex flex-wrap items-center gap-2 font-medium text-text-primary\">\n {account.label} {account.isDefault ? '• Default' : ''}\n <span\n className={`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${PAYOUT_ACCOUNT_TONE_CLASSES[statusView.tone]}`}\n >\n {statusView.label}\n </span>\n </p>\n <p className=\"text-text-secondary\">\n {account.providerPreference} · {account.currency}\n </p>\n {statusView.hint ? (\n <p className=\"mt-1 text-xs text-text-secondary\">{statusView.hint}</p>\n ) : null}\n </div>\n <div className=\"flex flex-wrap gap-2\">\n <button\n type=\"button\"\n onClick={() => handleEditAccount(account)}\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary\"\n >\n Edit\n </button>\n {!account.isDefault ? (\n <button\n type=\"button\"\n onClick={() => void handleSetDefault(account.id)}\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary\"\n >\n Make default\n </button>\n ) : null}\n <button\n type=\"button\"\n onClick={() => setArchiveAccountId(account.id)}\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-status-error-text\"\n >\n Archive\n </button>\n </div>\n </div>\n );\n })}\n </div>\n ) : null}\n </div>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">Payout requests</h2>\n {requests.length === 0 && !loading ? (\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title=\"No payout requests yet\"\n description=\"Your payout requests and processing updates will appear here.\"\n />\n ) : (\n <ResponsiveTable\n data={requests}\n rowKey={(request) => request.id}\n columns={payoutRequestColumns}\n />\n )}\n </div>\n </section>\n </div>\n\n <AlertDialog\n open={archiveAccountId !== null}\n onOpenChange={(open) => {\n if (!open) setArchiveAccountId(null);\n }}\n >\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Archive payout account?</AlertDialogTitle>\n <AlertDialogDescription>\n Archive this payout account? You can add a new one at any time.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Cancel</AlertDialogCancel>\n <AlertDialogAction\n onClick={() => {\n const id = archiveAccountId;\n setArchiveAccountId(null);\n if (id) void handleArchive(id);\n }}\n >\n Archive\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0CA,IAAME,KAA+D;CACnE;EACE,KAAK;EACL,QAAQ;EACR,UAAU;EACV,OAAO,MACL,kBAAC,QAAD;GAAM,WAAU;GACb,UAAAC,EAAeC,EAAQ,iBAAiBA,EAAQ,QAAQ;EACrD,CAAA;CAEV;CACA;EAAE,KAAK;EAAY,QAAQ;EAAY,OAAO,MAAYA,EAAQ;CAAS;CAC3E;EAAE,KAAK;EAAU,QAAQ;EAAU,OAAO,MAAYA,EAAQ;CAAO;CACrE;EACE,KAAK;EACL,QAAQ;EACR,OAAO,MAAYA,EAAQ,eAAe,SAAS;CACrD;CACA;EACE,KAAK;EACL,QAAQ;EACR,OAAO,MAAYC,EAAeD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IAEkB,CAAA,CACF,EAAA,CAAA,CACD,EAAA,CAAA;GACT,CAAA;EACV;;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.
|
|
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'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'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,C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","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'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'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,G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,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAkB,0BAAyC,CAAA,GAC3D,kBAACC,IAAD,EAAA,UAAwB,0GAGA,CAAA,CACP,EAAA,CAAA,GACnB,kBAACC,GAAD,EAAA,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"}
|
|
@@ -8,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,
|
|
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
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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 ?
|
|
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
|
-
|
|
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 @@
|
|
|
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
|