@burdenoff/microfe-billing 2026.915.2 → 2026.916.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billing/modules/checkout/hooks/useCheckout.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js.map +1 -1
- package/dist/billing/modules/earnings/api.js.map +1 -1
- package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/EarningsPage.js +117 -111
- package/dist/billing/modules/earnings/pages/EarningsPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/PayoutAdminPage.js +3 -2
- package/dist/billing/modules/earnings/pages/PayoutAdminPage.js.map +1 -1
- package/dist/generated/global-operations.js +1 -0
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","names":[],"sources":["../../../../src/billing/modules/earnings/api.ts"],"sourcesContent":["import { directBillingGraphqlRequest } from '../../shared/utils';\nimport { gatewayGraphqlRequest } from '../../shared/utils/gatewayGraphql';\nimport {\n AddPayoutAccountDocument,\n AdminDeveloperRevenueOrgDetailDocument,\n AdminDeveloperRevenueOrgDocument,\n AdminDeveloperRevenueOrgMonthlyDocument,\n AdminDeveloperRevenueOrgsDocument,\n AdminPayoutRequestsDocument,\n AdminPayoutSummaryDocument,\n ApprovePayoutRequestDocument,\n ArchivePayoutAccountDocument,\n BillingDeveloperPortalRevenueDocument,\n GetCostOfCreditsDocument,\n GetCreditBalanceByTypeDocument,\n MarkPayoutPaidDocument,\n MyEarningsEntriesDocument,\n MyEarningsSummaryDocument,\n MyPayoutAccountsDocument,\n MyPayoutRequestsDocument,\n ProcessPayoutRequestDocument,\n RejectPayoutRequestDocument,\n RetrySaleCreditSyncDocument,\n SetDefaultPayoutAccountDocument,\n UpdatePayoutAccountDocument,\n} from '../../../generated/global-operations';\n\nexport interface EarningsSummary {\n totalLifetimeAmount: number;\n availableAmount: number;\n reservedAmount: number;\n paidAmount: number;\n pendingAmount: number;\n moneyAmount: number;\n creditsAmount: number;\n categoryBreakdown?: Array<{\n category: 'AFFILIATE' | 'STORE' | 'OTHER';\n amount: number;\n count: number;\n }>;\n}\n\nexport interface EarningsEntry {\n id: string;\n sourceCategory: 'AFFILIATE' | 'STORE' | 'OTHER';\n sourceSubcategory?: string | null;\n description?: string | null;\n unitType: 'MONEY' | 'CREDITS';\n amount: number;\n currency: string;\n status: 'AVAILABLE' | 'RESERVED' | 'PAID' | 'REVERSED';\n createdAt: string;\n}\n\nexport interface PayoutAccount {\n id: string;\n label: string;\n type: 'BANK_ACCOUNT' | 'UPI' | 'WALLET';\n providerPreference: 'AUTO' | 'STRIPE' | 'RAZORPAY' | 'MANUAL';\n status: 'PENDING_VERIFICATION' | 'ACTIVE' | 'FAILED_VERIFICATION' | 'ARCHIVED';\n displayName?: string | null;\n accountLast4?: string | null;\n country?: string | null;\n currency: string;\n isDefault: boolean;\n accountDetails?: Record<string, unknown> | null;\n}\n\nexport interface PayoutRequest {\n id: string;\n billingAccountId?: string | null;\n requesterUserId?: string | null;\n requestedAmount: number;\n approvedAmount?: number | null;\n currency: string;\n provider: 'AUTO' | 'STRIPE' | 'RAZORPAY' | 'MANUAL';\n status: 'REQUESTED' | 'APPROVED' | 'REJECTED' | 'PROCESSING' | 'PAID' | 'FAILED' | 'CANCELED';\n /** See PayoutRequestKind on the backend — what approving this request actually does. */\n requestKind: 'CREDIT_CONVERSION' | 'CASH_PAYOUT';\n externalReference?: string | null;\n failureReason?: string | null;\n internalNotes?: string | null;\n userNotes?: string | null;\n createdAt: string;\n processedAt?: string | null;\n paidAt?: string | null;\n payoutAccount?: PayoutAccount | null;\n}\n\nexport interface PayoutAdminSummary {\n totalRequestedAmount: number;\n totalProcessingAmount: number;\n totalPaidAmount: number;\n pendingCount: number;\n failedCount: number;\n statusBreakdown?: Array<{ status: string; count: number; totalAmount: number }>;\n providerBreakdown?: Array<{ provider: string; count: number; totalAmount: number }>;\n}\n\nexport interface AdminPayoutRequestsPage {\n items: PayoutRequest[];\n totalCount: number;\n hasMore: boolean;\n}\n\nexport interface PayoutRequestFilter {\n billingAccountId?: string;\n provider?: PayoutRequest['provider'];\n status?: PayoutRequest['status'];\n startDate?: string;\n endDate?: string;\n}\n\nexport interface CreditBalanceByType {\n purchased: number;\n earned: number;\n granted: number;\n withdrawable: number;\n total: number;\n}\n\nexport interface DeveloperOrgMonthlyRevenuePoint {\n month: string;\n grossRevenue: number;\n platformFees: number;\n netRevenue: number;\n refunds: number;\n salesCount: number;\n}\n\nexport interface DeveloperPortalRevenueSummary {\n totalGrossRevenue: number;\n totalNetRevenue: number;\n totalPlatformFees: number;\n totalRefunds: number;\n totalRefundsCount: number;\n totalSales: number;\n pendingBalance: number;\n nextPayoutDate?: string | null;\n nextPayoutAmount?: number | null;\n}\n\nexport interface DeveloperPortalRevenueSale {\n id: string;\n grossAmount: number;\n netAmount: number;\n currency: string;\n pricingModel: string;\n status: string;\n billingCreditSyncStatus?: string | null;\n billingCreditSyncError?: string | null;\n billingCreditSyncedAt?: string | null;\n purchasedAt: string;\n application?: {\n id: string;\n name: string;\n slug: string;\n } | null;\n}\n\nexport interface DeveloperPortalRevenuePayout {\n id: string;\n periodLabel?: string | null;\n netAmount: number;\n currency: string;\n status: string;\n scheduledAt?: string | null;\n completedAt?: string | null;\n}\n\nexport interface DeveloperPortalRevenueDashboard {\n summary: DeveloperPortalRevenueSummary | null;\n sales: DeveloperPortalRevenueSale[];\n payouts: DeveloperPortalRevenuePayout[];\n}\n\nexport interface AdminDeveloperRevenueOrg {\n id: string;\n name: string;\n slug: string;\n billingAccountId?: string | null;\n isVerified: boolean;\n totalApps: number;\n publishedApps: number;\n totalInstalls: number;\n activeInstalls: number;\n averageRating?: number | null;\n totalRevenue: number;\n totalPlatformFees: number;\n totalPayouts: number;\n pendingBalance: number;\n lifetimeRevenue: number;\n platformFeeRate: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface AdminDeveloperRevenueOrgDetail {\n summary: DeveloperPortalRevenueSummary | null;\n unpaidSales: {\n totalCount: number;\n items: DeveloperPortalRevenueSale[];\n };\n}\n\ninterface GatewayContext {\n apiGatewayUrl?: string;\n authToken?: string;\n orgId?: string;\n}\n\nexport async function fetchDeveloperPortalRevenueDashboard(\n organizationId: string,\n context: GatewayContext\n): Promise<DeveloperPortalRevenueDashboard> {\n type RevenueQueryResult = {\n developerOrgRevenueSummary: DeveloperPortalRevenueSummary | null;\n developerOrgSales: { edges: Array<{ node: DeveloperPortalRevenueSale }> };\n developerOrgPayouts: { edges: Array<{ node: DeveloperPortalRevenuePayout }> };\n };\n\n const data = await gatewayGraphqlRequest<RevenueQueryResult, { organizationId: string }>({\n ...context,\n query: BillingDeveloperPortalRevenueDocument,\n variables: { organizationId },\n });\n\n return {\n summary: data.developerOrgRevenueSummary,\n sales: data.developerOrgSales.edges.map((edge) => edge.node),\n payouts: data.developerOrgPayouts.edges.map((edge) => edge.node),\n };\n}\n\nexport async function fetchEarningsSummary(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myEarningsSummary: EarningsSummary;\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyEarningsSummaryDocument,\n variables: { billingAccountId },\n });\n\n return data.myEarningsSummary;\n}\n\nexport async function fetchEarningsEntries(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myEarningsEntries: { items: EarningsEntry[] };\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyEarningsEntriesDocument,\n variables: { billingAccountId },\n });\n\n return data.myEarningsEntries.items;\n}\n\nexport async function fetchPayoutAccounts(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myPayoutAccounts: PayoutAccount[];\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyPayoutAccountsDocument,\n variables: { billingAccountId },\n });\n\n return data.myPayoutAccounts;\n}\n\nexport async function fetchPayoutRequests(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myPayoutRequests: { items: PayoutRequest[] };\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyPayoutRequestsDocument,\n variables: { billingAccountId },\n });\n\n return data.myPayoutRequests.items;\n}\n\nexport async function addPayoutAccount(input: Record<string, unknown>, context: GatewayContext) {\n await directBillingGraphqlRequest<\n {\n addPayoutAccount: { id: string };\n },\n { input: Record<string, unknown> }\n >({\n ...context,\n query: AddPayoutAccountDocument,\n variables: { input },\n });\n}\n\nexport async function updatePayoutAccount(\n id: string,\n input: Record<string, unknown>,\n context: GatewayContext\n) {\n await directBillingGraphqlRequest<\n { updatePayoutAccount: { id: string } },\n { id: string; input: Record<string, unknown> }\n >({\n ...context,\n query: UpdatePayoutAccountDocument,\n variables: { id, input },\n });\n}\n\nexport async function setDefaultPayoutAccount(id: string, context: GatewayContext) {\n await directBillingGraphqlRequest<{ setDefaultPayoutAccount: { id: string } }, { id: string }>({\n ...context,\n query: SetDefaultPayoutAccountDocument,\n variables: { id },\n });\n}\n\nexport async function archivePayoutAccount(id: string, context: GatewayContext) {\n await directBillingGraphqlRequest<{ archivePayoutAccount: boolean }, { id: string }>({\n ...context,\n query: ArchivePayoutAccountDocument,\n variables: { id },\n });\n}\n\nexport async function requestPayout(_input: Record<string, unknown>, _context: GatewayContext) {\n throw new Error('Payout request not yet implemented');\n}\n\nexport async function fetchAdminPayoutSummary(context: GatewayContext) {\n const data = await directBillingGraphqlRequest<{\n adminPayoutSummary: PayoutAdminSummary;\n }>({\n ...context,\n query: AdminPayoutSummaryDocument,\n });\n\n return data.adminPayoutSummary;\n}\n\nexport async function fetchAdminPayoutRequests(\n context: GatewayContext,\n pagination: { limit?: number; offset?: number; filter?: PayoutRequestFilter } = {}\n) {\n const data = await directBillingGraphqlRequest<\n {\n adminPayoutRequests: AdminPayoutRequestsPage;\n },\n {\n limit: number;\n offset: number;\n filter?: PayoutRequestFilter;\n }\n >({\n ...context,\n query: AdminPayoutRequestsDocument,\n variables: {\n limit: pagination.limit ?? 50,\n offset: pagination.offset ?? 0,\n filter: pagination.filter,\n },\n });\n\n return data.adminPayoutRequests;\n}\n\nexport async function fetchAdminDeveloperRevenueOrgs(context: GatewayContext) {\n const data = await gatewayGraphqlRequest<{\n developerOrganizations: {\n edges: Array<{ node: AdminDeveloperRevenueOrg }>;\n };\n }>({\n ...context,\n query: AdminDeveloperRevenueOrgsDocument,\n });\n\n return data.developerOrganizations.edges.map((edge) => edge.node);\n}\n\nexport async function fetchAdminDeveloperRevenueOrg(\n organizationId: string,\n context: GatewayContext\n) {\n const data = await gatewayGraphqlRequest<\n { developerOrganization: AdminDeveloperRevenueOrg | null },\n { organizationId: string }\n >({\n ...context,\n query: AdminDeveloperRevenueOrgDocument,\n variables: { organizationId },\n });\n\n return data.developerOrganization;\n}\n\nexport async function fetchAdminDeveloperRevenueOrgDetail(\n organizationId: string,\n context: GatewayContext,\n range: { startDate?: string; endDate?: string } = {}\n) {\n const data = await gatewayGraphqlRequest<\n {\n developerOrgRevenueSummary: DeveloperPortalRevenueSummary | null;\n developerOrgSales: { totalCount: number; edges: Array<{ node: DeveloperPortalRevenueSale }> };\n },\n {\n organizationId: string;\n period: string;\n salesLimit: number;\n salesOffset: number;\n startDate?: string;\n endDate?: string;\n }\n >({\n ...context,\n query: AdminDeveloperRevenueOrgDetailDocument,\n variables: {\n organizationId,\n period: 'monthly',\n salesLimit: 50,\n salesOffset: 0,\n startDate: range.startDate,\n endDate: range.endDate,\n },\n });\n\n return {\n summary: data.developerOrgRevenueSummary,\n unpaidSales: {\n totalCount: data.developerOrgSales.totalCount,\n items: data.developerOrgSales.edges.map((edge) => edge.node),\n },\n } satisfies AdminDeveloperRevenueOrgDetail;\n}\n\n/**\n * Estimated fiat cost of a raw credit amount at the current global credit\n * rate (1 credit = $0.01 by default). Credit-balance figures from\n * getCreditBalanceByType are raw credit units, NOT currency — never format\n * them with formatCurrency directly.\n */\nexport async function fetchCreditCost(\n creditAmount: number,\n currency: string,\n context: GatewayContext\n) {\n const data = await directBillingGraphqlRequest<\n { getCostOfCredits: { amount: number } },\n { creditAmount: number; currency: string }\n >({\n ...context,\n query: GetCostOfCreditsDocument,\n variables: { creditAmount, currency },\n });\n\n return data.getCostOfCredits.amount;\n}\n\nexport async function fetchAdminDeveloperRevenueOrgMonthly(\n organizationId: string,\n context: GatewayContext,\n months = 12\n) {\n const data = await gatewayGraphqlRequest<\n { developerOrgMonthlyRevenue: DeveloperOrgMonthlyRevenuePoint[] },\n { organizationId: string; months: number }\n >({\n ...context,\n query: AdminDeveloperRevenueOrgMonthlyDocument,\n variables: { organizationId, months },\n });\n\n return data.developerOrgMonthlyRevenue;\n}\n\n/**\n * Current credit balance for a devorg's linked billing account. Callable for\n * any billingAccountId as a billing admin — getCreditBalanceByType's\n * `scopeType: \"billing\"` RBAC bypasses org ownership for super_admin actors.\n */\nexport async function fetchBillingAccountCreditBalance(\n billingAccountId: string,\n context: GatewayContext\n) {\n const data = await directBillingGraphqlRequest<\n { getCreditBalanceByType: CreditBalanceByType },\n { billingAccountId: string }\n >({\n ...context,\n query: GetCreditBalanceByTypeDocument,\n variables: { billingAccountId },\n });\n\n return data.getCreditBalanceByType;\n}\n\nexport async function retrySaleCreditSync(saleId: string, context: GatewayContext) {\n const data = await gatewayGraphqlRequest<\n {\n retrySaleCreditSync: Pick<\n DeveloperPortalRevenueSale,\n 'id' | 'billingCreditSyncStatus' | 'billingCreditSyncError' | 'billingCreditSyncedAt'\n >;\n },\n { saleId: string }\n >({\n ...context,\n query: RetrySaleCreditSyncDocument,\n variables: { saleId },\n });\n\n return data.retrySaleCreditSync;\n}\n\nexport async function approvePayoutRequest(\n id: string,\n notes: string | null,\n context: GatewayContext\n) {\n await directBillingGraphqlRequest<\n {\n approvePayoutRequest: { id: string };\n },\n { id: string; notes: string | null }\n >({\n ...context,\n query: ApprovePayoutRequestDocument,\n variables: { id, notes },\n });\n}\n\nexport async function rejectPayoutRequest(id: string, reason: string, context: GatewayContext) {\n await directBillingGraphqlRequest<\n {\n rejectPayoutRequest: { id: string };\n },\n { id: string; reason: string }\n >({\n ...context,\n query: RejectPayoutRequestDocument,\n variables: { id, reason },\n });\n}\n\nexport async function processPayoutRequest(id: string, context: GatewayContext) {\n await directBillingGraphqlRequest<\n {\n processPayoutRequest: { id: string };\n },\n { id: string }\n >({\n ...context,\n query: ProcessPayoutRequestDocument,\n variables: { id },\n });\n}\n\nexport async function markPayoutPaid(\n id: string,\n externalReference: string | null,\n notes: string | null,\n context: GatewayContext\n) {\n await directBillingGraphqlRequest<\n { markPayoutPaid: { id: string } },\n { id: string; externalReference: string | null; notes: string | null }\n >({\n ...context,\n query: MarkPayoutPaidDocument,\n variables: { id, externalReference, notes },\n });\n}\n"],"mappings":";;;;;AAmNA,eAAsB,EACpB,GACA,GAC0C;CAO1C,IAAM,IAAO,MAAM,EAAsE;EACvF,GAAG;EACH,OAAO;EACP,WAAW,EAAE,kBAAe;CAC9B,CAAC;CAED,OAAO;EACL,SAAS,EAAK;EACd,OAAO,EAAK,kBAAkB,MAAM,KAAK,MAAS,EAAK,IAAI;EAC3D,SAAS,EAAK,oBAAoB,MAAM,KAAK,MAAS,EAAK,IAAI;CACjE;AACF;AAEA,eAAsB,EAAqB,GAA0B,GAAyB;CAY5F,QAAO,MAXY,EAKjB;EACA,GAAG;EACH,OAAO;EACP,WAAW,EAAE,oBAAiB;CAChC,CAAC,GAEW;AACd;AAEA,eAAsB,EAAqB,GAA0B,GAAyB;CAY5F,QAAO,MAXY,EAKjB;EACA,GAAG;EACH,OAAO;EACP,WAAW,EAAE,oBAAiB;CAChC,CAAC,GAEW,kBAAkB;AAChC;AAEA,eAAsB,EAAoB,GAA0B,GAAyB;CAY3F,QAAO,MAXY,EAKjB;EACA,GAAG;EACH,OAAO;EACP,WAAW,EAAE,oBAAiB;CAChC,CAAC,GAEW;AACd;AAEA,eAAsB,EA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AACH"}
|
|
1
|
+
{"version":3,"file":"api.js","names":[],"sources":["../../../../src/billing/modules/earnings/api.ts"],"sourcesContent":["import { directBillingGraphqlRequest } from '../../shared/utils';\nimport { gatewayGraphqlRequest } from '../../shared/utils/gatewayGraphql';\nimport {\n AddPayoutAccountDocument,\n AdminDeveloperRevenueOrgDetailDocument,\n AdminDeveloperRevenueOrgDocument,\n AdminDeveloperRevenueOrgMonthlyDocument,\n AdminDeveloperRevenueOrgsDocument,\n AdminPayoutRequestsDocument,\n AdminPayoutSummaryDocument,\n ApprovePayoutRequestDocument,\n ArchivePayoutAccountDocument,\n BillingDeveloperPortalRevenueDocument,\n GetCostOfCreditsDocument,\n GetCreditBalanceByTypeDocument,\n MarkPayoutPaidDocument,\n MyEarningsEntriesDocument,\n MyEarningsSummaryDocument,\n MyPayoutAccountsDocument,\n MyPayoutRequestsDocument,\n ProcessPayoutRequestDocument,\n RejectPayoutRequestDocument,\n RetrySaleCreditSyncDocument,\n SetDefaultPayoutAccountDocument,\n UpdatePayoutAccountDocument,\n} from '../../../generated/global-operations';\n\nexport interface EarningsSummary {\n totalLifetimeAmount: number;\n availableAmount: number;\n reservedAmount: number;\n paidAmount: number;\n pendingAmount: number;\n moneyAmount: number;\n creditsAmount: number;\n categoryBreakdown?: Array<{\n category: 'AFFILIATE' | 'STORE' | 'OTHER';\n amount: number;\n count: number;\n }>;\n}\n\nexport interface EarningsEntry {\n id: string;\n sourceCategory: 'AFFILIATE' | 'STORE' | 'OTHER';\n sourceSubcategory?: string | null;\n description?: string | null;\n unitType: 'MONEY' | 'CREDITS';\n amount: number;\n currency: string;\n status: 'AVAILABLE' | 'RESERVED' | 'PAID' | 'REVERSED';\n createdAt: string;\n}\n\nexport interface PayoutAccount {\n id: string;\n label: string;\n type: 'BANK_ACCOUNT' | 'UPI' | 'WALLET';\n providerPreference: 'AUTO' | 'STRIPE' | 'RAZORPAY' | 'MANUAL';\n status: 'PENDING_VERIFICATION' | 'ACTIVE' | 'FAILED_VERIFICATION' | 'ARCHIVED';\n displayName?: string | null;\n accountLast4?: string | null;\n country?: string | null;\n currency: string;\n isDefault: boolean;\n accountDetails?: Record<string, unknown> | null;\n}\n\nexport interface PayoutRequest {\n id: string;\n billingAccountId?: string | null;\n requesterUserId?: string | null;\n requestedAmount: number;\n approvedAmount?: number | null;\n currency: string;\n provider: 'AUTO' | 'STRIPE' | 'RAZORPAY' | 'MANUAL';\n status: 'REQUESTED' | 'APPROVED' | 'REJECTED' | 'PROCESSING' | 'PAID' | 'FAILED' | 'CANCELED';\n /** See PayoutRequestKind on the backend — what approving this request actually does. */\n requestKind: 'CREDIT_CONVERSION' | 'CASH_PAYOUT';\n externalReference?: string | null;\n failureReason?: string | null;\n internalNotes?: string | null;\n userNotes?: string | null;\n createdAt: string;\n processedAt?: string | null;\n paidAt?: string | null;\n payoutAccount?: PayoutAccount | null;\n}\n\nexport interface PayoutAdminSummary {\n totalRequestedAmount: number;\n totalProcessingAmount: number;\n totalPaidAmount: number;\n pendingCount: number;\n failedCount: number;\n statusBreakdown?: Array<{ status: string; count: number; totalAmount: number }>;\n providerBreakdown?: Array<{ provider: string; count: number; totalAmount: number }>;\n}\n\nexport interface AdminPayoutRequestsPage {\n items: PayoutRequest[];\n totalCount: number;\n hasMore: boolean;\n}\n\nexport interface PayoutRequestFilter {\n billingAccountId?: string;\n provider?: PayoutRequest['provider'];\n status?: PayoutRequest['status'];\n startDate?: string;\n endDate?: string;\n}\n\nexport interface CreditBalanceByType {\n purchased: number;\n earned: number;\n granted: number;\n withdrawable: number;\n total: number;\n}\n\nexport interface DeveloperOrgMonthlyRevenuePoint {\n month: string;\n grossRevenue: number;\n platformFees: number;\n netRevenue: number;\n refunds: number;\n salesCount: number;\n}\n\nexport interface DeveloperPortalRevenueSummary {\n currency: string;\n totalGrossRevenue: number;\n totalNetRevenue: number;\n totalPlatformFees: number;\n totalRefunds: number;\n totalRefundsCount: number;\n totalSales: number;\n pendingBalance: number;\n nextPayoutDate?: string | null;\n nextPayoutAmount?: number | null;\n}\n\nexport interface DeveloperPortalRevenueSale {\n id: string;\n grossAmount: number;\n netAmount: number;\n currency: string;\n pricingModel: string;\n status: string;\n billingCreditSyncStatus?: string | null;\n billingCreditSyncError?: string | null;\n billingCreditSyncedAt?: string | null;\n purchasedAt: string;\n application?: {\n id: string;\n name: string;\n slug: string;\n } | null;\n}\n\nexport interface DeveloperPortalRevenuePayout {\n id: string;\n periodLabel?: string | null;\n netAmount: number;\n currency: string;\n status: string;\n scheduledAt?: string | null;\n completedAt?: string | null;\n}\n\nexport interface DeveloperPortalRevenueDashboard {\n summary: DeveloperPortalRevenueSummary | null;\n sales: DeveloperPortalRevenueSale[];\n payouts: DeveloperPortalRevenuePayout[];\n}\n\nexport interface AdminDeveloperRevenueOrg {\n id: string;\n name: string;\n slug: string;\n billingAccountId?: string | null;\n isVerified: boolean;\n totalApps: number;\n publishedApps: number;\n totalInstalls: number;\n activeInstalls: number;\n averageRating?: number | null;\n totalRevenue: number;\n totalPlatformFees: number;\n totalPayouts: number;\n pendingBalance: number;\n lifetimeRevenue: number;\n platformFeeRate: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface AdminDeveloperRevenueOrgDetail {\n summary: DeveloperPortalRevenueSummary | null;\n unpaidSales: {\n totalCount: number;\n items: DeveloperPortalRevenueSale[];\n };\n}\n\ninterface GatewayContext {\n apiGatewayUrl?: string;\n authToken?: string;\n orgId?: string;\n}\n\nexport async function fetchDeveloperPortalRevenueDashboard(\n organizationId: string,\n context: GatewayContext\n): Promise<DeveloperPortalRevenueDashboard> {\n type RevenueQueryResult = {\n developerOrgRevenueSummary: DeveloperPortalRevenueSummary | null;\n developerOrgSales: { edges: Array<{ node: DeveloperPortalRevenueSale }> };\n developerOrgPayouts: { edges: Array<{ node: DeveloperPortalRevenuePayout }> };\n };\n\n const data = await gatewayGraphqlRequest<RevenueQueryResult, { organizationId: string }>({\n ...context,\n query: BillingDeveloperPortalRevenueDocument,\n variables: { organizationId },\n });\n\n return {\n summary: data.developerOrgRevenueSummary,\n sales: data.developerOrgSales.edges.map((edge) => edge.node),\n payouts: data.developerOrgPayouts.edges.map((edge) => edge.node),\n };\n}\n\nexport async function fetchEarningsSummary(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myEarningsSummary: EarningsSummary;\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyEarningsSummaryDocument,\n variables: { billingAccountId },\n });\n\n return data.myEarningsSummary;\n}\n\nexport async function fetchEarningsEntries(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myEarningsEntries: { items: EarningsEntry[] };\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyEarningsEntriesDocument,\n variables: { billingAccountId },\n });\n\n return data.myEarningsEntries.items;\n}\n\nexport async function fetchPayoutAccounts(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myPayoutAccounts: PayoutAccount[];\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyPayoutAccountsDocument,\n variables: { billingAccountId },\n });\n\n return data.myPayoutAccounts;\n}\n\nexport async function fetchPayoutRequests(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myPayoutRequests: { items: PayoutRequest[] };\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyPayoutRequestsDocument,\n variables: { billingAccountId },\n });\n\n return data.myPayoutRequests.items;\n}\n\nexport async function addPayoutAccount(input: Record<string, unknown>, context: GatewayContext) {\n await directBillingGraphqlRequest<\n {\n addPayoutAccount: { id: string };\n },\n { input: Record<string, unknown> }\n >({\n ...context,\n query: AddPayoutAccountDocument,\n variables: { input },\n });\n}\n\nexport async function updatePayoutAccount(\n id: string,\n input: Record<string, unknown>,\n context: GatewayContext\n) {\n await directBillingGraphqlRequest<\n { updatePayoutAccount: { id: string } },\n { id: string; input: Record<string, unknown> }\n >({\n ...context,\n query: UpdatePayoutAccountDocument,\n variables: { id, input },\n });\n}\n\nexport async function setDefaultPayoutAccount(id: string, context: GatewayContext) {\n await directBillingGraphqlRequest<{ setDefaultPayoutAccount: { id: string } }, { id: string }>({\n ...context,\n query: SetDefaultPayoutAccountDocument,\n variables: { id },\n });\n}\n\nexport async function archivePayoutAccount(id: string, context: GatewayContext) {\n await directBillingGraphqlRequest<{ archivePayoutAccount: boolean }, { id: string }>({\n ...context,\n query: ArchivePayoutAccountDocument,\n variables: { id },\n });\n}\n\nexport async function requestPayout(_input: Record<string, unknown>, _context: GatewayContext) {\n throw new Error('Payout request not yet implemented');\n}\n\nexport async function fetchAdminPayoutSummary(context: GatewayContext) {\n const data = await directBillingGraphqlRequest<{\n adminPayoutSummary: PayoutAdminSummary;\n }>({\n ...context,\n query: AdminPayoutSummaryDocument,\n });\n\n return data.adminPayoutSummary;\n}\n\nexport async function fetchAdminPayoutRequests(\n context: GatewayContext,\n pagination: { limit?: number; offset?: number; filter?: PayoutRequestFilter } = {}\n) {\n const data = await directBillingGraphqlRequest<\n {\n adminPayoutRequests: AdminPayoutRequestsPage;\n },\n {\n limit: number;\n offset: number;\n filter?: PayoutRequestFilter;\n }\n >({\n ...context,\n query: AdminPayoutRequestsDocument,\n variables: {\n limit: pagination.limit ?? 50,\n offset: pagination.offset ?? 0,\n filter: pagination.filter,\n },\n });\n\n return data.adminPayoutRequests;\n}\n\nexport async function fetchAdminDeveloperRevenueOrgs(context: GatewayContext) {\n const data = await gatewayGraphqlRequest<{\n developerOrganizations: {\n edges: Array<{ node: AdminDeveloperRevenueOrg }>;\n };\n }>({\n ...context,\n query: AdminDeveloperRevenueOrgsDocument,\n });\n\n return data.developerOrganizations.edges.map((edge) => edge.node);\n}\n\nexport async function fetchAdminDeveloperRevenueOrg(\n organizationId: string,\n context: GatewayContext\n) {\n const data = await gatewayGraphqlRequest<\n { developerOrganization: AdminDeveloperRevenueOrg | null },\n { organizationId: string }\n >({\n ...context,\n query: AdminDeveloperRevenueOrgDocument,\n variables: { organizationId },\n });\n\n return data.developerOrganization;\n}\n\nexport async function fetchAdminDeveloperRevenueOrgDetail(\n organizationId: string,\n context: GatewayContext,\n range: { startDate?: string; endDate?: string } = {}\n) {\n const data = await gatewayGraphqlRequest<\n {\n developerOrgRevenueSummary: DeveloperPortalRevenueSummary | null;\n developerOrgSales: { totalCount: number; edges: Array<{ node: DeveloperPortalRevenueSale }> };\n },\n {\n organizationId: string;\n period: string;\n salesLimit: number;\n salesOffset: number;\n startDate?: string;\n endDate?: string;\n }\n >({\n ...context,\n query: AdminDeveloperRevenueOrgDetailDocument,\n variables: {\n organizationId,\n period: 'monthly',\n salesLimit: 50,\n salesOffset: 0,\n startDate: range.startDate,\n endDate: range.endDate,\n },\n });\n\n return {\n summary: data.developerOrgRevenueSummary,\n unpaidSales: {\n totalCount: data.developerOrgSales.totalCount,\n items: data.developerOrgSales.edges.map((edge) => edge.node),\n },\n } satisfies AdminDeveloperRevenueOrgDetail;\n}\n\n/**\n * Estimated fiat cost of a raw credit amount at the current global credit\n * rate (1 credit = $0.01 by default). Credit-balance figures from\n * getCreditBalanceByType are raw credit units, NOT currency — never format\n * them with formatCurrency directly.\n */\nexport async function fetchCreditCost(\n creditAmount: number,\n currency: string,\n context: GatewayContext\n) {\n const data = await directBillingGraphqlRequest<\n { getCostOfCredits: { amount: number } },\n { creditAmount: number; currency: string }\n >({\n ...context,\n query: GetCostOfCreditsDocument,\n variables: { creditAmount, currency },\n });\n\n return data.getCostOfCredits.amount;\n}\n\nexport async function fetchAdminDeveloperRevenueOrgMonthly(\n organizationId: string,\n context: GatewayContext,\n months = 12\n) {\n const data = await gatewayGraphqlRequest<\n { developerOrgMonthlyRevenue: DeveloperOrgMonthlyRevenuePoint[] },\n { organizationId: string; months: number }\n >({\n ...context,\n query: AdminDeveloperRevenueOrgMonthlyDocument,\n variables: { organizationId, months },\n });\n\n return data.developerOrgMonthlyRevenue;\n}\n\n/**\n * Current credit balance for a devorg's linked billing account. Callable for\n * any billingAccountId as a billing admin — getCreditBalanceByType's\n * `scopeType: \"billing\"` RBAC bypasses org ownership for super_admin actors.\n */\nexport async function fetchBillingAccountCreditBalance(\n billingAccountId: string,\n context: GatewayContext\n) {\n const data = await directBillingGraphqlRequest<\n { getCreditBalanceByType: CreditBalanceByType },\n { billingAccountId: string }\n >({\n ...context,\n query: GetCreditBalanceByTypeDocument,\n variables: { billingAccountId },\n });\n\n return data.getCreditBalanceByType;\n}\n\nexport async function retrySaleCreditSync(saleId: string, context: GatewayContext) {\n const data = await gatewayGraphqlRequest<\n {\n retrySaleCreditSync: Pick<\n DeveloperPortalRevenueSale,\n 'id' | 'billingCreditSyncStatus' | 'billingCreditSyncError' | 'billingCreditSyncedAt'\n >;\n },\n { saleId: string }\n >({\n ...context,\n query: RetrySaleCreditSyncDocument,\n variables: { saleId },\n });\n\n return data.retrySaleCreditSync;\n}\n\nexport async function approvePayoutRequest(\n id: string,\n notes: string | null,\n context: GatewayContext\n) {\n await directBillingGraphqlRequest<\n {\n approvePayoutRequest: { id: string };\n },\n { id: string; notes: string | null }\n >({\n ...context,\n query: ApprovePayoutRequestDocument,\n variables: { id, notes },\n });\n}\n\nexport async function rejectPayoutRequest(id: string, reason: string, context: GatewayContext) {\n await directBillingGraphqlRequest<\n {\n rejectPayoutRequest: { id: string };\n },\n { id: string; reason: string }\n >({\n ...context,\n query: RejectPayoutRequestDocument,\n variables: { id, reason },\n });\n}\n\nexport async function processPayoutRequest(id: string, context: GatewayContext) {\n await directBillingGraphqlRequest<\n {\n processPayoutRequest: { id: string };\n },\n { id: string }\n >({\n ...context,\n query: ProcessPayoutRequestDocument,\n variables: { id },\n });\n}\n\nexport async function markPayoutPaid(\n id: string,\n externalReference: string | null,\n notes: string | null,\n context: GatewayContext\n) {\n await directBillingGraphqlRequest<\n { markPayoutPaid: { id: string } },\n { id: string; externalReference: string | null; notes: string | null }\n >({\n ...context,\n query: MarkPayoutPaidDocument,\n variables: { id, externalReference, notes },\n });\n}\n"],"mappings":";;;;;AAoNA,eAAsB,EACpB,GACA,GA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AAE;GAAgB;EAAO;CACtC,CAAC,GAEW;AACd;AAOA,eAAsB,EACpB,GACA,GACA;CAUA,QAAO,MATY,EAGjB;EACA,GAAG;EACH,OAAO;EACP,WAAW,EAAE,oBAAiB;CAChC,CAAC,GAEW;AACd;AAEA,eAAsB,EAAoB,GAAgB,GAAyB;CAejF,QAAO,MAdY,EAQjB;EACA,GAAG;EACH,OAAO;EACP,WAAW,EAAE,UAAO;CACtB,CAAC,GAEW;AACd;AAEA,eAAsB,EACpB,GACA,GACA,GACA;CACA,MAAM,EAKJ;EACA,GAAG;EACH,OAAO;EACP,WAAW;GAAE;GAAI;EAAM;CACzB,CAAC;AACH;AAEA,eAAsB,EAAoB,GAAY,GAAgB,GAAyB;CAC7F,MAAM,EAKJ;EACA,GAAG;EACH,OAAO;EACP,WAAW;GAAE;GAAI;EAAO;CAC1B,CAAC;AACH;AAeA,eAAsB,EACpB,GACA,GACA,GACA,GACA;CACA,MAAM,EAGJ;EACA,GAAG;EACH,OAAO;EACP,WAAW;GAAE;GAAI;GAAmB;EAAM;CAC5C,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeveloperRevenueOrgDetailPage.js","names":[],"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 { formatCredits, formatCurrency, formatDateTime, isServerError } 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(Date.UTC(start.getUTCFullYear(), start.getUTCMonth(), 1)).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' ? 'Revenue-share credits' : '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 (organizationIdValue: string, billingAccountId: string | null | undefined, month: string) => {\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 platform's\n 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 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 them.\n </p>\n </div>\n <div\n className={`overflow-x-auto ${periodLoading ? 'pointer-events-none opacity-50' : ''}`}\n >\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\">/{sale.application?.slug ?? 'unknown'}</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(organizationId, org.billingAccountId, selectedMonth);\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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,UAAM,EAAK,2BAA2B,UAAe,CAAA;UACpD,EAAK,0BACJ,kBAAC,OAAD;WAAK,WAAU;qBACZ,EAAK;UACH,CAAA;UAEN,EAAK,4BAA4B,YAAY,EAAI,oBAChD,kBAAC,UAAD;WACE,MAAK;WACL,eAAe;YACR,MACC,YAAY;aAChB,EAAkB,EAAK,EAAE;aACzB,IAAI;cAEF,AADA,MAAM,GAAoB,EAAK,IAAI,CAAc,GACjD,MAAM,EAAW,GAAgB,EAAI,kBAAkB,CAAa;aACtE,UAAU;cACR,EAAkB,IAAI;aACxB;YACF,GAAG;WACL;WACA,UAAU,MAAmB,EAAK;WAClC,WAAU;qBAET,MAAmB,EAAK,KAAK,cAAc;UACtC,CAAA;SAER;;QACJ,kBAAC,MAAD;SAAI,WAAU;mBAAiC,EAAK;QAAW,CAAA;OAC7D;SA3CK,EAAK,EA2CV,CACL,EAEE,CAAA,CACF;;IACJ,CAAA,CACE;;EACN;;AAET"}
|
|
1
|
+
{"version":3,"file":"DeveloperRevenueOrgDetailPage.js","names":[],"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 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>\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