@burdenoff/microfe-billing 2026.1114.5 → 2026.1114.7
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 +74 -87
- package/dist/billing/BillingUserRoutes.js.map +1 -1
- package/dist/billing/modules/addons/pages/AddonBrowseDetailPage.js +1 -1
- package/dist/billing/modules/addons/pages/AddonDetailPage.js +1 -1
- package/dist/billing/modules/addons/pages/AddonEditPage.js +1 -1
- package/dist/billing/modules/addons/pages/AddonsBrowsePage.js +3 -3
- package/dist/billing/modules/addons/pages/AddonsBrowsePage.js.map +1 -1
- package/dist/billing/modules/billing/pages/InvoicesListPage.js +176 -168
- package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/TransactionsPage.js +117 -111
- package/dist/billing/modules/billing/pages/TransactionsPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/UserRefundsPage.js +143 -138
- package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditTransactionsPage.js +132 -126
- package/dist/billing/modules/credits/pages/CreditTransactionsPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditsPage.js +1 -1
- package/dist/billing/modules/credits/pages/CreditsPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/DeveloperRevenueAdminPage.js +13 -13
- package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js +24 -24
- package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanBrowseDetailPage.js +1 -1
- package/dist/billing/modules/plans/pages/PlanEditPage.js +6 -6
- package/dist/billing/modules/plans/pages/PlanEditPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlansBrowsePage.js +35 -35
- package/dist/billing/modules/plans/pages/PlansListPage.js +1 -1
- package/dist/billing/modules/quota/pages/QuotaTemplateDetailPage.js +4 -4
- package/dist/billing/modules/quota/pages/QuotaTemplateEditPage.js +4 -4
- package/dist/billing/modules/store/index.d.ts +0 -1
- package/dist/billing/shared/components/BillingHistoryTabs.d.ts +9 -0
- package/dist/billing/shared/components/BillingHistoryTabs.js +30 -0
- package/dist/billing/shared/components/BillingHistoryTabs.js.map +1 -0
- package/dist/billing/shared/components/historyTabs.d.ts +19 -0
- package/dist/billing/shared/components/historyTabs.js +32 -0
- package/dist/billing/shared/components/historyTabs.js.map +1 -0
- package/dist/billing/shared/components/index.d.ts +1 -0
- package/dist/billing/shared/components/index.js +2 -1
- package/package.json +1 -1
- package/dist/billing/modules/store/graphql/index.js +0 -1
- package/dist/billing/modules/store/index.js +0 -2
- package/dist/billing/modules/store/pages/StoreCheckoutPage.d.ts +0 -9
- package/dist/billing/modules/store/pages/StoreCheckoutPage.js +0 -16
- package/dist/billing/modules/store/pages/StoreCheckoutPage.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreditsPage.js","names":["CreditsPage","useI18n","tr","translated","t","key","fallback","navigateTo","useBillingNavigate","permissions","useBillingPermissions","isFluidgrids","useIsFluidgridsVariant","showWithdraw","defaultAccount","isLoadingDefault","useDefaultBillingAccount","searchParams","useSearchParams","chosenAccountId","setChosenAccountId","useState","accountsData","useGetBillingAccountsByOrgQuery","accountOptions","useMemo","viewingOther","otherAccount","isLoadingOther","useBillingAccount","billingAccount","isLoadingAccount","selectedAccountId","days","setDays","filterType","setFilterType","page","setPage","isLoadingTransactions","useCreditTransactions","isLoading","filteredTransactions","transactions","tx","error","refetch","creditBalance","PagePurpose","EmphasisPanel","account","pagination","d","type","formatCreditTransactionType","IllustratedEmptyState","TransactionRow","p","statusColor","getCreditTransactionStatusColor","transaction","isCredit","statusTokens","getStatusBadgeClasses","formatRelativeTime","formatDate"],"sources":["../../../../../src/billing/modules/credits/pages/CreditsPage.tsx"],"sourcesContent":["/**\n * Credits Module - Credits Page\n * Displays credit balance and transaction history\n */\n\nimport { useMemo, useState, type FC } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { useCreditTransactions } from '../hooks/useCredits';\nimport { useBillingAccount, useDefaultBillingAccount } from '../../subscriptions/hooks';\nimport {\n useGetBillingAccountsByOrgQuery,\n type GetBillingAccountsByOrgQuery,\n} from '../../../../generated/global-operations';\n\ntype BillingAccountItem = GetBillingAccountsByOrgQuery['getBillingAccountsByOrg'][number];\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport {\n formatDate,\n formatRelativeTime,\n formatCreditTransactionType,\n} from '../../../shared/utils/format';\nimport {\n getCreditTransactionStatusColor,\n getStatusBadgeClasses,\n} from '../../../shared/utils/status';\nimport { statusTokens } from '../../../shared/utils/tokens';\nimport type { CreditTransaction, CreditTransactionType } from '../../../shared/types';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { EmphasisPanel, PagePurpose, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\n\ntype FilterType = 'all' | CreditTransactionType;\n\nexport const CreditsPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n // FluidGrids: Withdraw lives only in the Seller area (BOFF-11861).\n const isFluidgrids = useIsFluidgridsVariant();\n const showWithdraw = !isFluidgrids;\n const { billingAccount: defaultAccount, isLoading: isLoadingDefault } =\n useDefaultBillingAccount();\n\n // FluidGrids: pick which billing account's credits to see, like Invoices does.\n const [searchParams] = useSearchParams();\n const [chosenAccountId, setChosenAccountId] = useState<string | null>(\n searchParams.get('billingAccountId')\n );\n const { data: accountsData } = useGetBillingAccountsByOrgQuery({\n fetchPolicy: 'cache-first',\n skip: !isFluidgrids,\n });\n const accountOptions = useMemo(\n () => (isFluidgrids ? (accountsData?.getBillingAccountsByOrg ?? []) : []),\n [isFluidgrids, accountsData]\n );\n const viewingOther =\n isFluidgrids && chosenAccountId !== null && chosenAccountId !== defaultAccount?.id;\n const { billingAccount: otherAccount, isLoading: isLoadingOther } = useBillingAccount(\n viewingOther ? chosenAccountId : undefined\n );\n const billingAccount = viewingOther ? otherAccount : defaultAccount;\n const isLoadingAccount = viewingOther ? isLoadingOther : isLoadingDefault;\n const selectedAccountId = viewingOther ? chosenAccountId : (defaultAccount?.id ?? '');\n\n const [days, setDays] = useState(30);\n const [filterType, setFilterType] = useState<FilterType>('all');\n const [page, setPage] = useState(1);\n\n const {\n transactions,\n pagination,\n isLoading: isLoadingTransactions,\n error,\n refetch,\n } = useCreditTransactions({\n billingAccountId: billingAccount?.id || '',\n days,\n page,\n pageSize: 20,\n });\n\n // Permission check\n if (!permissions.canViewCredits) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-2\">\n <div className=\"size-12 mx-auto rounded-full bg-bg-sunken flex items-center justify-center\">\n <svg\n className=\"size-6 text-text-secondary\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Access Denied</h2>\n <p className=\"text-sm text-text-secondary max-w-sm\">\n You don't have permission to view credits.\n </p>\n </div>\n </div>\n );\n }\n\n const isLoading = isLoadingAccount || isLoadingTransactions;\n\n // Filter transactions\n const filteredTransactions = transactions.filter((tx) => {\n if (filterType === 'all') return true;\n return tx.type === filterType;\n });\n\n // Loading state\n if (isLoading && !billingAccount) {\n return (\n <div className=\"space-y-6 px-6 lg:px-8 py-6\">\n <div className=\"h-8 w-48 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\n <div className=\"border border-border-subtle rounded-lg p-6\">\n <div className=\"h-6 w-24 bg-bg-sunken animate-pulse rounded mb-2\" />\n <div className=\"h-10 w-32 bg-bg-sunken animate-pulse rounded\" />\n </div>\n </div>\n </div>\n );\n }\n\n // Error state\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-4\">\n <div className=\"size-12 mx-auto rounded-full bg-status-error-bg-subtle flex items-center justify-center\">\n <svg\n className=\"size-6 text-status-error-text\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Failed to load credits</h2>\n <p className=\"text-sm text-text-secondary\">{error.message}</p>\n <button\n type=\"button\"\n onClick={() => refetch()}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors\"\n >\n Try Again\n </button>\n </div>\n </div>\n );\n }\n\n const creditBalance = billingAccount?.creditAmount || 0;\n\n return (\n <div className=\"space-y-6 px-6 lg:px-8 py-6\">\n {/* Header */}\n <div\n className={\n isFluidgrids\n ? 'flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between'\n : 'flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between'\n }\n >\n <div className={isFluidgrids ? 'min-w-0 lg:max-w-3xl' : undefined}>\n <h1 className=\"text-2xl md:text-3xl font-semibold tracking-tight text-text-primary\">\n {tr('billing.credits.title', 'Credits')}\n </h1>\n <p className=\"text-sm text-text-secondary mt-1\">\n Manage your credit balance and view transaction history\n </p>\n <PagePurpose className=\"mt-3\">\n {tr(\n 'billing.credits.purpose',\n 'Credits are prepaid balance you can spend on usage and purchases instead of paying per invoice. See your available balance, top it up, withdraw unused credits, and review every credit purchase, grant and deduction over time.'\n )}\n </PagePurpose>\n </div>\n\n <div\n className={\n isFluidgrids\n ? 'flex flex-wrap items-center gap-2 lg:shrink-0 [&_button]:whitespace-nowrap'\n : 'flex items-center gap-2'\n }\n >\n {showWithdraw && (\n <button\n type=\"button\"\n onClick={() => navigateTo('/credits/withdraw')}\n className=\"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors\"\n >\n <svg className=\"size-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z\"\n />\n </svg>\n Withdraw\n </button>\n )}\n <button\n type=\"button\"\n onClick={() => navigateTo('/checkout/credits')}\n className=\"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors\"\n >\n <svg className=\"size-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 4v16m8-8H4\"\n />\n </svg>\n Purchase Credits\n </button>\n </div>\n </div>\n\n {/* Balance Card */}\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4\">\n <EmphasisPanel className=\"p-6\">\n <p className=\"text-sm text-text-secondary\">Available Balance</p>\n <p className=\"text-3xl font-bold tabular-nums text-text-primary mt-2\">\n {creditBalance.toLocaleString()} Credits\n </p>\n {isFluidgrids && accountOptions.length > 1 ? (\n <select\n aria-label={tr('billing.credits.billingAccountLabel', 'Billing Account')}\n value={selectedAccountId ?? ''}\n onChange={(e) => {\n setChosenAccountId(e.target.value || null);\n setPage(1);\n }}\n className=\"mt-3 w-full min-w-0 truncate text-sm border border-border-subtle rounded-button bg-bg-surface text-text-primary px-3 py-2 focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n {accountOptions.map((account: BillingAccountItem) => (\n <option key={account.id ?? ''} value={account.id ?? ''}>\n {account.name ?? account.email ?? account.id}\n {account.isDefault ? tr('billing.invoices.defaultSuffix', ' (Default)') : ''}\n </option>\n ))}\n </select>\n ) : (\n <p className=\"text-sm text-text-secondary mt-2\">{billingAccount?.name}</p>\n )}\n </EmphasisPanel>\n\n <div className=\"border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 p-5\">\n <p className=\"text-sm text-text-secondary\">Transactions ({days}d)</p>\n <p className=\"text-2xl md:text-3xl font-semibold tracking-tight text-text-primary mt-2\">\n {pagination.totalCount}\n </p>\n <p className=\"text-sm text-text-secondary mt-2\">Total transactions</p>\n </div>\n </div>\n\n {/* Filters */}\n <div className=\"flex flex-wrap items-center gap-4 pb-4 border-b border-border-subtle\">\n {/* Time Range */}\n <div className=\"inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken\">\n {[7, 30, 90].map((d) => (\n <button\n type=\"button\"\n key={d}\n onClick={() => setDays(d)}\n className={`px-3 py-1.5 text-sm font-medium rounded-button transition-colors ${\n days === d\n ? 'bg-bg-surface text-text-primary shadow-sm'\n : 'text-text-secondary hover:text-text-primary'\n }`}\n >\n {d}d\n </button>\n ))}\n </div>\n\n {/* Transaction Type Filter */}\n <div className=\"inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken\">\n {(['all', 'purchase', 'usage', 'adjustment', 'granted'] as FilterType[]).map((type) => (\n <button\n type=\"button\"\n key={type}\n onClick={() => setFilterType(type)}\n className={`px-3 py-1.5 text-sm font-medium rounded-button transition-colors capitalize ${\n filterType === type\n ? 'bg-bg-surface text-text-primary shadow-sm'\n : 'text-text-secondary hover:text-text-primary'\n }`}\n >\n {type === 'all' ? 'All' : formatCreditTransactionType(type as CreditTransactionType)}\n </button>\n ))}\n </div>\n </div>\n\n {/* Transactions List */}\n {filteredTransactions.length === 0 ? (\n <IllustratedEmptyState\n illustration={filterType !== 'all' ? 'empty-search' : 'empty-data'}\n title=\"No transactions found\"\n description={\n filterType !== 'all'\n ? 'No transactions match your filter.'\n : 'No credit transactions in this period.'\n }\n />\n ) : (\n <div className=\"space-y-3\">\n {filteredTransactions.map((tx) => (\n <TransactionRow key={tx.id} transaction={tx} />\n ))}\n\n {/* Pagination */}\n {pagination.hasMore && (\n <div className=\"flex justify-center pt-4\">\n <button\n type=\"button\"\n onClick={() => setPage((p) => p + 1)}\n className=\"px-4 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors\"\n >\n Load More\n </button>\n </div>\n )}\n </div>\n )}\n </div>\n );\n};\n\n// ============================================================================\n// Transaction Row Component\n// ============================================================================\n\ninterface TransactionRowProps {\n transaction: CreditTransaction;\n}\n\nconst TransactionRow: FC<TransactionRowProps> = ({ transaction }) => {\n const statusColor = getCreditTransactionStatusColor(transaction.status);\n const isCredit =\n transaction.type === 'purchase' ||\n transaction.type === 'adjustment' ||\n transaction.type === 'granted';\n\n return (\n <div className=\"flex items-center gap-4 p-4 border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 hover:shadow-sm transition-shadow\">\n {/* Icon */}\n <div\n className={`size-10 rounded-full flex items-center justify-center ${\n isCredit ? statusTokens.success.bg : statusTokens.warning.bg\n }`}\n >\n {isCredit ? (\n <svg\n className={`size-5 ${statusTokens.success.icon}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M12 4v16m8-8H4\" />\n </svg>\n ) : (\n <svg\n className={`size-5 ${statusTokens.warning.icon}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M20 12H4\" />\n </svg>\n )}\n </div>\n\n {/* Info */}\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <p className=\"font-medium text-text-primary capitalize\">\n {formatCreditTransactionType(transaction.type)}\n </p>\n <span\n className={`px-2 py-0.5 text-xs font-medium rounded ${getStatusBadgeClasses(statusColor)}`}\n >\n {transaction.status}\n </span>\n </div>\n <p className=\"text-sm text-text-secondary mt-0.5\">\n {formatRelativeTime(transaction.createdAt)} • {formatDate(transaction.createdAt, 'short')}\n </p>\n </div>\n\n {/* Amount */}\n <div className=\"text-right\">\n <p\n className={`font-semibold ${isCredit ? statusTokens.success.text : 'text-text-primary'}`}\n >\n {isCredit ? '+' : '-'}\n {transaction.amount.toLocaleString()} credits\n </p>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,IAAaA,UAAwB;CACnC,IAAM,EAAE,SAAMC,EAAQ,GAChBC,KAAM,GAAa,MAA6B;EACpD,IAAMC,IAAaC,EAAEC,CAAG;EACxB,OAAOF,MAAeE,IAAMC,IAAWH;CACzC,GACMI,IAAaC,EAAmB,GAChCC,IAAcC,EAAsB,GAEpCC,IAAeC,EAAuB,GACtCC,IAAe,CAACF,GAChB,EAAE,gBAAgBG,GAAgB,WAAWC,MACjDC,EAAyB,GAGrB,CAACC,KAAgBC,EAAgB,GACjC,CAACC,GAAiBC,KAAsBC,EAC5CJ,EAAa,IAAI,kBAAkB,CACrC,GACM,EAAE,MAAMK,MAAiBC,EAAgC;EAC7D,aAAa;EACb,MAAM,CAACZ;CACT,CAAC,GACKa,IAAiBC,QACdd,IAAgBW,GAAc,2BAA2B,CAAC,IAAK,CAAC,GACvE,CAACX,GAAcW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pC;;GACA,CAAA;EACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"CreditsPage.js","names":["CreditsPage","useI18n","tr","translated","t","key","fallback","navigateTo","useBillingNavigate","permissions","useBillingPermissions","isFluidgrids","useIsFluidgridsVariant","showWithdraw","defaultAccount","isLoadingDefault","useDefaultBillingAccount","searchParams","useSearchParams","chosenAccountId","setChosenAccountId","useState","accountsData","useGetBillingAccountsByOrgQuery","accountOptions","useMemo","viewingOther","otherAccount","isLoadingOther","useBillingAccount","billingAccount","isLoadingAccount","selectedAccountId","days","setDays","filterType","setFilterType","page","setPage","isLoadingTransactions","useCreditTransactions","isLoading","filteredTransactions","transactions","tx","error","refetch","creditBalance","PagePurpose","EmphasisPanel","account","pagination","d","type","formatCreditTransactionType","IllustratedEmptyState","TransactionRow","p","statusColor","getCreditTransactionStatusColor","transaction","isCredit","statusTokens","getStatusBadgeClasses","formatRelativeTime","formatDate"],"sources":["../../../../../src/billing/modules/credits/pages/CreditsPage.tsx"],"sourcesContent":["/**\n * Credits Module - Credits Page\n * Displays credit balance and transaction history\n */\n\nimport { useMemo, useState, type FC } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { useCreditTransactions } from '../hooks/useCredits';\nimport { useBillingAccount, useDefaultBillingAccount } from '../../subscriptions/hooks';\nimport {\n useGetBillingAccountsByOrgQuery,\n type GetBillingAccountsByOrgQuery,\n} from '../../../../generated/global-operations';\n\ntype BillingAccountItem = GetBillingAccountsByOrgQuery['getBillingAccountsByOrg'][number];\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport {\n formatDate,\n formatRelativeTime,\n formatCreditTransactionType,\n} from '../../../shared/utils/format';\nimport {\n getCreditTransactionStatusColor,\n getStatusBadgeClasses,\n} from '../../../shared/utils/status';\nimport { statusTokens } from '../../../shared/utils/tokens';\nimport type { CreditTransaction, CreditTransactionType } from '../../../shared/types';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { EmphasisPanel, PagePurpose, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\n\ntype FilterType = 'all' | CreditTransactionType;\n\nexport const CreditsPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n // FluidGrids: Withdraw lives only in the Seller area (BOFF-11861).\n const isFluidgrids = useIsFluidgridsVariant();\n const showWithdraw = !isFluidgrids;\n const { billingAccount: defaultAccount, isLoading: isLoadingDefault } =\n useDefaultBillingAccount();\n\n // FluidGrids: pick which billing account's credits to see, like Invoices does.\n const [searchParams] = useSearchParams();\n const [chosenAccountId, setChosenAccountId] = useState<string | null>(\n searchParams.get('billingAccountId')\n );\n const { data: accountsData } = useGetBillingAccountsByOrgQuery({\n fetchPolicy: 'cache-first',\n skip: !isFluidgrids,\n });\n const accountOptions = useMemo(\n () => (isFluidgrids ? (accountsData?.getBillingAccountsByOrg ?? []) : []),\n [isFluidgrids, accountsData]\n );\n const viewingOther =\n isFluidgrids && chosenAccountId !== null && chosenAccountId !== defaultAccount?.id;\n const { billingAccount: otherAccount, isLoading: isLoadingOther } = useBillingAccount(\n viewingOther ? chosenAccountId : undefined\n );\n const billingAccount = viewingOther ? otherAccount : defaultAccount;\n const isLoadingAccount = viewingOther ? isLoadingOther : isLoadingDefault;\n const selectedAccountId = viewingOther ? chosenAccountId : (defaultAccount?.id ?? '');\n\n const [days, setDays] = useState(30);\n const [filterType, setFilterType] = useState<FilterType>('all');\n const [page, setPage] = useState(1);\n\n const {\n transactions,\n pagination,\n isLoading: isLoadingTransactions,\n error,\n refetch,\n } = useCreditTransactions({\n billingAccountId: billingAccount?.id || '',\n days,\n page,\n pageSize: 20,\n });\n\n // Permission check\n if (!permissions.canViewCredits) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-2\">\n <div className=\"size-12 mx-auto rounded-full bg-bg-sunken flex items-center justify-center\">\n <svg\n className=\"size-6 text-text-secondary\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Access Denied</h2>\n <p className=\"text-sm text-text-secondary max-w-sm\">\n You don't have permission to view credits.\n </p>\n </div>\n </div>\n );\n }\n\n const isLoading = isLoadingAccount || isLoadingTransactions;\n\n // Filter transactions\n const filteredTransactions = transactions.filter((tx) => {\n if (filterType === 'all') return true;\n return tx.type === filterType;\n });\n\n // Loading state\n if (isLoading && !billingAccount) {\n return (\n <div className=\"space-y-6 px-6 lg:px-8 py-6\">\n <div className=\"h-8 w-48 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\n <div className=\"border border-border-subtle rounded-lg p-6\">\n <div className=\"h-6 w-24 bg-bg-sunken animate-pulse rounded mb-2\" />\n <div className=\"h-10 w-32 bg-bg-sunken animate-pulse rounded\" />\n </div>\n </div>\n </div>\n );\n }\n\n // Error state\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-4\">\n <div className=\"size-12 mx-auto rounded-full bg-status-error-bg-subtle flex items-center justify-center\">\n <svg\n className=\"size-6 text-status-error-text\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Failed to load credits</h2>\n <p className=\"text-sm text-text-secondary\">{error.message}</p>\n <button\n type=\"button\"\n onClick={() => refetch()}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors\"\n >\n Try Again\n </button>\n </div>\n </div>\n );\n }\n\n const creditBalance = billingAccount?.creditAmount || 0;\n\n return (\n <div className=\"space-y-6 px-6 lg:px-8 py-6\">\n {/* Header */}\n <div\n className={\n isFluidgrids\n ? 'flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between'\n : 'flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between'\n }\n >\n <div className={isFluidgrids ? 'min-w-0 lg:max-w-3xl' : undefined}>\n <h1 className=\"text-2xl md:text-3xl font-semibold tracking-tight text-text-primary\">\n {tr('billing.credits.title', 'Credits')}\n </h1>\n <p className=\"text-sm text-text-secondary mt-1\">\n Manage your credit balance and view transaction history\n </p>\n <PagePurpose className=\"mt-3\">\n {isFluidgrids\n ? tr(\n 'billing.credits.purposeFluidgrids',\n 'Credits are your prepaid balance for usage and purchases. They are separate from the monthly AI credits that come with your plan. See your balance, top it up, and review every purchase, grant and deduction.'\n )\n : tr(\n 'billing.credits.purpose',\n 'Credits are prepaid balance you can spend on usage and purchases instead of paying per invoice. See your available balance, top it up, withdraw unused credits, and review every credit purchase, grant and deduction over time.'\n )}\n </PagePurpose>\n </div>\n\n <div\n className={\n isFluidgrids\n ? 'flex flex-wrap items-center gap-2 lg:shrink-0 [&_button]:whitespace-nowrap'\n : 'flex items-center gap-2'\n }\n >\n {showWithdraw && (\n <button\n type=\"button\"\n onClick={() => navigateTo('/credits/withdraw')}\n className=\"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors\"\n >\n <svg className=\"size-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z\"\n />\n </svg>\n Withdraw\n </button>\n )}\n <button\n type=\"button\"\n onClick={() => navigateTo('/checkout/credits')}\n className=\"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors\"\n >\n <svg className=\"size-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 4v16m8-8H4\"\n />\n </svg>\n Purchase Credits\n </button>\n </div>\n </div>\n\n {/* Balance Card */}\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4\">\n <EmphasisPanel className=\"p-6\">\n <p className=\"text-sm text-text-secondary\">Available Balance</p>\n <p className=\"text-3xl font-bold tabular-nums text-text-primary mt-2\">\n {creditBalance.toLocaleString()} Credits\n </p>\n {isFluidgrids && accountOptions.length > 1 ? (\n <select\n aria-label={tr('billing.credits.billingAccountLabel', 'Billing Account')}\n value={selectedAccountId ?? ''}\n onChange={(e) => {\n setChosenAccountId(e.target.value || null);\n setPage(1);\n }}\n className=\"mt-3 w-full min-w-0 truncate text-sm border border-border-subtle rounded-button bg-bg-surface text-text-primary px-3 py-2 focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n {accountOptions.map((account: BillingAccountItem) => (\n <option key={account.id ?? ''} value={account.id ?? ''}>\n {account.name ?? account.email ?? account.id}\n {account.isDefault ? tr('billing.invoices.defaultSuffix', ' (Default)') : ''}\n </option>\n ))}\n </select>\n ) : (\n <p className=\"text-sm text-text-secondary mt-2\">{billingAccount?.name}</p>\n )}\n </EmphasisPanel>\n\n <div className=\"border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 p-5\">\n <p className=\"text-sm text-text-secondary\">Transactions ({days}d)</p>\n <p className=\"text-2xl md:text-3xl font-semibold tracking-tight text-text-primary mt-2\">\n {pagination.totalCount}\n </p>\n <p className=\"text-sm text-text-secondary mt-2\">Total transactions</p>\n </div>\n </div>\n\n {/* Filters */}\n <div className=\"flex flex-wrap items-center gap-4 pb-4 border-b border-border-subtle\">\n {/* Time Range */}\n <div className=\"inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken\">\n {[7, 30, 90].map((d) => (\n <button\n type=\"button\"\n key={d}\n onClick={() => setDays(d)}\n className={`px-3 py-1.5 text-sm font-medium rounded-button transition-colors ${\n days === d\n ? 'bg-bg-surface text-text-primary shadow-sm'\n : 'text-text-secondary hover:text-text-primary'\n }`}\n >\n {d}d\n </button>\n ))}\n </div>\n\n {/* Transaction Type Filter */}\n <div className=\"inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken\">\n {(['all', 'purchase', 'usage', 'adjustment', 'granted'] as FilterType[]).map((type) => (\n <button\n type=\"button\"\n key={type}\n onClick={() => setFilterType(type)}\n className={`px-3 py-1.5 text-sm font-medium rounded-button transition-colors capitalize ${\n filterType === type\n ? 'bg-bg-surface text-text-primary shadow-sm'\n : 'text-text-secondary hover:text-text-primary'\n }`}\n >\n {type === 'all' ? 'All' : formatCreditTransactionType(type as CreditTransactionType)}\n </button>\n ))}\n </div>\n </div>\n\n {/* Transactions List */}\n {filteredTransactions.length === 0 ? (\n <IllustratedEmptyState\n illustration={filterType !== 'all' ? 'empty-search' : 'empty-data'}\n title=\"No transactions found\"\n description={\n filterType !== 'all'\n ? 'No transactions match your filter.'\n : 'No credit transactions in this period.'\n }\n />\n ) : (\n <div className=\"space-y-3\">\n {filteredTransactions.map((tx) => (\n <TransactionRow key={tx.id} transaction={tx} />\n ))}\n\n {/* Pagination */}\n {pagination.hasMore && (\n <div className=\"flex justify-center pt-4\">\n <button\n type=\"button\"\n onClick={() => setPage((p) => p + 1)}\n className=\"px-4 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors\"\n >\n Load More\n </button>\n </div>\n )}\n </div>\n )}\n </div>\n );\n};\n\n// ============================================================================\n// Transaction Row Component\n// ============================================================================\n\ninterface TransactionRowProps {\n transaction: CreditTransaction;\n}\n\nconst TransactionRow: FC<TransactionRowProps> = ({ transaction }) => {\n const statusColor = getCreditTransactionStatusColor(transaction.status);\n const isCredit =\n transaction.type === 'purchase' ||\n transaction.type === 'adjustment' ||\n transaction.type === 'granted';\n\n return (\n <div className=\"flex items-center gap-4 p-4 border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 hover:shadow-sm transition-shadow\">\n {/* Icon */}\n <div\n className={`size-10 rounded-full flex items-center justify-center ${\n isCredit ? statusTokens.success.bg : statusTokens.warning.bg\n }`}\n >\n {isCredit ? (\n <svg\n className={`size-5 ${statusTokens.success.icon}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M12 4v16m8-8H4\" />\n </svg>\n ) : (\n <svg\n className={`size-5 ${statusTokens.warning.icon}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M20 12H4\" />\n </svg>\n )}\n </div>\n\n {/* Info */}\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <p className=\"font-medium text-text-primary capitalize\">\n {formatCreditTransactionType(transaction.type)}\n </p>\n <span\n className={`px-2 py-0.5 text-xs font-medium rounded ${getStatusBadgeClasses(statusColor)}`}\n >\n {transaction.status}\n </span>\n </div>\n <p className=\"text-sm text-text-secondary mt-0.5\">\n {formatRelativeTime(transaction.createdAt)} • {formatDate(transaction.createdAt, 'short')}\n </p>\n </div>\n\n {/* Amount */}\n <div className=\"text-right\">\n <p\n className={`font-semibold ${isCredit ? statusTokens.success.text : 'text-text-primary'}`}\n >\n {isCredit ? '+' : '-'}\n {transaction.amount.toLocaleString()} credits\n </p>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,IAAaA,UAAwB;CACnC,IAAM,EAAE,SAAMC,EAAQ,GAChBC,KAAM,GAAa,MAA6B;EACpD,IAAMC,IAAaC,EAAEC,CAAG;EACxB,OAAOF,MAAeE,IAAMC,IAAWH;CACzC,GACMI,IAAaC,EAAmB,GAChCC,IAAcC,EAAsB,GAEpCC,IAAeC,EAAuB,GACtCC,IAAe,CAACF,GAChB,EAAE,gBAAgBG,GAAgB,WAAWC,MACjDC,EAAyB,GAGrB,CAACC,KAAgBC,EAAgB,GACjC,CAACC,GAAiBC,KAAsBC,EAC5CJ,EAAa,IAAI,kBAAkB,CACrC,GACM,EAAE,MAAMK,MAAiBC,EAAgC;EAC7D,aAAa;EACb,MAAM,CAACZ;CACT,CAAC,GACKa,IAAiBC,QACdd,IAAgBW,GAAc,2BAA2B,CAAC,IAAK,CAAC,GACvE,CAACX,GAAcW,CAAY,CAC7B,GACMI,IACJf,KAAgBQ,MAAoB,QAAQA,MAAoBL,GAAgB,IAC5E,EAAE,gBAAgBa,GAAc,WAAWC,MAAmBC,EAClEH,IAAeP,IAAkB,KAAA,CACnC,GACMW,IAAiBJ,IAAeC,IAAeb,GAC/CiB,IAAmBL,IAAeE,IAAiBb,GACnDiB,IAAoBN,IAAeP,IAAmBL,GAAgB,MAAM,IAE5E,CAACmB,GAAMC,KAAWb,EAAS,EAAE,GAC7B,CAACc,GAAYC,KAAiBf,EAAqB,KAAK,GACxD,CAACgB,GAAMC,KAAWjB,EAAS,CAAC,GAE5B,EACJ,iBACA,eACA,WAAWkB,GACX,UACA,eACEC,EAAs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MAAQ,gBAAe;MAAQ,aAAa;MAAG,GAAE;KAAkB,CAAA;IACpF,CAAA,IAEL,kBAAC,OAAD;KACE,WAAW,UAAUA,EAAa,QAAQ;KAC1C,MAAK;KACL,SAAQ;KACR,QAAO;KAEP,UAAA,kBAAC,QAAD;MAAM,eAAc;MAAQ,gBAAe;MAAQ,aAAa;MAAG,GAAE;KAAY,CAAA;IAC9E,CAAA;GAEJ,CAAA;GAGL,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,kBAAC,KAAD;MAAG,WAAU;MACV,UAAAR,EAA4BM,EAAY,IAAI;KAC5C,CAAA,GACH,kBAAC,QAAD;MACE,WAAW,2CAA2CG,EAAsBL,CAAW;MAEtF,UAAAE,EAAY;KACT,CAAA,CACH;IACL,CAAA,GAAA,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA;MACGI,EAAmBJ,EAAY,SAAS;MAAE;MAAIK,EAAWL,EAAY,WAAW,OAAO;KACvF;IACA,CAAA,CAAA;;GAGL,kBAAC,OAAD;IAAK,WAAU;IACb,UAAA,kBAAC,KAAD;KACE,WAAW,iBAAiBC,IAAWC,EAAa,QAAQ,OAAO;KADrE,UAAA;MAGGD,IAAW,MAAM;MACjBD,EAAY,OAAO,eAAe;MAAE;KACpC;;GACA,CAAA;EACF;;AAET"}
|
|
@@ -3,9 +3,9 @@ import { AccessDenied as t } from "../../../shared/components/AccessDenied.js";
|
|
|
3
3
|
import { PageHeader as n } from "../../../shared/components/PageHeader.js";
|
|
4
4
|
import { ServerError as r } from "../../../shared/components/ServerError.js";
|
|
5
5
|
import { useBillingNavigate as i } from "../../../hooks/useBillingNavigate.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { useBillingPermissions as a } from "../../../hooks/useBillingPermissions.js";
|
|
7
|
+
import { formatCurrency as o } from "../../../shared/utils/format.js";
|
|
8
|
+
import { isServerError as s } from "../../../shared/utils/error.js";
|
|
9
9
|
import "../../../shared/components/index.js";
|
|
10
10
|
import "../../../shared/utils/index.js";
|
|
11
11
|
import { fetchAdminDeveloperRevenueOrgs as c } from "../api.js";
|
|
@@ -36,7 +36,7 @@ function C({ orgs: e }) {
|
|
|
36
36
|
children: "Gross revenue"
|
|
37
37
|
}), /* @__PURE__ */ S("div", {
|
|
38
38
|
className: "mt-1 flex items-center gap-2 text-lg font-semibold text-text-primary",
|
|
39
|
-
children: [/* @__PURE__ */ x(h, { className: "size-4 text-text-muted" }),
|
|
39
|
+
children: [/* @__PURE__ */ x(h, { className: "size-4 text-text-muted" }), o(t.totalRevenue, "USD")]
|
|
40
40
|
})]
|
|
41
41
|
}),
|
|
42
42
|
/* @__PURE__ */ S("div", {
|
|
@@ -46,7 +46,7 @@ function C({ orgs: e }) {
|
|
|
46
46
|
children: "Platform fees"
|
|
47
47
|
}), /* @__PURE__ */ S("div", {
|
|
48
48
|
className: "mt-1 flex items-center gap-2 text-lg font-semibold text-text-primary",
|
|
49
|
-
children: [/* @__PURE__ */ x(_, { className: "size-4 text-text-muted" }),
|
|
49
|
+
children: [/* @__PURE__ */ x(_, { className: "size-4 text-text-muted" }), o(t.totalPlatformFees, "USD")]
|
|
50
50
|
})]
|
|
51
51
|
}),
|
|
52
52
|
/* @__PURE__ */ S("div", {
|
|
@@ -56,7 +56,7 @@ function C({ orgs: e }) {
|
|
|
56
56
|
children: "Pending earned credits"
|
|
57
57
|
}), /* @__PURE__ */ S("div", {
|
|
58
58
|
className: "mt-1 flex items-center gap-2 text-lg font-semibold text-text-primary",
|
|
59
|
-
children: [/* @__PURE__ */ x(y, { className: "size-4 text-text-muted" }),
|
|
59
|
+
children: [/* @__PURE__ */ x(y, { className: "size-4 text-text-muted" }), o(t.pendingBalance, "USD")]
|
|
60
60
|
})]
|
|
61
61
|
}),
|
|
62
62
|
/* @__PURE__ */ S("div", {
|
|
@@ -66,14 +66,14 @@ function C({ orgs: e }) {
|
|
|
66
66
|
children: "Already withdrawn"
|
|
67
67
|
}), /* @__PURE__ */ S("div", {
|
|
68
68
|
className: "mt-1 flex items-center gap-2 text-lg font-semibold text-text-primary",
|
|
69
|
-
children: [/* @__PURE__ */ x(m, { className: "size-4 text-text-muted" }),
|
|
69
|
+
children: [/* @__PURE__ */ x(m, { className: "size-4 text-text-muted" }), o(t.totalPayouts, "USD")]
|
|
70
70
|
})]
|
|
71
71
|
})
|
|
72
72
|
]
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
var w = () => {
|
|
76
|
-
let m =
|
|
76
|
+
let m = a(), { apiGatewayUrl: h, authToken: _, orgId: y } = e(), w = i(), [T, E] = f([]), [D, O] = f(!0), [k, A] = f(null), [j, M] = f(""), N = d(() => ({
|
|
77
77
|
apiGatewayUrl: h,
|
|
78
78
|
authToken: _,
|
|
79
79
|
orgId: y
|
|
@@ -95,7 +95,7 @@ var w = () => {
|
|
|
95
95
|
if (u(() => {
|
|
96
96
|
m.isBillingAdmin && P();
|
|
97
97
|
}, [P, m.isBillingAdmin]), !m.isBillingAdmin) return /* @__PURE__ */ x(t, { message: "You don't have permission to view developer revenue." });
|
|
98
|
-
if (k &&
|
|
98
|
+
if (k && s(k)) return /* @__PURE__ */ x(r, {
|
|
99
99
|
title: "Developer revenue unavailable",
|
|
100
100
|
message: k.message,
|
|
101
101
|
showRetry: !0,
|
|
@@ -204,19 +204,19 @@ var w = () => {
|
|
|
204
204
|
}),
|
|
205
205
|
/* @__PURE__ */ x("td", {
|
|
206
206
|
className: "px-4 py-3 text-text-primary",
|
|
207
|
-
children:
|
|
207
|
+
children: o(e.totalRevenue, "USD")
|
|
208
208
|
}),
|
|
209
209
|
/* @__PURE__ */ x("td", {
|
|
210
210
|
className: "px-4 py-3 text-text-secondary",
|
|
211
|
-
children:
|
|
211
|
+
children: o(e.totalPlatformFees, "USD")
|
|
212
212
|
}),
|
|
213
213
|
/* @__PURE__ */ x("td", {
|
|
214
214
|
className: "px-4 py-3 font-medium text-status-warning-text",
|
|
215
|
-
children:
|
|
215
|
+
children: o(e.pendingBalance, "USD")
|
|
216
216
|
}),
|
|
217
217
|
/* @__PURE__ */ x("td", {
|
|
218
218
|
className: "px-4 py-3 text-text-secondary",
|
|
219
|
-
children:
|
|
219
|
+
children: o(e.totalPayouts, "USD")
|
|
220
220
|
})
|
|
221
221
|
]
|
|
222
222
|
}, e.id)) })]
|
|
@@ -4,9 +4,9 @@ import { PageHeader as n } from "../../../shared/components/PageHeader.js";
|
|
|
4
4
|
import { StatCard as r } from "../../../shared/components/StatCard.js";
|
|
5
5
|
import { ServerError as i } from "../../../shared/components/ServerError.js";
|
|
6
6
|
import { useBillingNavigate as a } from "../../../hooks/useBillingNavigate.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { useBillingPermissions as o } from "../../../hooks/useBillingPermissions.js";
|
|
8
|
+
import { formatCredits as s, formatCurrency as c, formatDateTime as l } from "../../../shared/utils/format.js";
|
|
9
|
+
import { isServerError as ee } from "../../../shared/utils/error.js";
|
|
10
10
|
import "../../../shared/components/index.js";
|
|
11
11
|
import "../../../shared/utils/index.js";
|
|
12
12
|
import { fetchAdminDeveloperRevenueOrg as u, fetchAdminDeveloperRevenueOrgDetail as d, fetchAdminDeveloperRevenueOrgMonthly as te, fetchAdminPayoutRequests as f, fetchBillingAccountCreditBalance as p, fetchCreditCost as m, retrySaleCreditSync as ne } from "../api.js";
|
|
@@ -100,15 +100,15 @@ function de({ points: e }) {
|
|
|
100
100
|
}),
|
|
101
101
|
/* @__PURE__ */ S("td", {
|
|
102
102
|
className: "px-4 py-3 text-text-primary",
|
|
103
|
-
children:
|
|
103
|
+
children: c(t.grossRevenue, "USD")
|
|
104
104
|
}),
|
|
105
105
|
/* @__PURE__ */ S("td", {
|
|
106
106
|
className: "px-4 py-3 text-text-secondary",
|
|
107
|
-
children:
|
|
107
|
+
children: c(t.platformFees, "USD")
|
|
108
108
|
}),
|
|
109
109
|
/* @__PURE__ */ S("td", {
|
|
110
110
|
className: "px-4 py-3 text-text-secondary",
|
|
111
|
-
children:
|
|
111
|
+
children: c(t.netRevenue, "USD")
|
|
112
112
|
}),
|
|
113
113
|
/* @__PURE__ */ S("td", {
|
|
114
114
|
className: "px-4 py-3 text-text-secondary",
|
|
@@ -176,7 +176,7 @@ function fe({ requests: e }) {
|
|
|
176
176
|
children: [
|
|
177
177
|
/* @__PURE__ */ S("td", {
|
|
178
178
|
className: "px-4 py-3 text-text-secondary",
|
|
179
|
-
children:
|
|
179
|
+
children: l(e.createdAt)
|
|
180
180
|
}),
|
|
181
181
|
/* @__PURE__ */ S("td", {
|
|
182
182
|
className: "px-4 py-3 text-text-secondary",
|
|
@@ -184,7 +184,7 @@ function fe({ requests: e }) {
|
|
|
184
184
|
}),
|
|
185
185
|
/* @__PURE__ */ S("td", {
|
|
186
186
|
className: "px-4 py-3 font-medium text-text-primary",
|
|
187
|
-
children:
|
|
187
|
+
children: c(e.requestedAmount, e.currency)
|
|
188
188
|
}),
|
|
189
189
|
/* @__PURE__ */ S("td", {
|
|
190
190
|
className: "px-4 py-3",
|
|
@@ -192,7 +192,7 @@ function fe({ requests: e }) {
|
|
|
192
192
|
}),
|
|
193
193
|
/* @__PURE__ */ S("td", {
|
|
194
194
|
className: "px-4 py-3 text-text-secondary",
|
|
195
|
-
children: e.paidAt ?
|
|
195
|
+
children: e.paidAt ? l(e.paidAt) : "—"
|
|
196
196
|
}),
|
|
197
197
|
/* @__PURE__ */ S("td", {
|
|
198
198
|
className: "px-4 py-3 text-text-muted",
|
|
@@ -204,7 +204,7 @@ function fe({ requests: e }) {
|
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
var k = () => {
|
|
207
|
-
let { organizationId: y } = le(), T =
|
|
207
|
+
let { organizationId: y } = le(), T = o(), { apiGatewayUrl: E, authToken: D, orgId: k } = e(), pe = a(), [A, j] = _(null), [M, N] = _([]), [P, F] = _(null), [I, L] = _(null), [R, z] = _([]), [B, me] = _(null), [he, ge] = _([]), [V, H] = _(w), [_e, U] = _(!0), [W, G] = _(!1), [K, q] = _(null), [J, Y] = _(null), X = g(() => ({
|
|
208
208
|
apiGatewayUrl: E,
|
|
209
209
|
authToken: D,
|
|
210
210
|
orgId: k
|
|
@@ -266,7 +266,7 @@ var k = () => {
|
|
|
266
266
|
}).finally(() => G(!1)));
|
|
267
267
|
};
|
|
268
268
|
if (!T.isBillingAdmin) return /* @__PURE__ */ S(t, { message: "You don't have permission to view developer revenue." });
|
|
269
|
-
if (K &&
|
|
269
|
+
if (K && ee(K)) return /* @__PURE__ */ S(i, {
|
|
270
270
|
title: "Developer revenue unavailable",
|
|
271
271
|
message: K.message,
|
|
272
272
|
showRetry: !0,
|
|
@@ -300,22 +300,22 @@ var k = () => {
|
|
|
300
300
|
children: [
|
|
301
301
|
/* @__PURE__ */ S(r, {
|
|
302
302
|
label: "Gross revenue (all time)",
|
|
303
|
-
value:
|
|
303
|
+
value: c(A.totalRevenue, "USD"),
|
|
304
304
|
icon: /* @__PURE__ */ S(b, { className: "size-4" })
|
|
305
305
|
}),
|
|
306
306
|
/* @__PURE__ */ S(r, {
|
|
307
307
|
label: "Platform fees (all time)",
|
|
308
|
-
value:
|
|
308
|
+
value: c(A.totalPlatformFees, "USD"),
|
|
309
309
|
icon: /* @__PURE__ */ S(se, { className: "size-4" })
|
|
310
310
|
}),
|
|
311
311
|
/* @__PURE__ */ S(r, {
|
|
312
312
|
label: "Pending earned credits",
|
|
313
|
-
value:
|
|
313
|
+
value: c(B?.summary?.pendingBalance ?? A.pendingBalance, "USD"),
|
|
314
314
|
icon: /* @__PURE__ */ S(ce, { className: "size-4" })
|
|
315
315
|
}),
|
|
316
316
|
/* @__PURE__ */ S(r, {
|
|
317
317
|
label: "Already withdrawn (all time)",
|
|
318
|
-
value:
|
|
318
|
+
value: c(ye, "USD"),
|
|
319
319
|
icon: /* @__PURE__ */ S(oe, { className: "size-4" })
|
|
320
320
|
})
|
|
321
321
|
]
|
|
@@ -338,28 +338,28 @@ var k = () => {
|
|
|
338
338
|
children: [
|
|
339
339
|
/* @__PURE__ */ S(r, {
|
|
340
340
|
label: "Earned",
|
|
341
|
-
value:
|
|
341
|
+
value: s(P.earned)
|
|
342
342
|
}),
|
|
343
343
|
/* @__PURE__ */ S(r, {
|
|
344
344
|
label: "Purchased",
|
|
345
|
-
value:
|
|
345
|
+
value: s(P.purchased)
|
|
346
346
|
}),
|
|
347
347
|
/* @__PURE__ */ S(r, {
|
|
348
348
|
label: "Granted",
|
|
349
|
-
value:
|
|
349
|
+
value: s(P.granted)
|
|
350
350
|
}),
|
|
351
351
|
/* @__PURE__ */ S(r, {
|
|
352
352
|
label: "Withdrawable",
|
|
353
|
-
value:
|
|
353
|
+
value: s(P.withdrawable)
|
|
354
354
|
}),
|
|
355
355
|
/* @__PURE__ */ S(r, {
|
|
356
356
|
label: "Total balance",
|
|
357
|
-
value:
|
|
357
|
+
value: s(P.total)
|
|
358
358
|
})
|
|
359
359
|
]
|
|
360
360
|
}), /* @__PURE__ */ S("div", {
|
|
361
361
|
className: "px-5 pb-4 text-xs text-text-muted",
|
|
362
|
-
children: I === null ? "Estimated cash value could not be loaded." : `≈ ${
|
|
362
|
+
children: I === null ? "Estimated cash value could not be loaded." : `≈ ${c(I, "USD")} total at the current credit rate.`
|
|
363
363
|
})] }) : /* @__PURE__ */ S("div", {
|
|
364
364
|
className: "px-5 py-8 text-center text-sm text-text-muted",
|
|
365
365
|
children: "Credit balance could not be loaded."
|
|
@@ -369,7 +369,7 @@ var k = () => {
|
|
|
369
369
|
}),
|
|
370
370
|
$ > 0 && /* @__PURE__ */ C("div", {
|
|
371
371
|
className: "border-t border-border-seam bg-status-warning-bg-subtle px-5 py-3 text-xs text-status-warning-text",
|
|
372
|
-
children: [
|
|
372
|
+
children: [c($, "USD"), " is currently tied up in a pending or approved withdrawal request — it has already left the withdrawable balance above."]
|
|
373
373
|
})
|
|
374
374
|
]
|
|
375
375
|
}),
|
|
@@ -495,11 +495,11 @@ var k = () => {
|
|
|
495
495
|
}),
|
|
496
496
|
/* @__PURE__ */ S("td", {
|
|
497
497
|
className: "px-4 py-3 text-text-secondary",
|
|
498
|
-
children:
|
|
498
|
+
children: l(e.purchasedAt)
|
|
499
499
|
}),
|
|
500
500
|
/* @__PURE__ */ S("td", {
|
|
501
501
|
className: "px-4 py-3 text-text-primary",
|
|
502
|
-
children:
|
|
502
|
+
children: c(e.netAmount, e.currency)
|
|
503
503
|
}),
|
|
504
504
|
/* @__PURE__ */ C("td", {
|
|
505
505
|
className: "px-4 py-3 text-text-secondary",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeveloperRevenueOrgDetailPage.js","names":["_Fragment","Fragment$1","ALL_TIME","PAYOUT_STATUS_LABEL","PAYOUT_STATUS_COLORS","PayoutStatusBadge","status","formatMonthLabel","iso","monthRangeFor","month","start","MonthlyRevenueTrend","points","prior","index","growthPct","point","formatCurrency","jsx","TrendingUp","TrendingDown","WithdrawalHistory","requests","formatDateTime","request","DeveloperRevenueOrgDetailPage","useParams","permissions","useBillingPermissions","useBilling","navigateTo","useBillingNavigate","org","setOrg","useState","monthly","setMonthly","creditBalance","setCreditBalance","creditBalanceUsd","setCreditBalanceUsd","lifetimePayouts","setLifetimePayouts","detail","setDetail","payoutHistory","setPayoutHistory","selectedMonth","setSelectedMonth","loading","setLoading","periodLoading","setPeriodLoading","error","setError","retryingSaleId","setRetryingSaleId","requestContext","useMemo","apiGatewayUrl","authToken","orgId","loadPeriod","useCallback","range","detailResult","payoutsResult","fetchAdminDeveloperRevenueOrgDetail","organizationIdValue","billingAccountId","fetchAdminPayoutRequests","load","organizationId","orgResult","monthlyResult","fetchAdminDeveloperRevenueOrg","fetchAdminDeveloperRevenueOrgMonthly","defaultMonth","balanceResult","lifetimeResult","fetchBillingAccountCreditBalance","fetchCreditCost","loadError","handleMonthChange","AccessDenied","isServerError","ServerError","Loader2","withdrawn","sum","inFlight","monthOptions","PageHeader","ArrowLeft","PagePurpose","StatCard","CreditCard","Wallet","BadgeCheck","formatCredits","event","sale","retrySaleCreditSync"],"sources":["../../../../../src/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState, type FC } from 'react';\nimport { useParams } from 'react-router';\nimport {\n ArrowLeft,\n BadgeCheck,\n CreditCard,\n Loader2,\n TrendingDown,\n TrendingUp,\n Wallet,\n} from 'lucide-react';\n\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { AccessDenied, PageHeader, ServerError, StatCard } from '../../../shared/components';\nimport { PagePurpose } from '@burdenoff/fe-libs/ui';\nimport {\n formatCredits,\n formatCurrency,\n formatDateTime,\n isServerError,\n} from '../../../shared/utils';\nimport {\n fetchAdminDeveloperRevenueOrg,\n fetchAdminDeveloperRevenueOrgDetail,\n fetchAdminDeveloperRevenueOrgMonthly,\n fetchAdminPayoutRequests,\n fetchBillingAccountCreditBalance,\n fetchCreditCost,\n retrySaleCreditSync,\n type AdminDeveloperRevenueOrg,\n type AdminDeveloperRevenueOrgDetail,\n type CreditBalanceByType,\n type DeveloperOrgMonthlyRevenuePoint,\n type PayoutRequest,\n} from '../api';\n\nconst ALL_TIME = 'all';\n\nconst PAYOUT_STATUS_LABEL: Record<string, string> = {\n REQUESTED: 'Requested',\n APPROVED: 'Approved',\n REJECTED: 'Rejected',\n PROCESSING: 'Processing',\n PAID: 'Paid',\n FAILED: 'Failed',\n CANCELED: 'Canceled',\n};\n\nconst PAYOUT_STATUS_COLORS: Record<string, string> = {\n REQUESTED: 'bg-status-warning-bg-subtle text-status-warning-text',\n APPROVED: 'bg-status-info-bg-subtle text-status-info-text',\n REJECTED: 'bg-status-error-bg-subtle text-status-error-text',\n PROCESSING: 'bg-status-info-bg-subtle text-status-info-text',\n PAID: 'bg-status-success-bg-subtle text-status-success-text',\n FAILED: 'bg-status-error-bg-subtle text-status-error-text',\n CANCELED: 'bg-bg-sunken text-text-muted',\n};\n\nfunction PayoutStatusBadge({ status }: { status: string }) {\n return (\n <span\n className={`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${PAYOUT_STATUS_COLORS[status] ?? 'bg-bg-sunken text-text-muted'}`}\n >\n {PAYOUT_STATUS_LABEL[status] ?? status}\n </span>\n );\n}\n\nfunction formatMonthLabel(iso: string): string {\n return new Date(iso).toLocaleDateString('en-US', { month: 'short', year: 'numeric' });\n}\n\n/**\n * Turns a month-start ISO string (as returned by developerOrgMonthlyRevenue,\n * always the first instant of a calendar month) into a [startDate, endDate]\n * range covering that whole month, for scoping the sales/withdrawal queries.\n * ALL_TIME returns an empty range (no filtering).\n */\nfunction monthRangeFor(month: string): { startDate?: string; endDate?: string } {\n if (month === ALL_TIME) return {};\n const start = new Date(month);\n if (Number.isNaN(start.getTime())) return {};\n const startDate = new Date(\n Date.UTC(start.getUTCFullYear(), start.getUTCMonth(), 1)\n ).toISOString();\n const endDate = new Date(\n Date.UTC(start.getUTCFullYear(), start.getUTCMonth() + 1, 1) - 1\n ).toISOString();\n return { startDate, endDate };\n}\n\nfunction MonthlyRevenueTrend({ points }: { points: DeveloperOrgMonthlyRevenuePoint[] }) {\n if (points.length === 0) {\n return (\n <div className=\"px-5 py-10 text-center text-sm text-text-muted\">\n No sales recorded yet — the revenue trend will appear once the first sale comes in.\n </div>\n );\n }\n\n return (\n <div className=\"overflow-x-auto\">\n <table className=\"min-w-full text-sm\">\n <thead className=\"bg-bg-sunken/60 text-left text-xs uppercase tracking-wide text-text-muted\">\n <tr>\n <th className=\"px-4 py-3\">Month</th>\n <th className=\"px-4 py-3\">Gross revenue</th>\n <th className=\"px-4 py-3\">Platform fee</th>\n <th className=\"px-4 py-3\">Net revenue</th>\n <th className=\"px-4 py-3\">Sales</th>\n <th className=\"px-4 py-3\">Growth (MoM)</th>\n </tr>\n </thead>\n <tbody>\n {points.map((point, index) => {\n const prior = index > 0 ? points[index - 1] : null;\n const growthPct =\n prior && prior.grossRevenue > 0\n ? ((point.grossRevenue - prior.grossRevenue) / prior.grossRevenue) * 100\n : null;\n\n return (\n <tr key={point.month} className=\"border-t border-border-seam\">\n <td className=\"px-4 py-3 font-medium text-text-primary\">\n {formatMonthLabel(point.month)}\n </td>\n <td className=\"px-4 py-3 text-text-primary\">\n {formatCurrency(point.grossRevenue, 'USD')}\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">\n {formatCurrency(point.platformFees, 'USD')}\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">\n {formatCurrency(point.netRevenue, 'USD')}\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">{point.salesCount}</td>\n <td className=\"px-4 py-3\">\n {growthPct === null ? (\n <span className=\"text-text-muted\">—</span>\n ) : (\n <span\n className={`inline-flex items-center gap-1 font-medium ${\n growthPct >= 0 ? 'text-status-success-text' : 'text-status-error-text'\n }`}\n >\n {growthPct >= 0 ? (\n <TrendingUp className=\"size-3.5\" />\n ) : (\n <TrendingDown className=\"size-3.5\" />\n )}\n {growthPct >= 0 ? '+' : ''}\n {growthPct.toFixed(1)}%\n </span>\n )}\n </td>\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n}\n\nfunction WithdrawalHistory({ requests }: { requests: PayoutRequest[] }) {\n if (requests.length === 0) {\n return (\n <div className=\"px-5 py-10 text-center text-sm text-text-muted\">\n No withdrawal requests in this period.\n </div>\n );\n }\n\n return (\n <div className=\"overflow-x-auto\">\n <table className=\"min-w-full text-sm\">\n <thead className=\"bg-bg-sunken/60 text-left text-xs uppercase tracking-wide text-text-muted\">\n <tr>\n <th className=\"px-4 py-3\">Requested</th>\n <th className=\"px-4 py-3\">Kind</th>\n <th className=\"px-4 py-3\">Amount</th>\n <th className=\"px-4 py-3\">Status</th>\n <th className=\"px-4 py-3\">Paid</th>\n <th className=\"px-4 py-3\">Notes</th>\n </tr>\n </thead>\n <tbody>\n {requests.map((request) => (\n <tr key={request.id} className=\"border-t border-border-seam\">\n <td className=\"px-4 py-3 text-text-secondary\">{formatDateTime(request.createdAt)}</td>\n <td className=\"px-4 py-3 text-text-secondary\">\n {request.requestKind === 'CREDIT_CONVERSION'\n ? 'Revenue-share credits'\n : 'Cash payout'}\n </td>\n <td className=\"px-4 py-3 font-medium text-text-primary\">\n {formatCurrency(request.requestedAmount, request.currency)}\n </td>\n <td className=\"px-4 py-3\">\n <PayoutStatusBadge status={request.status} />\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">\n {request.paidAt ? formatDateTime(request.paidAt) : '—'}\n </td>\n <td className=\"px-4 py-3 text-text-muted\">\n {request.failureReason || request.userNotes || '—'}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n}\n\nexport const DeveloperRevenueOrgDetailPage: FC = () => {\n const { organizationId } = useParams<{ organizationId: string }>();\n const permissions = useBillingPermissions();\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n const navigateTo = useBillingNavigate();\n\n const [org, setOrg] = useState<AdminDeveloperRevenueOrg | null>(null);\n const [monthly, setMonthly] = useState<DeveloperOrgMonthlyRevenuePoint[]>([]);\n const [creditBalance, setCreditBalance] = useState<CreditBalanceByType | null>(null);\n const [creditBalanceUsd, setCreditBalanceUsd] = useState<number | null>(null);\n // Lifetime (unscoped) withdrawal history — drives the \"Already withdrawn\" /\n // in-flight totals up top, which must stay accurate regardless of which\n // month the tables below are currently scoped to.\n const [lifetimePayouts, setLifetimePayouts] = useState<PayoutRequest[]>([]);\n // Period-scoped data — re-fetched whenever selectedMonth changes.\n const [detail, setDetail] = useState<AdminDeveloperRevenueOrgDetail | null>(null);\n const [payoutHistory, setPayoutHistory] = useState<PayoutRequest[]>([]);\n const [selectedMonth, setSelectedMonth] = useState<string>(ALL_TIME);\n\n const [loading, setLoading] = useState(true);\n const [periodLoading, setPeriodLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [retryingSaleId, setRetryingSaleId] = useState<string | null>(null);\n\n const requestContext = useMemo(\n () => ({ apiGatewayUrl, authToken, orgId }),\n [apiGatewayUrl, authToken, orgId]\n );\n\n const loadPeriod = useCallback(\n async (\n organizationIdValue: string,\n billingAccountId: string | null | undefined,\n month: string\n ) => {\n const range = monthRangeFor(month);\n const [detailResult, payoutsResult] = await Promise.all([\n fetchAdminDeveloperRevenueOrgDetail(organizationIdValue, requestContext, range),\n billingAccountId\n ? fetchAdminPayoutRequests(requestContext, {\n limit: 100,\n filter: { billingAccountId, ...range },\n })\n : Promise.resolve({ items: [], totalCount: 0, hasMore: false }),\n ]);\n setDetail(detailResult);\n setPayoutHistory(payoutsResult.items);\n },\n [requestContext]\n );\n\n const load = useCallback(async () => {\n if (!organizationId) return;\n setLoading(true);\n setError(null);\n try {\n const [orgResult, monthlyResult] = await Promise.all([\n fetchAdminDeveloperRevenueOrg(organizationId, requestContext),\n fetchAdminDeveloperRevenueOrgMonthly(organizationId, requestContext, 12),\n ]);\n setOrg(orgResult);\n setMonthly(monthlyResult);\n\n const billingAccountId = orgResult?.billingAccountId ?? null;\n const defaultMonth =\n monthlyResult.length > 0 ? monthlyResult[monthlyResult.length - 1].month : ALL_TIME;\n setSelectedMonth(defaultMonth);\n\n const [balanceResult, lifetimeResult] = await Promise.all([\n billingAccountId\n ? fetchBillingAccountCreditBalance(billingAccountId, requestContext)\n : Promise.resolve(null),\n billingAccountId\n ? fetchAdminPayoutRequests(requestContext, { limit: 100, filter: { billingAccountId } })\n : Promise.resolve({ items: [], totalCount: 0, hasMore: false }),\n loadPeriod(organizationId, billingAccountId, defaultMonth),\n ]);\n setCreditBalance(balanceResult);\n setLifetimePayouts(lifetimeResult.items);\n\n if (balanceResult && balanceResult.total > 0) {\n fetchCreditCost(balanceResult.total, 'USD', requestContext)\n .then(setCreditBalanceUsd)\n .catch(() => setCreditBalanceUsd(null));\n } else {\n setCreditBalanceUsd(0);\n }\n } catch (loadError) {\n setError(loadError instanceof Error ? loadError : new Error('Failed to load revenue detail'));\n } finally {\n setLoading(false);\n }\n }, [organizationId, requestContext, loadPeriod]);\n\n useEffect(() => {\n if (!permissions.isBillingAdmin) return;\n void load();\n }, [load, permissions.isBillingAdmin]);\n\n const handleMonthChange = (month: string) => {\n if (!organizationId || !org) return;\n setSelectedMonth(month);\n setPeriodLoading(true);\n void loadPeriod(organizationId, org.billingAccountId, month)\n .catch((loadError) => {\n setError(loadError instanceof Error ? loadError : new Error('Failed to load period data'));\n })\n .finally(() => setPeriodLoading(false));\n };\n\n if (!permissions.isBillingAdmin) {\n return <AccessDenied message=\"You don't have permission to view developer revenue.\" />;\n }\n\n if (error && isServerError(error)) {\n return (\n <ServerError\n title=\"Developer revenue unavailable\"\n message={error.message}\n showRetry\n onRetry={() => void load()}\n />\n );\n }\n\n if (loading || !org) {\n return (\n <div className=\"flex items-center justify-center py-20 text-text-secondary\">\n <Loader2 className=\"size-8 animate-spin\" />\n </div>\n );\n }\n\n const withdrawn = lifetimePayouts\n .filter((request) => request.status === 'PAID')\n .reduce((sum, request) => sum + (request.approvedAmount ?? request.requestedAmount), 0);\n const inFlight = lifetimePayouts\n .filter((request) => ['REQUESTED', 'APPROVED', 'PROCESSING'].includes(request.status))\n .reduce((sum, request) => sum + request.requestedAmount, 0);\n\n // Most-recent-first for the dropdown; `monthly` itself stays ascending\n // (oldest first) since that's what the trend table's MoM math needs.\n const monthOptions = [...monthly].reverse();\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title={org.name}\n description={`/${org.slug}${org.isVerified ? ' · Verified developer organization' : ''}`}\n actions={\n <button\n type=\"button\"\n onClick={() => navigateTo('/developer-revenue')}\n className=\"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 <ArrowLeft className=\"size-4\" />\n Back to developer revenue\n </button>\n }\n />\n\n <PagePurpose>\n Store revenue for this org is credited into its linked billing account as earned credits.\n The developer withdraws those credits later through their own billing withdrawal flow — this\n page is a read-and-verify view of that whole loop, from sale to payout.\n </PagePurpose>\n\n <div className=\"grid gap-3 md:grid-cols-2 xl:grid-cols-4\">\n <StatCard\n label=\"Gross revenue (all time)\"\n value={formatCurrency(org.totalRevenue, 'USD')}\n icon={<TrendingUp className=\"size-4\" />}\n />\n <StatCard\n label=\"Platform fees (all time)\"\n value={formatCurrency(org.totalPlatformFees, 'USD')}\n icon={<CreditCard className=\"size-4\" />}\n />\n <StatCard\n label=\"Pending earned credits\"\n value={formatCurrency(detail?.summary?.pendingBalance ?? org.pendingBalance, 'USD')}\n icon={<Wallet className=\"size-4\" />}\n />\n <StatCard\n label=\"Already withdrawn (all time)\"\n value={formatCurrency(withdrawn, 'USD')}\n icon={<BadgeCheck className=\"size-4\" />}\n />\n </div>\n\n <section className=\"overflow-hidden rounded-card border border-border-seam bg-bg-surface shadow-[var(--shadow-elevation-1)]\">\n <div className=\"border-b border-border-seam px-5 py-4\">\n <h2 className=\"text-base font-semibold text-text-primary\">Billing account balance</h2>\n <p className=\"mt-1 text-sm text-text-muted\">\n The current credit ledger on the org's linked billing account, right now. These are\n credit units, not currency — 1 credit is worth a small fraction of $1 at the\n platform's current credit rate.\n </p>\n </div>\n {!org.billingAccountId ? (\n <div className=\"px-5 py-8 text-center text-sm text-text-muted\">\n No billing account is linked yet — revenue cannot be credited until this org links one.\n </div>\n ) : !creditBalance ? (\n <div className=\"px-5 py-8 text-center text-sm text-text-muted\">\n Credit balance could not be loaded.\n </div>\n ) : (\n <>\n <div className=\"grid gap-3 p-5 md:grid-cols-3 xl:grid-cols-5\">\n <StatCard label=\"Earned\" value={formatCredits(creditBalance.earned)} />\n <StatCard label=\"Purchased\" value={formatCredits(creditBalance.purchased)} />\n <StatCard label=\"Granted\" value={formatCredits(creditBalance.granted)} />\n <StatCard label=\"Withdrawable\" value={formatCredits(creditBalance.withdrawable)} />\n <StatCard label=\"Total balance\" value={formatCredits(creditBalance.total)} />\n </div>\n <div className=\"px-5 pb-4 text-xs text-text-muted\">\n {creditBalanceUsd === null\n ? 'Estimated cash value could not be loaded.'\n : `≈ ${formatCurrency(creditBalanceUsd, 'USD')} total at the current credit rate.`}\n </div>\n </>\n )}\n {inFlight > 0 && (\n <div className=\"border-t border-border-seam bg-status-warning-bg-subtle px-5 py-3 text-xs text-status-warning-text\">\n {formatCurrency(inFlight, 'USD')} is currently tied up in a pending or approved\n withdrawal request — it has already left the withdrawable balance above.\n </div>\n )}\n </section>\n\n <section className=\"overflow-hidden rounded-card border border-border-seam bg-bg-surface shadow-[var(--shadow-elevation-1)]\">\n <div className=\"border-b border-border-seam px-5 py-4\">\n <h2 className=\"text-base font-semibold text-text-primary\">Monthly revenue trend</h2>\n <p className=\"mt-1 text-sm text-text-muted\">\n Last 12 months of gross/net revenue for this org, computed from completed sales.\n </p>\n </div>\n <MonthlyRevenueTrend points={monthly} />\n </section>\n\n <div className=\"flex flex-wrap items-center justify-between gap-3 rounded-card border border-border-seam bg-bg-surface px-5 py-4 shadow-[var(--shadow-elevation-1)]\">\n <div>\n <h2 className=\"text-sm font-semibold text-text-primary\">Viewing activity for</h2>\n <p className=\"mt-1 text-xs text-text-muted\">\n Scopes both the withdrawal history and sales tables below — pick a single month to keep\n long-running orgs easy to review, or switch to all time.\n </p>\n </div>\n <div className=\"flex items-center gap-2\">\n {periodLoading && <Loader2 className=\"size-4 animate-spin text-text-muted\" />}\n <select\n value={selectedMonth}\n onChange={(event) => handleMonthChange(event.target.value)}\n disabled={periodLoading}\n className=\"rounded-md border border-border-subtle bg-bg-surface scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary px-3 py-2 text-sm text-text-primary disabled:opacity-50\"\n >\n <option value={ALL_TIME}>All time</option>\n {monthOptions.map((point) => (\n <option key={point.month} value={point.month}>\n {formatMonthLabel(point.month)}\n </option>\n ))}\n </select>\n </div>\n </div>\n\n <section className=\"overflow-hidden rounded-card border border-border-seam bg-bg-surface shadow-[var(--shadow-elevation-1)]\">\n <div className=\"border-b border-border-seam px-5 py-4\">\n <h2 className=\"text-base font-semibold text-text-primary\">Withdrawal history</h2>\n <p className=\"mt-1 text-sm text-text-muted\">\n Payout requests this org made in{' '}\n {selectedMonth === ALL_TIME ? 'all time' : formatMonthLabel(selectedMonth)} — both\n revenue-share credit conversions and cash payouts — with current status.\n </p>\n </div>\n <div className={periodLoading ? 'pointer-events-none opacity-50' : undefined}>\n <WithdrawalHistory requests={payoutHistory} />\n </div>\n </section>\n\n <section className=\"overflow-hidden rounded-card border border-border-seam bg-bg-surface shadow-[var(--shadow-elevation-1)]\">\n <div className=\"border-b border-border-seam px-5 py-4\">\n <h2 className=\"text-base font-semibold text-text-primary\">\n Sales currently contributing to earned credits\n </h2>\n <p className=\"mt-1 text-xs text-text-muted\">\n Unpaid sales purchased in{' '}\n {selectedMonth === ALL_TIME ? 'all time' : formatMonthLabel(selectedMonth)} that should\n exist as earned credits in the linked billing account until the developer withdraws\n them.\n </p>\n </div>\n <div className={`overflow-x-auto ${periodLoading ? 'pointer-events-none opacity-50' : ''}`}>\n <table className=\"min-w-full text-sm\">\n <thead className=\"bg-bg-sunken/60 text-left text-xs uppercase tracking-wide text-text-muted\">\n <tr>\n <th className=\"px-4 py-3\">Application</th>\n <th className=\"px-4 py-3\">Purchased</th>\n <th className=\"px-4 py-3\">Net revenue</th>\n <th className=\"px-4 py-3\">Credit sync</th>\n <th className=\"px-4 py-3\">Status</th>\n </tr>\n </thead>\n <tbody>\n {!detail || detail.unpaidSales.items.length === 0 ? (\n <tr>\n <td colSpan={5} className=\"px-4 py-8 text-center text-sm text-text-muted\">\n No outstanding unpaid sales in this period.\n </td>\n </tr>\n ) : (\n detail.unpaidSales.items.map((sale) => (\n <tr key={sale.id} className=\"border-t border-border-seam\">\n <td className=\"px-4 py-3\">\n <div className=\"font-medium text-text-primary\">\n {sale.application?.name ?? 'Unknown app'}\n </div>\n <div className=\"text-xs text-text-muted\">\n /{sale.application?.slug ?? 'unknown'}\n </div>\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">\n {formatDateTime(sale.purchasedAt)}\n </td>\n <td className=\"px-4 py-3 text-text-primary\">\n {formatCurrency(sale.netAmount, sale.currency)}\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">\n <div>{sale.billingCreditSyncStatus ?? 'UNKNOWN'}</div>\n {sale.billingCreditSyncError && (\n <div className=\"mt-1 text-xs text-status-error-text\">\n {sale.billingCreditSyncError}\n </div>\n )}\n {sale.billingCreditSyncStatus !== 'SYNCED' && org.billingAccountId && (\n <button\n type=\"button\"\n onClick={() => {\n if (!organizationId) return;\n void (async () => {\n setRetryingSaleId(sale.id);\n try {\n await retrySaleCreditSync(sale.id, requestContext);\n await loadPeriod(\n organizationId,\n org.billingAccountId,\n selectedMonth\n );\n } finally {\n setRetryingSaleId(null);\n }\n })();\n }}\n disabled={retryingSaleId === sale.id}\n className=\"mt-2 rounded-md border border-border-subtle px-2 py-1 text-xs font-medium text-text-primary disabled:opacity-50\"\n >\n {retryingSaleId === sale.id ? 'Retrying…' : 'Retry sync'}\n </button>\n )}\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">{sale.status}</td>\n </tr>\n ))\n )}\n </tbody>\n </table>\n </div>\n </section>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsCA,IAAME,IAAW,OAEXC,IAA8C;CAClD,WAAW;CACX,UAAU;CACV,UAAU;CACV,YAAY;CACZ,MAAM;CACN,QAAQ;CACR,UAAU;AACZ,GAEMC,IAA+C;CACnD,WAAW;CACX,UAAU;CACV,UAAU;CACV,YAAY;CACZ,MAAM;CACN,QAAQ;CACR,UAAU;AACZ;AAEA,SAASC,EAAkB,EAAE,aAA8B;CACzD,OACE,kBAAC,QAAD;EACE,WAAW,2EAA2ED,EAAqBE,MAAW;EAErH,UAAAH,EAAoBG,MAAWA;CAC5B,CAAA;AAEV;AAEA,SAASC,EAAiB,GAAqB;CAC7C,OAAO,IAAI,KAAKC,CAAG,CAAC,CAAC,mBAAmB,SAAS;EAAE,OAAO;EAAS,MAAM;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PAYOUT_STATUS_LABEL","PAYOUT_STATUS_COLORS","PayoutStatusBadge","status","formatMonthLabel","iso","monthRangeFor","month","start","MonthlyRevenueTrend","points","prior","index","growthPct","point","formatCurrency","jsx","TrendingUp","TrendingDown","WithdrawalHistory","requests","formatDateTime","request","DeveloperRevenueOrgDetailPage","useParams","permissions","useBillingPermissions","useBilling","navigateTo","useBillingNavigate","org","setOrg","useState","monthly","setMonthly","creditBalance","setCreditBalance","creditBalanceUsd","setCreditBalanceUsd","lifetimePayouts","setLifetimePayouts","detail","setDetail","payoutHistory","setPayoutHistory","selectedMonth","setSelectedMonth","loading","setLoading","periodLoading","setPeriodLoading","error","setError","retryingSaleId","setRetryingSaleId","requestContext","useMemo","apiGatewayUrl","authToken","orgId","loadPeriod","useCallback","range","detailResult","payoutsResult","fetchAdminDeveloperRevenueOrgDetail","organizationIdValue","billingAccountId","fetchAdminPayoutRequests","load","organizationId","orgResult","monthlyResult","fetchAdminDeveloperRevenueOrg","fetchAdminDeveloperRevenueOrgMonthly","defaultMonth","balanceResult","lifetimeResult","fetchBillingAccountCreditBalance","fetchCreditCost","loadError","handleMonthChange","AccessDenied","isServerError","ServerError","Loader2","withdrawn","sum","inFlight","monthOptions","PageHeader","ArrowLeft","PagePurpose","StatCard","CreditCard","Wallet","BadgeCheck","formatCredits","event","sale","retrySaleCreditSync"],"sources":["../../../../../src/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState, type FC } from 'react';\nimport { useParams } from 'react-router';\nimport {\n ArrowLeft,\n BadgeCheck,\n CreditCard,\n Loader2,\n TrendingDown,\n TrendingUp,\n Wallet,\n} from 'lucide-react';\n\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { AccessDenied, PageHeader, ServerError, StatCard } from '../../../shared/components';\nimport { PagePurpose } from '@burdenoff/fe-libs/ui';\nimport {\n formatCredits,\n formatCurrency,\n formatDateTime,\n isServerError,\n} from '../../../shared/utils';\nimport {\n fetchAdminDeveloperRevenueOrg,\n fetchAdminDeveloperRevenueOrgDetail,\n fetchAdminDeveloperRevenueOrgMonthly,\n fetchAdminPayoutRequests,\n fetchBillingAccountCreditBalance,\n fetchCreditCost,\n retrySaleCreditSync,\n type AdminDeveloperRevenueOrg,\n type AdminDeveloperRevenueOrgDetail,\n type CreditBalanceByType,\n type DeveloperOrgMonthlyRevenuePoint,\n type PayoutRequest,\n} from '../api';\n\nconst ALL_TIME = 'all';\n\nconst PAYOUT_STATUS_LABEL: Record<string, string> = {\n REQUESTED: 'Requested',\n APPROVED: 'Approved',\n REJECTED: 'Rejected',\n PROCESSING: 'Processing',\n PAID: 'Paid',\n FAILED: 'Failed',\n CANCELED: 'Canceled',\n};\n\nconst PAYOUT_STATUS_COLORS: Record<string, string> = {\n REQUESTED: 'bg-status-warning-bg-subtle text-status-warning-text',\n APPROVED: 'bg-status-info-bg-subtle text-status-info-text',\n REJECTED: 'bg-status-error-bg-subtle text-status-error-text',\n PROCESSING: 'bg-status-info-bg-subtle text-status-info-text',\n PAID: 'bg-status-success-bg-subtle text-status-success-text',\n FAILED: 'bg-status-error-bg-subtle text-status-error-text',\n CANCELED: 'bg-bg-sunken text-text-muted',\n};\n\nfunction PayoutStatusBadge({ status }: { status: string }) {\n return (\n <span\n className={`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${PAYOUT_STATUS_COLORS[status] ?? 'bg-bg-sunken text-text-muted'}`}\n >\n {PAYOUT_STATUS_LABEL[status] ?? status}\n </span>\n );\n}\n\nfunction formatMonthLabel(iso: string): string {\n return new Date(iso).toLocaleDateString('en-US', { month: 'short', year: 'numeric' });\n}\n\n/**\n * Turns a month-start ISO string (as returned by developerOrgMonthlyRevenue,\n * always the first instant of a calendar month) into a [startDate, endDate]\n * range covering that whole month, for scoping the sales/withdrawal queries.\n * ALL_TIME returns an empty range (no filtering).\n */\nfunction monthRangeFor(month: string): { startDate?: string; endDate?: string } {\n if (month === ALL_TIME) return {};\n const start = new Date(month);\n if (Number.isNaN(start.getTime())) return {};\n const startDate = new Date(\n Date.UTC(start.getUTCFullYear(), start.getUTCMonth(), 1)\n ).toISOString();\n const endDate = new Date(\n Date.UTC(start.getUTCFullYear(), start.getUTCMonth() + 1, 1) - 1\n ).toISOString();\n return { startDate, endDate };\n}\n\nfunction MonthlyRevenueTrend({ points }: { points: DeveloperOrgMonthlyRevenuePoint[] }) {\n if (points.length === 0) {\n return (\n <div className=\"px-5 py-10 text-center text-sm text-text-muted\">\n No sales recorded yet — the revenue trend will appear once the first sale comes in.\n </div>\n );\n }\n\n return (\n <div className=\"overflow-x-auto\">\n <table className=\"min-w-full text-sm\">\n <thead className=\"bg-bg-sunken/60 text-left text-xs uppercase tracking-wide text-text-muted\">\n <tr>\n <th className=\"px-4 py-3\">Month</th>\n <th className=\"px-4 py-3\">Gross revenue</th>\n <th className=\"px-4 py-3\">Platform fee</th>\n <th className=\"px-4 py-3\">Net revenue</th>\n <th className=\"px-4 py-3\">Sales</th>\n <th className=\"px-4 py-3\">Growth (MoM)</th>\n </tr>\n </thead>\n <tbody>\n {points.map((point, index) => {\n const prior = index > 0 ? points[index - 1] : null;\n const growthPct =\n prior && prior.grossRevenue > 0\n ? ((point.grossRevenue - prior.grossRevenue) / prior.grossRevenue) * 100\n : null;\n\n return (\n <tr key={point.month} className=\"border-t border-border-seam\">\n <td className=\"px-4 py-3 font-medium text-text-primary\">\n {formatMonthLabel(point.month)}\n </td>\n <td className=\"px-4 py-3 text-text-primary\">\n {formatCurrency(point.grossRevenue, 'USD')}\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">\n {formatCurrency(point.platformFees, 'USD')}\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">\n {formatCurrency(point.netRevenue, 'USD')}\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">{point.salesCount}</td>\n <td className=\"px-4 py-3\">\n {growthPct === null ? (\n <span className=\"text-text-muted\">—</span>\n ) : (\n <span\n className={`inline-flex items-center gap-1 font-medium ${\n growthPct >= 0 ? 'text-status-success-text' : 'text-status-error-text'\n }`}\n >\n {growthPct >= 0 ? (\n <TrendingUp className=\"size-3.5\" />\n ) : (\n <TrendingDown className=\"size-3.5\" />\n )}\n {growthPct >= 0 ? '+' : ''}\n {growthPct.toFixed(1)}%\n </span>\n )}\n </td>\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n}\n\nfunction WithdrawalHistory({ requests }: { requests: PayoutRequest[] }) {\n if (requests.length === 0) {\n return (\n <div className=\"px-5 py-10 text-center text-sm text-text-muted\">\n No withdrawal requests in this period.\n </div>\n );\n }\n\n return (\n <div className=\"overflow-x-auto\">\n <table className=\"min-w-full text-sm\">\n <thead className=\"bg-bg-sunken/60 text-left text-xs uppercase tracking-wide text-text-muted\">\n <tr>\n <th className=\"px-4 py-3\">Requested</th>\n <th className=\"px-4 py-3\">Kind</th>\n <th className=\"px-4 py-3\">Amount</th>\n <th className=\"px-4 py-3\">Status</th>\n <th className=\"px-4 py-3\">Paid</th>\n <th className=\"px-4 py-3\">Notes</th>\n </tr>\n </thead>\n <tbody>\n {requests.map((request) => (\n <tr key={request.id} className=\"border-t border-border-seam\">\n <td className=\"px-4 py-3 text-text-secondary\">{formatDateTime(request.createdAt)}</td>\n <td className=\"px-4 py-3 text-text-secondary\">\n {request.requestKind === 'CREDIT_CONVERSION'\n ? 'Revenue-share credits'\n : 'Cash payout'}\n </td>\n <td className=\"px-4 py-3 font-medium text-text-primary\">\n {formatCurrency(request.requestedAmount, request.currency)}\n </td>\n <td className=\"px-4 py-3\">\n <PayoutStatusBadge status={request.status} />\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">\n {request.paidAt ? formatDateTime(request.paidAt) : '—'}\n </td>\n <td className=\"px-4 py-3 text-text-muted\">\n {request.failureReason || request.userNotes || '—'}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n}\n\nexport const DeveloperRevenueOrgDetailPage: FC = () => {\n const { organizationId } = useParams<{ organizationId: string }>();\n const permissions = useBillingPermissions();\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n const navigateTo = useBillingNavigate();\n\n const [org, setOrg] = useState<AdminDeveloperRevenueOrg | null>(null);\n const [monthly, setMonthly] = useState<DeveloperOrgMonthlyRevenuePoint[]>([]);\n const [creditBalance, setCreditBalance] = useState<CreditBalanceByType | null>(null);\n const [creditBalanceUsd, setCreditBalanceUsd] = useState<number | null>(null);\n // Lifetime (unscoped) withdrawal history — drives the \"Already withdrawn\" /\n // in-flight totals up top, which must stay accurate regardless of which\n // month the tables below are currently scoped to.\n const [lifetimePayouts, setLifetimePayouts] = useState<PayoutRequest[]>([]);\n // Period-scoped data — re-fetched whenever selectedMonth changes.\n const [detail, setDetail] = useState<AdminDeveloperRevenueOrgDetail | null>(null);\n const [payoutHistory, setPayoutHistory] = useState<PayoutRequest[]>([]);\n const [selectedMonth, setSelectedMonth] = useState<string>(ALL_TIME);\n\n const [loading, setLoading] = useState(true);\n const [periodLoading, setPeriodLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [retryingSaleId, setRetryingSaleId] = useState<string | null>(null);\n\n const requestContext = useMemo(\n () => ({ apiGatewayUrl, authToken, orgId }),\n [apiGatewayUrl, authToken, orgId]\n );\n\n const loadPeriod = useCallback(\n async (\n organizationIdValue: string,\n billingAccountId: string | null | undefined,\n month: string\n ) => {\n const range = monthRangeFor(month);\n const [detailResult, payoutsResult] = await Promise.all([\n fetchAdminDeveloperRevenueOrgDetail(organizationIdValue, requestContext, range),\n billingAccountId\n ? fetchAdminPayoutRequests(requestContext, {\n limit: 100,\n filter: { billingAccountId, ...range },\n })\n : Promise.resolve({ items: [], totalCount: 0, hasMore: false }),\n ]);\n setDetail(detailResult);\n setPayoutHistory(payoutsResult.items);\n },\n [requestContext]\n );\n\n const load = useCallback(async () => {\n if (!organizationId) return;\n setLoading(true);\n setError(null);\n try {\n const [orgResult, monthlyResult] = await Promise.all([\n fetchAdminDeveloperRevenueOrg(organizationId, requestContext),\n fetchAdminDeveloperRevenueOrgMonthly(organizationId, requestContext, 12),\n ]);\n setOrg(orgResult);\n setMonthly(monthlyResult);\n\n const billingAccountId = orgResult?.billingAccountId ?? null;\n const defaultMonth =\n monthlyResult.length > 0 ? monthlyResult[monthlyResult.length - 1].month : ALL_TIME;\n setSelectedMonth(defaultMonth);\n\n const [balanceResult, lifetimeResult] = await Promise.all([\n billingAccountId\n ? fetchBillingAccountCreditBalance(billingAccountId, requestContext)\n : Promise.resolve(null),\n billingAccountId\n ? fetchAdminPayoutRequests(requestContext, { limit: 100, filter: { billingAccountId } })\n : Promise.resolve({ items: [], totalCount: 0, hasMore: false }),\n loadPeriod(organizationId, billingAccountId, defaultMonth),\n ]);\n setCreditBalance(balanceResult);\n setLifetimePayouts(lifetimeResult.items);\n\n if (balanceResult && balanceResult.total > 0) {\n fetchCreditCost(balanceResult.total, 'USD', requestContext)\n .then(setCreditBalanceUsd)\n .catch(() => setCreditBalanceUsd(null));\n } else {\n setCreditBalanceUsd(0);\n }\n } catch (loadError) {\n setError(loadError instanceof Error ? loadError : new Error('Failed to load revenue detail'));\n } finally {\n setLoading(false);\n }\n }, [organizationId, requestContext, loadPeriod]);\n\n useEffect(() => {\n if (!permissions.isBillingAdmin) return;\n void load();\n }, [load, permissions.isBillingAdmin]);\n\n const handleMonthChange = (month: string) => {\n if (!organizationId || !org) return;\n setSelectedMonth(month);\n setPeriodLoading(true);\n void loadPeriod(organizationId, org.billingAccountId, month)\n .catch((loadError) => {\n setError(loadError instanceof Error ? loadError : new Error('Failed to load period data'));\n })\n .finally(() => setPeriodLoading(false));\n };\n\n if (!permissions.isBillingAdmin) {\n return <AccessDenied message=\"You don't have permission to view developer revenue.\" />;\n }\n\n if (error && isServerError(error)) {\n return (\n <ServerError\n title=\"Developer revenue unavailable\"\n message={error.message}\n showRetry\n onRetry={() => void load()}\n />\n );\n }\n\n if (loading || !org) {\n return (\n <div className=\"flex items-center justify-center py-20 text-text-secondary\">\n <Loader2 className=\"size-8 animate-spin\" />\n </div>\n );\n }\n\n const withdrawn = lifetimePayouts\n .filter((request) => request.status === 'PAID')\n .reduce((sum, request) => sum + (request.approvedAmount ?? request.requestedAmount), 0);\n const inFlight = lifetimePayouts\n .filter((request) => ['REQUESTED', 'APPROVED', 'PROCESSING'].includes(request.status))\n .reduce((sum, request) => sum + request.requestedAmount, 0);\n\n // Most-recent-first for the dropdown; `monthly` itself stays ascending\n // (oldest first) since that's what the trend table's MoM math needs.\n const monthOptions = [...monthly].reverse();\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title={org.name}\n description={`/${org.slug}${org.isVerified ? ' · Verified developer organization' : ''}`}\n actions={\n <button\n type=\"button\"\n onClick={() => navigateTo('/developer-revenue')}\n className=\"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 <ArrowLeft className=\"size-4\" />\n Back to developer revenue\n </button>\n }\n />\n\n <PagePurpose>\n Store revenue for this org is credited into its linked billing account as earned credits.\n The developer withdraws those credits later through their own billing withdrawal flow — this\n page is a read-and-verify view of that whole loop, from sale to payout.\n </PagePurpose>\n\n <div className=\"grid gap-3 md:grid-cols-2 xl:grid-cols-4\">\n <StatCard\n label=\"Gross revenue (all time)\"\n value={formatCurrency(org.totalRevenue, 'USD')}\n icon={<TrendingUp className=\"size-4\" />}\n />\n <StatCard\n label=\"Platform fees (all time)\"\n value={formatCurrency(org.totalPlatformFees, 'USD')}\n icon={<CreditCard className=\"size-4\" />}\n />\n <StatCard\n label=\"Pending earned credits\"\n value={formatCurrency(detail?.summary?.pendingBalance ?? org.pendingBalance, 'USD')}\n icon={<Wallet className=\"size-4\" />}\n />\n <StatCard\n label=\"Already withdrawn (all time)\"\n value={formatCurrency(withdrawn, 'USD')}\n icon={<BadgeCheck className=\"size-4\" />}\n />\n </div>\n\n <section className=\"overflow-hidden rounded-card border border-border-seam bg-bg-surface shadow-[var(--shadow-elevation-1)]\">\n <div className=\"border-b border-border-seam px-5 py-4\">\n <h2 className=\"text-base font-semibold text-text-primary\">Billing account balance</h2>\n <p className=\"mt-1 text-sm text-text-muted\">\n The current credit ledger on the org's linked billing account, right now. These are\n credit units, not currency — 1 credit is worth a small fraction of $1 at the\n platform's current credit rate.\n </p>\n </div>\n {!org.billingAccountId ? (\n <div className=\"px-5 py-8 text-center text-sm text-text-muted\">\n No billing account is linked yet — revenue cannot be credited until this org links one.\n </div>\n ) : !creditBalance ? (\n <div className=\"px-5 py-8 text-center text-sm text-text-muted\">\n Credit balance could not be loaded.\n </div>\n ) : (\n <>\n <div className=\"grid gap-3 p-5 md:grid-cols-3 xl:grid-cols-5\">\n <StatCard label=\"Earned\" value={formatCredits(creditBalance.earned)} />\n <StatCard label=\"Purchased\" value={formatCredits(creditBalance.purchased)} />\n <StatCard label=\"Granted\" value={formatCredits(creditBalance.granted)} />\n <StatCard label=\"Withdrawable\" value={formatCredits(creditBalance.withdrawable)} />\n <StatCard label=\"Total balance\" value={formatCredits(creditBalance.total)} />\n </div>\n <div className=\"px-5 pb-4 text-xs text-text-muted\">\n {creditBalanceUsd === null\n ? 'Estimated cash value could not be loaded.'\n : `≈ ${formatCurrency(creditBalanceUsd, 'USD')} total at the current credit rate.`}\n </div>\n </>\n )}\n {inFlight > 0 && (\n <div className=\"border-t border-border-seam bg-status-warning-bg-subtle px-5 py-3 text-xs text-status-warning-text\">\n {formatCurrency(inFlight, 'USD')} is currently tied up in a pending or approved\n withdrawal request — it has already left the withdrawable balance above.\n </div>\n )}\n </section>\n\n <section className=\"overflow-hidden rounded-card border border-border-seam bg-bg-surface shadow-[var(--shadow-elevation-1)]\">\n <div className=\"border-b border-border-seam px-5 py-4\">\n <h2 className=\"text-base font-semibold text-text-primary\">Monthly revenue trend</h2>\n <p className=\"mt-1 text-sm text-text-muted\">\n Last 12 months of gross/net revenue for this org, computed from completed sales.\n </p>\n </div>\n <MonthlyRevenueTrend points={monthly} />\n </section>\n\n <div className=\"flex flex-wrap items-center justify-between gap-3 rounded-card border border-border-seam bg-bg-surface px-5 py-4 shadow-[var(--shadow-elevation-1)]\">\n <div>\n <h2 className=\"text-sm font-semibold text-text-primary\">Viewing activity for</h2>\n <p className=\"mt-1 text-xs text-text-muted\">\n Scopes both the withdrawal history and sales tables below — pick a single month to keep\n long-running orgs easy to review, or switch to all time.\n </p>\n </div>\n <div className=\"flex items-center gap-2\">\n {periodLoading && <Loader2 className=\"size-4 animate-spin text-text-muted\" />}\n <select\n value={selectedMonth}\n onChange={(event) => handleMonthChange(event.target.value)}\n disabled={periodLoading}\n className=\"rounded-md border border-border-subtle bg-bg-surface scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary px-3 py-2 text-sm text-text-primary disabled:opacity-50\"\n >\n <option value={ALL_TIME}>All time</option>\n {monthOptions.map((point) => (\n <option key={point.month} value={point.month}>\n {formatMonthLabel(point.month)}\n </option>\n ))}\n </select>\n </div>\n </div>\n\n <section className=\"overflow-hidden rounded-card border border-border-seam bg-bg-surface shadow-[var(--shadow-elevation-1)]\">\n <div className=\"border-b border-border-seam px-5 py-4\">\n <h2 className=\"text-base font-semibold text-text-primary\">Withdrawal history</h2>\n <p className=\"mt-1 text-sm text-text-muted\">\n Payout requests this org made in{' '}\n {selectedMonth === ALL_TIME ? 'all time' : formatMonthLabel(selectedMonth)} — both\n revenue-share credit conversions and cash payouts — with current status.\n </p>\n </div>\n <div className={periodLoading ? 'pointer-events-none opacity-50' : undefined}>\n <WithdrawalHistory requests={payoutHistory} />\n </div>\n </section>\n\n <section className=\"overflow-hidden rounded-card border border-border-seam bg-bg-surface shadow-[var(--shadow-elevation-1)]\">\n <div className=\"border-b border-border-seam px-5 py-4\">\n <h2 className=\"text-base font-semibold text-text-primary\">\n Sales currently contributing to earned credits\n </h2>\n <p className=\"mt-1 text-xs text-text-muted\">\n Unpaid sales purchased in{' '}\n {selectedMonth === ALL_TIME ? 'all time' : formatMonthLabel(selectedMonth)} that should\n exist as earned credits in the linked billing account until the developer withdraws\n them.\n </p>\n </div>\n <div className={`overflow-x-auto ${periodLoading ? 'pointer-events-none opacity-50' : ''}`}>\n <table className=\"min-w-full text-sm\">\n <thead className=\"bg-bg-sunken/60 text-left text-xs uppercase tracking-wide text-text-muted\">\n <tr>\n <th className=\"px-4 py-3\">Application</th>\n <th className=\"px-4 py-3\">Purchased</th>\n <th className=\"px-4 py-3\">Net revenue</th>\n <th className=\"px-4 py-3\">Credit sync</th>\n <th className=\"px-4 py-3\">Status</th>\n </tr>\n </thead>\n <tbody>\n {!detail || detail.unpaidSales.items.length === 0 ? (\n <tr>\n <td colSpan={5} className=\"px-4 py-8 text-center text-sm text-text-muted\">\n No outstanding unpaid sales in this period.\n </td>\n </tr>\n ) : (\n detail.unpaidSales.items.map((sale) => (\n <tr key={sale.id} className=\"border-t border-border-seam\">\n <td className=\"px-4 py-3\">\n <div className=\"font-medium text-text-primary\">\n {sale.application?.name ?? 'Unknown app'}\n </div>\n <div className=\"text-xs text-text-muted\">\n /{sale.application?.slug ?? 'unknown'}\n </div>\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">\n {formatDateTime(sale.purchasedAt)}\n </td>\n <td className=\"px-4 py-3 text-text-primary\">\n {formatCurrency(sale.netAmount, sale.currency)}\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">\n <div>{sale.billingCreditSyncStatus ?? 'UNKNOWN'}</div>\n {sale.billingCreditSyncError && (\n <div className=\"mt-1 text-xs text-status-error-text\">\n {sale.billingCreditSyncError}\n </div>\n )}\n {sale.billingCreditSyncStatus !== 'SYNCED' && org.billingAccountId && (\n <button\n type=\"button\"\n onClick={() => {\n if (!organizationId) return;\n void (async () => {\n setRetryingSaleId(sale.id);\n try {\n await retrySaleCreditSync(sale.id, requestContext);\n await loadPeriod(\n organizationId,\n org.billingAccountId,\n selectedMonth\n );\n } finally {\n setRetryingSaleId(null);\n }\n })();\n }}\n disabled={retryingSaleId === sale.id}\n className=\"mt-2 rounded-md border border-border-subtle px-2 py-1 text-xs font-medium text-text-primary disabled:opacity-50\"\n >\n {retryingSaleId === sale.id ? 'Retrying…' : 'Retry sync'}\n </button>\n )}\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">{sale.status}</td>\n </tr>\n ))\n )}\n </tbody>\n </table>\n </div>\n </section>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsCA,IAAME,IAAW,OAEXC,IAA8C;CAClD,WAAW;CACX,UAAU;CACV,UAAU;CACV,YAAY;CACZ,MAAM;CACN,QAAQ;CACR,UAAU;AACZ,GAEMC,IAA+C;CACnD,WAAW;CACX,UAAU;CACV,UAAU;CACV,YAAY;CACZ,MAAM;CACN,QAAQ;CACR,UAAU;AACZ;AAEA,SAASC,EAAkB,EAAE,aAA8B;CACzD,OACE,kBAAC,QAAD;EACE,WAAW,2EAA2ED,EAAqBE,MAAW;EAErH,UAAAH,EAAoBG,MAAWA;CAC5B,CAAA;AAEV;AAEA,SAASC,EAAiB,GAAqB;CAC7C,OAAO,IAAI,KAAKC,CAAG,CAAC,CAAC,mBAAmB,SAAS;EAAE,OAAO;EAAS,MAAM;CAAU,CAAC;AACtF;AAQA,SAASC,GAAc,GAAyD;CAC9E,IAAIC,MAAUR,GAAU,OAAO,CAAC;CAChC,IAAMS,IAAQ,IAAI,KAAKD,CAAK;CAQ5B,OAPI,OAAO,MAAMC,EAAM,QAAQ,CAAC,IAAU,CAAC,IAOpC;EAAE,WANS,IAAI,KACpB,KAAK,IAAIA,EAAM,eAAe,GAAGA,EAAM,YAAY,GAAG,CAAC,CACzD,CAAC,CAAC,YAIO;EAAW,0BAHJ,IAAI,KAClB,KAAK,IAAIA,EAAM,eAAe,GAAGA,EAAM,YAAY,IAAI,GAAG,CAAC,IAAI,CACjE,EAAA,CAAE,YACkB;CAAQ;AAC9B;AAEA,SAASC,GAAoB,EAAE,aAAyD;CAStF,OARIC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AAd,UAAA;UACE,kBAAC,OAAD,EAAA,UAAMA,EAAK,2BAA2B,UAAe,CAAA;UACpDA,EAAK,0BACJ,kBAAC,OAAD;WAAK,WAAU;WACZ,UAAAA,EAAK;UACH,CAAA;UAENA,EAAK,4BAA4B,YAAYrE,EAAI,oBAChD,kBAAC,UAAD;WACE,MAAK;WACL,eAAe;YACb,AAAKwC,MACC,YAAY;aAChB,EAAkB6B,EAAK,EAAE;aACzB,IAAI;cAEF,AADA,MAAMC,GAAoBD,EAAK,IAAI5C,CAAc,GACjD,MAAMK,EACJU,GACAxC,EAAI,kBACJe,CACF;aACF,UAAU;cACR,EAAkB,IAAI;aACxB;YACF,EAAA,CAAG;WACL;WACA,UAAUQ,MAAmB8C,EAAK;WAClC,WAAU;WAET,UAAA9C,MAAmB8C,EAAK,KAAK,cAAc;UACtC,CAAA;SAER;;QACJ,kBAAC,MAAD;SAAI,WAAU;SAAiC,UAAAA,EAAK;QAAW,CAAA;OAC7D;MAjDK,GAAAA,EAAK,EAiDV,CACL,EAEE,CAAA,CACF;;IACJ,CAAA,CACE;;EACN;;AAET"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ServerError as e } from "../../../shared/components/ServerError.js";
|
|
2
2
|
import { useBillingNavigate as t } from "../../../hooks/useBillingNavigate.js";
|
|
3
|
+
import "../hooks/index.js";
|
|
3
4
|
import { formatCurrency as n, formatPlanDuration as r, formatPlanDurationLabel as i, formatQuotaValue as a } from "../../../shared/utils/format.js";
|
|
4
5
|
import { isServerError as o } from "../../../shared/utils/error.js";
|
|
5
6
|
import { getPlanFeatureQuantity as s, getPlanFeatureUnit as c, getQuotaDisplayName as l } from "../../../shared/utils/planFeatureQuantity.js";
|
|
6
|
-
import "../hooks/index.js";
|
|
7
7
|
import "../../../shared/components/index.js";
|
|
8
8
|
import { usePlan as u } from "../hooks/usePlans.js";
|
|
9
9
|
import "../../../shared/utils/index.js";
|