@burdenoff/microfe-billing 2026.1113.4 → 2026.1114.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billing/modules/addons/pages/AddonsBrowsePage.js +293 -291
- package/dist/billing/modules/addons/pages/AddonsBrowsePage.js.map +1 -1
- package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js +25 -24
- package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js.map +1 -1
- package/dist/billing/modules/analytics/pages/AnalyticsPage.js +25 -24
- package/dist/billing/modules/analytics/pages/AnalyticsPage.js.map +1 -1
- package/dist/billing/modules/billing/hooks/index.js +5 -5
- package/dist/billing/modules/billing/hooks/useInvoices.js +20 -39
- package/dist/billing/modules/billing/hooks/useInvoices.js.map +1 -1
- package/dist/billing/modules/billing/index.js +14 -14
- package/dist/billing/modules/billing/pages/InvoicesListPage.js +92 -89
- package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/TransactionsPage.js +2 -2
- package/dist/billing/modules/billing/pages/UserRefundsPage.js +140 -140
- package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
- package/dist/billing/modules/coupons/pages/CouponDetailPage.js +16 -15
- package/dist/billing/modules/coupons/pages/CouponDetailPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js +1 -1
- package/dist/billing/modules/credits/pages/CreditsPage.js +164 -137
- package/dist/billing/modules/credits/pages/CreditsPage.js.map +1 -1
- package/dist/billing/modules/dashboard/pages/OverviewPage.js +444 -594
- package/dist/billing/modules/dashboard/pages/OverviewPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/EarningsPage.js +20 -20
- package/dist/billing/modules/earnings/pages/EarningsPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/PayoutsPage.js +1 -1
- package/dist/billing/modules/plans/pages/PlansBrowsePage.js +32 -32
- package/dist/billing/modules/settings/pages/SettingsPage.js +4 -4
- package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js +577 -640
- package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js.map +1 -1
- package/dist/billing/shared/components/HeaderActions.d.ts +10 -0
- package/dist/billing/shared/components/HeaderActions.js +33 -0
- package/dist/billing/shared/components/HeaderActions.js.map +1 -0
- package/dist/billing/shared/components/index.d.ts +1 -0
- package/dist/billing/shared/components/index.js +2 -1
- package/dist/billing/shared/utils/format.js +4 -16
- package/dist/billing/shared/utils/format.js.map +1 -1
- package/dist/billing/shared/utils/index.js +8 -8
- package/dist/generated/global-operations.js +286 -294
- package/dist/generated/global-operations.js.map +1 -1
- package/package.json +1 -1
- package/dist/billing/modules/dashboard/utils/overviewSummary.d.ts +0 -46
- package/dist/billing/modules/dashboard/utils/overviewSummary.js +0 -37
- package/dist/billing/modules/dashboard/utils/overviewSummary.js.map +0 -1
- package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.d.ts +0 -30
- package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.js +0 -20
- package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.js.map +0 -1
|
@@ -1,37 +1,18 @@
|
|
|
1
|
-
import { GetInvoicesDocument as e, GetPaginatedInvoicesDocument as t, GetTransactionsByBillingAccountDocument as n, useGenerateInvoiceMutation as r, useGetInvoiceQuery as i,
|
|
2
|
-
import { useCallback as
|
|
3
|
-
import { useApolloClient as
|
|
1
|
+
import { GetInvoicesDocument as e, GetPaginatedInvoicesDocument as t, GetTransactionsByBillingAccountDocument as n, useGenerateInvoiceMutation as r, useGetInvoiceQuery as i, useGetPaginatedInvoicesQuery as a, usePayInvoiceMutation as o, useRetryInvoiceGenerationMutation as s, useVoidInvoiceMutation as c } from "../../../../generated/global-operations.js";
|
|
2
|
+
import { useCallback as l } from "react";
|
|
3
|
+
import { useApolloClient as u } from "@apollo/client/react";
|
|
4
4
|
// src/billing/modules/billing/hooks/useInvoices.ts
|
|
5
|
-
function
|
|
6
|
-
let { status: t, billingAccountId: n } = e, { data:
|
|
7
|
-
variables: {
|
|
8
|
-
status: t,
|
|
9
|
-
billingAccountId: n
|
|
10
|
-
},
|
|
11
|
-
fetchPolicy: "cache-and-network"
|
|
12
|
-
}), c = d(() => r?.getInvoices || [], [r?.getInvoices]);
|
|
13
|
-
return {
|
|
14
|
-
invoices: c,
|
|
15
|
-
openInvoices: d(() => c.filter((e) => e.status === "OPEN"), [c]),
|
|
16
|
-
paidInvoices: d(() => c.filter((e) => e.status === "PAID"), [c]),
|
|
17
|
-
isLoading: i,
|
|
18
|
-
error: o,
|
|
19
|
-
refetch: u(async () => {
|
|
20
|
-
await s();
|
|
21
|
-
}, [s])
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function m(e = {}) {
|
|
25
|
-
let { status: t, billingAccountId: n, page: r = 1, pageSize: i = 20, search: a } = e, { data: s, loading: c, error: l, refetch: d } = o({
|
|
5
|
+
function d(e = {}) {
|
|
6
|
+
let { status: t, billingAccountId: n, page: r = 1, pageSize: i = 20, search: o } = e, { data: s, loading: c, error: u, refetch: d } = a({
|
|
26
7
|
variables: {
|
|
27
8
|
status: t,
|
|
28
9
|
billingAccountId: n,
|
|
29
10
|
page: r,
|
|
30
11
|
pageSize: i,
|
|
31
|
-
search:
|
|
12
|
+
search: o || void 0
|
|
32
13
|
},
|
|
33
14
|
fetchPolicy: "cache-and-network"
|
|
34
|
-
}), f =
|
|
15
|
+
}), f = l(async () => {
|
|
35
16
|
await d();
|
|
36
17
|
}, [d]);
|
|
37
18
|
return {
|
|
@@ -42,11 +23,11 @@ function m(e = {}) {
|
|
|
42
23
|
pageSize: s?.getPaginatedInvoices?.pageSize || i,
|
|
43
24
|
totalPages: s?.getPaginatedInvoices?.totalPages || 0,
|
|
44
25
|
isLoading: c,
|
|
45
|
-
error:
|
|
26
|
+
error: u,
|
|
46
27
|
refetch: f
|
|
47
28
|
};
|
|
48
29
|
}
|
|
49
|
-
function
|
|
30
|
+
function f(e, t) {
|
|
50
31
|
let { data: n, loading: r, error: a, refetch: o } = i({
|
|
51
32
|
variables: {
|
|
52
33
|
id: e,
|
|
@@ -54,7 +35,7 @@ function h(e, t) {
|
|
|
54
35
|
},
|
|
55
36
|
skip: !e || !t,
|
|
56
37
|
fetchPolicy: "cache-and-network"
|
|
57
|
-
}), s =
|
|
38
|
+
}), s = l(async () => {
|
|
58
39
|
await o();
|
|
59
40
|
}, [o]);
|
|
60
41
|
return {
|
|
@@ -64,10 +45,10 @@ function h(e, t) {
|
|
|
64
45
|
refetch: s
|
|
65
46
|
};
|
|
66
47
|
}
|
|
67
|
-
function
|
|
68
|
-
let i =
|
|
48
|
+
function p() {
|
|
49
|
+
let i = u(), [a, { loading: d }] = r(), [f, { loading: p }] = o(), [m, { loading: h }] = c(), [g, { loading: _ }] = s();
|
|
69
50
|
return {
|
|
70
|
-
generateInvoice:
|
|
51
|
+
generateInvoice: l(async (n, r) => {
|
|
71
52
|
try {
|
|
72
53
|
let { data: o } = await a({ variables: {
|
|
73
54
|
subscriptionId: n,
|
|
@@ -78,9 +59,9 @@ function g() {
|
|
|
78
59
|
throw console.error("Failed to generate invoice:", e), e;
|
|
79
60
|
}
|
|
80
61
|
}, [a, i]),
|
|
81
|
-
payInvoice:
|
|
62
|
+
payInvoice: l(async (n, r, a) => {
|
|
82
63
|
try {
|
|
83
|
-
let { data: o } = await
|
|
64
|
+
let { data: o } = await f({ variables: {
|
|
84
65
|
invoiceId: n,
|
|
85
66
|
paymentMethodId: r,
|
|
86
67
|
billingAccountId: a
|
|
@@ -89,8 +70,8 @@ function g() {
|
|
|
89
70
|
} catch (e) {
|
|
90
71
|
throw console.error("Failed to pay invoice:", e), e;
|
|
91
72
|
}
|
|
92
|
-
}, [
|
|
93
|
-
voidInvoice:
|
|
73
|
+
}, [f, i]),
|
|
74
|
+
voidInvoice: l(async (n, r) => {
|
|
94
75
|
try {
|
|
95
76
|
let { data: a } = await m({ variables: {
|
|
96
77
|
invoiceId: n,
|
|
@@ -101,7 +82,7 @@ function g() {
|
|
|
101
82
|
throw console.error("Failed to void invoice:", e), e;
|
|
102
83
|
}
|
|
103
84
|
}, [m, i]),
|
|
104
|
-
retryInvoiceGeneration:
|
|
85
|
+
retryInvoiceGeneration: l(async (r, a) => {
|
|
105
86
|
try {
|
|
106
87
|
let { data: o } = await g({ variables: {
|
|
107
88
|
transactionId: r,
|
|
@@ -116,12 +97,12 @@ function g() {
|
|
|
116
97
|
throw console.error("Failed to retry invoice generation:", e), e;
|
|
117
98
|
}
|
|
118
99
|
}, [g, i]),
|
|
119
|
-
isGenerating:
|
|
100
|
+
isGenerating: d,
|
|
120
101
|
isPaying: p,
|
|
121
102
|
isVoiding: h,
|
|
122
103
|
isRetrying: _
|
|
123
104
|
};
|
|
124
105
|
}
|
|
125
|
-
export {
|
|
106
|
+
export { f as useInvoice, p as useInvoiceMutations, d as usePaginatedInvoices };
|
|
126
107
|
|
|
127
108
|
//# sourceMappingURL=useInvoices.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInvoices.js","names":["useInvoices","options","useGetInvoicesQuery","invoices","useMemo","data","inv","loading","useCallback","refetch","usePaginatedInvoices","useGetPaginatedInvoicesQuery","search","handleRefetch","pageSize","useInvoice","useGetInvoiceQuery","id","billingAccountId","useInvoiceMutations","client","useApolloClient","generateInvoiceMutation","isGenerating","useGenerateInvoiceMutation","payInvoiceMutation","isPaying","usePayInvoiceMutation","voidInvoiceMutation","isVoiding","useVoidInvoiceMutation","retryInvoiceGenerationMutation","isRetrying","useRetryInvoiceGenerationMutation","GetInvoicesDocument","GetPaginatedInvoicesDocument","error","GetTransactionsByBillingAccountDocument"],"sources":["../../../../../src/billing/modules/billing/hooks/useInvoices.ts"],"sourcesContent":["/**\n * Billing Module - useInvoices Hook\n * Provides access to invoice data and mutations\n */\n\nimport { useApolloClient } from '@apollo/client/react';\nimport { useCallback, useMemo } from 'react';\nimport {\n useGetInvoicesQuery,\n useGetInvoiceQuery,\n useGetInvoiceByNumberQuery,\n useGenerateInvoiceMutation,\n usePayInvoiceMutation,\n useVoidInvoiceMutation,\n useRetryInvoiceGenerationMutation,\n GetInvoicesDocument,\n GetPaginatedInvoicesDocument,\n GetTransactionsByBillingAccountDocument,\n useGetPaginatedInvoicesQuery,\n} from '../../../../generated/global-operations';\nimport type { Invoice, InvoiceStatus } from '../../../shared/types';\n\ninterface UseInvoicesOptions {\n status?: InvoiceStatus;\n billingAccountId?: string;\n}\n\ninterface UseInvoicesResult {\n invoices: Invoice[];\n openInvoices: Invoice[];\n paidInvoices: Invoice[];\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\ninterface UsePaginatedInvoicesOptions {\n status?: InvoiceStatus;\n billingAccountId?: string;\n page?: number;\n pageSize?: number;\n search?: string;\n}\n\ninterface UsePaginatedInvoicesResult {\n invoices: Invoice[];\n totalCount: number;\n hasMore: boolean;\n page: number;\n pageSize: number;\n totalPages: number;\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\ninterface UseInvoiceResult {\n invoice: Invoice | null;\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\ninterface UseInvoiceMutationsResult {\n generateInvoice: (subscriptionId: string, billingAccountId: string) => Promise<Invoice>;\n payInvoice: (\n invoiceId: string,\n paymentMethodId: string,\n billingAccountId: string\n ) => Promise<Invoice>;\n voidInvoice: (invoiceId: string, billingAccountId: string) => Promise<Invoice>;\n /**\n * Retry invoice generation for a successful transaction that never got an\n * invoice recorded (a transient Zoho Books/Stripe Invoicing failure at\n * payment time). transactionId comes from getTransactionsByBillingAccount\n * / getTransaction — these transactions never appear in the invoice list,\n * which only shows transactions that already have one.\n */\n retryInvoiceGeneration: (transactionId: string, billingAccountId: string) => Promise<Invoice>;\n isGenerating: boolean;\n isPaying: boolean;\n isVoiding: boolean;\n isRetrying: boolean;\n}\n\n/**\n * Hook for fetching invoices\n */\nexport function useInvoices(options: UseInvoicesOptions = {}): UseInvoicesResult {\n const { status, billingAccountId } = options;\n\n const { data, loading, error, refetch } = useGetInvoicesQuery({\n variables: { status, billingAccountId },\n fetchPolicy: 'cache-and-network',\n });\n\n const invoices = useMemo<Invoice[]>(() => data?.getInvoices || [], [data?.getInvoices]);\n\n const openInvoices = useMemo(() => {\n return invoices.filter((inv) => inv.status === ('OPEN' as InvoiceStatus));\n }, [invoices]);\n\n const paidInvoices = useMemo(() => {\n return invoices.filter((inv) => inv.status === ('PAID' as InvoiceStatus));\n }, [invoices]);\n\n const handleRefetch = useCallback(async () => {\n await refetch();\n }, [refetch]);\n\n return {\n invoices,\n openInvoices,\n paidInvoices,\n isLoading: loading,\n error: error as Error | undefined,\n refetch: handleRefetch,\n };\n}\n\n/**\n * Hook for fetching paginated invoices\n */\nexport function usePaginatedInvoices(\n options: UsePaginatedInvoicesOptions = {}\n): UsePaginatedInvoicesResult {\n const { status, billingAccountId, page = 1, pageSize = 20, search } = options;\n\n const { data, loading, error, refetch } = useGetPaginatedInvoicesQuery({\n variables: { status, billingAccountId, page, pageSize, search: search || undefined },\n fetchPolicy: 'cache-and-network',\n });\n\n const handleRefetch = useCallback(async () => {\n await refetch();\n }, [refetch]);\n\n return {\n invoices: data?.getPaginatedInvoices?.invoices || [],\n totalCount: data?.getPaginatedInvoices?.totalCount || 0,\n hasMore: data?.getPaginatedInvoices?.hasMore || false,\n page: data?.getPaginatedInvoices?.page || 1,\n pageSize: data?.getPaginatedInvoices?.pageSize || pageSize,\n totalPages: data?.getPaginatedInvoices?.totalPages || 0,\n isLoading: loading,\n error: error as Error | undefined,\n refetch: handleRefetch,\n };\n}\n\n/**\n * Hook for fetching a single invoice by ID\n */\nexport function useInvoice(\n id: string | undefined,\n billingAccountId: string | undefined\n): UseInvoiceResult {\n const { data, loading, error, refetch } = useGetInvoiceQuery({\n variables: { id: id!, billingAccountId: billingAccountId! },\n skip: !id || !billingAccountId,\n fetchPolicy: 'cache-and-network',\n });\n\n const handleRefetch = useCallback(async () => {\n await refetch();\n }, [refetch]);\n\n return {\n invoice: data?.getInvoice || null,\n isLoading: loading,\n error: error as Error | undefined,\n refetch: handleRefetch,\n };\n}\n\n/**\n * Hook for fetching an invoice by number\n */\nexport function useInvoiceByNumber(\n invoiceNumber: string | undefined,\n billingAccountId: string | undefined\n): UseInvoiceResult {\n const { data, loading, error, refetch } = useGetInvoiceByNumberQuery({\n variables: { invoiceNumber: invoiceNumber!, billingAccountId: billingAccountId! },\n skip: !invoiceNumber || !billingAccountId,\n fetchPolicy: 'cache-and-network',\n });\n\n const handleRefetch = useCallback(async () => {\n await refetch();\n }, [refetch]);\n\n return {\n invoice: data?.getInvoiceByNumber || null,\n isLoading: loading,\n error: error as Error | undefined,\n refetch: handleRefetch,\n };\n}\n\n/**\n * Hook for invoice mutations\n */\nexport function useInvoiceMutations(): UseInvoiceMutationsResult {\n const client = useApolloClient();\n\n const [generateInvoiceMutation, { loading: isGenerating }] = useGenerateInvoiceMutation();\n const [payInvoiceMutation, { loading: isPaying }] = usePayInvoiceMutation();\n const [voidInvoiceMutation, { loading: isVoiding }] = useVoidInvoiceMutation();\n const [retryInvoiceGenerationMutation, { loading: isRetrying }] =\n useRetryInvoiceGenerationMutation();\n\n const generateInvoice = useCallback(\n async (subscriptionId: string, billingAccountId: string): Promise<Invoice> => {\n try {\n const { data } = await generateInvoiceMutation({\n variables: { subscriptionId, billingAccountId },\n });\n await client.refetchQueries({\n include: [GetInvoicesDocument, GetPaginatedInvoicesDocument],\n });\n return data!.generateInvoice;\n } catch (error) {\n console.error('Failed to generate invoice:', error);\n throw error;\n }\n },\n [generateInvoiceMutation, client]\n );\n\n const payInvoice = useCallback(\n async (\n invoiceId: string,\n paymentMethodId: string,\n billingAccountId: string\n ): Promise<Invoice> => {\n try {\n const { data } = await payInvoiceMutation({\n variables: { invoiceId, paymentMethodId, billingAccountId },\n });\n await client.refetchQueries({\n include: [GetInvoicesDocument, GetPaginatedInvoicesDocument],\n });\n return data!.payInvoice;\n } catch (error) {\n console.error('Failed to pay invoice:', error);\n throw error;\n }\n },\n [payInvoiceMutation, client]\n );\n\n const voidInvoice = useCallback(\n async (invoiceId: string, billingAccountId: string): Promise<Invoice> => {\n try {\n const { data } = await voidInvoiceMutation({\n variables: { invoiceId, billingAccountId },\n });\n await client.refetchQueries({\n include: [GetInvoicesDocument, GetPaginatedInvoicesDocument],\n });\n return data!.voidInvoice;\n } catch (error) {\n console.error('Failed to void invoice:', error);\n throw error;\n }\n },\n [voidInvoiceMutation, client]\n );\n\n const retryInvoiceGeneration = useCallback(\n async (transactionId: string, billingAccountId: string): Promise<Invoice> => {\n try {\n const { data } = await retryInvoiceGenerationMutation({\n variables: { transactionId, billingAccountId },\n });\n // The transaction moves from \"no invoice yet\" to \"has an invoice\" —\n // refetch both the invoice list (it'll now include this one) and the\n // transactions list (its missing-invoice indicator should clear).\n await client.refetchQueries({\n include: [\n GetInvoicesDocument,\n GetPaginatedInvoicesDocument,\n GetTransactionsByBillingAccountDocument,\n ],\n });\n return data!.retryInvoiceGeneration;\n } catch (error) {\n console.error('Failed to retry invoice generation:', error);\n throw error;\n }\n },\n [retryInvoiceGenerationMutation, client]\n );\n\n return {\n generateInvoice,\n payInvoice,\n voidInvoice,\n retryInvoiceGeneration,\n isGenerating,\n isPaying,\n isVoiding,\n isRetrying,\n };\n}\n"],"mappings":";;;;AAwFA,SAAgBA,EAAY,IAA8B,CAAC,GAAsB;CAC/E,IAAM,EAAE,WAAQ,wBAAqBC,GAE/B,EAAE,SAAM,YAAS,UAAO,eAAYC,EAAoB;EAC5D,WAAW;GAAE;GAAQ;EAAiB;EACtC,aAAa;CACf,CAAC,GAEKC,IAAWC,QAAyBC,GAAM,eAAe,CAAC,GAAG,CAACA,GAAM,WAAW,CAAC;CActF,OAAO;EACL;EACA,cAdmBD,QACZD,EAAS,QAAQ,MAAQG,EAAI,WAAY,MAAwB,GACvE,CAACH,CAAQ,CAYV;EACA,cAXmBC,QACZD,EAAS,QAAQ,MAAQG,EAAI,W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;IAWD,OAPA,MAAMX,EAAO,eAAe,EAC1B,SAAS;KACPc;KACAC;KACAE;IACF,EACF,CAAC,GACMhC,EAAM;GACf,SAAS+B,GAAO;IAEd,MADA,QAAQ,MAAM,uCAAuCA,CAAK,GACpDA;GACR;EACF,GACA,CAACL,GAAgCX,CAAM,CAOvC;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useInvoices.js","names":["usePaginatedInvoices","options","useGetPaginatedInvoicesQuery","search","handleRefetch","useCallback","refetch","data","pageSize","loading","useInvoice","useGetInvoiceQuery","id","billingAccountId","useInvoiceMutations","client","useApolloClient","generateInvoiceMutation","isGenerating","useGenerateInvoiceMutation","payInvoiceMutation","isPaying","usePayInvoiceMutation","voidInvoiceMutation","isVoiding","useVoidInvoiceMutation","retryInvoiceGenerationMutation","isRetrying","useRetryInvoiceGenerationMutation","GetInvoicesDocument","GetPaginatedInvoicesDocument","error","GetTransactionsByBillingAccountDocument"],"sources":["../../../../../src/billing/modules/billing/hooks/useInvoices.ts"],"sourcesContent":["/**\n * Billing Module - useInvoices Hook\n * Provides access to invoice data and mutations\n */\n\nimport { useApolloClient } from '@apollo/client/react';\nimport { useCallback, useMemo } from 'react';\nimport {\n useGetInvoicesQuery,\n useGetInvoiceQuery,\n useGetInvoiceByNumberQuery,\n useGenerateInvoiceMutation,\n usePayInvoiceMutation,\n useVoidInvoiceMutation,\n useRetryInvoiceGenerationMutation,\n GetInvoicesDocument,\n GetPaginatedInvoicesDocument,\n GetTransactionsByBillingAccountDocument,\n useGetPaginatedInvoicesQuery,\n} from '../../../../generated/global-operations';\nimport type { Invoice, InvoiceStatus } from '../../../shared/types';\n\ninterface UseInvoicesOptions {\n status?: InvoiceStatus;\n billingAccountId?: string;\n}\n\ninterface UseInvoicesResult {\n invoices: Invoice[];\n openInvoices: Invoice[];\n paidInvoices: Invoice[];\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\ninterface UsePaginatedInvoicesOptions {\n status?: InvoiceStatus;\n billingAccountId?: string;\n page?: number;\n pageSize?: number;\n search?: string;\n}\n\ninterface UsePaginatedInvoicesResult {\n invoices: Invoice[];\n totalCount: number;\n hasMore: boolean;\n page: number;\n pageSize: number;\n totalPages: number;\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\ninterface UseInvoiceResult {\n invoice: Invoice | null;\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\ninterface UseInvoiceMutationsResult {\n generateInvoice: (subscriptionId: string, billingAccountId: string) => Promise<Invoice>;\n payInvoice: (\n invoiceId: string,\n paymentMethodId: string,\n billingAccountId: string\n ) => Promise<Invoice>;\n voidInvoice: (invoiceId: string, billingAccountId: string) => Promise<Invoice>;\n /**\n * Retry invoice generation for a successful transaction that never got an\n * invoice recorded (a transient Zoho Books/Stripe Invoicing failure at\n * payment time). transactionId comes from getTransactionsByBillingAccount\n * / getTransaction — these transactions never appear in the invoice list,\n * which only shows transactions that already have one.\n */\n retryInvoiceGeneration: (transactionId: string, billingAccountId: string) => Promise<Invoice>;\n isGenerating: boolean;\n isPaying: boolean;\n isVoiding: boolean;\n isRetrying: boolean;\n}\n\n/**\n * Hook for fetching invoices\n */\nexport function useInvoices(options: UseInvoicesOptions = {}): UseInvoicesResult {\n const { status, billingAccountId } = options;\n\n const { data, loading, error, refetch } = useGetInvoicesQuery({\n variables: { status, billingAccountId },\n fetchPolicy: 'cache-and-network',\n });\n\n const invoices = useMemo<Invoice[]>(() => data?.getInvoices || [], [data?.getInvoices]);\n\n const openInvoices = useMemo(() => {\n return invoices.filter((inv) => inv.status === ('OPEN' as InvoiceStatus));\n }, [invoices]);\n\n const paidInvoices = useMemo(() => {\n return invoices.filter((inv) => inv.status === ('PAID' as InvoiceStatus));\n }, [invoices]);\n\n const handleRefetch = useCallback(async () => {\n await refetch();\n }, [refetch]);\n\n return {\n invoices,\n openInvoices,\n paidInvoices,\n isLoading: loading,\n error: error as Error | undefined,\n refetch: handleRefetch,\n };\n}\n\n/**\n * Hook for fetching paginated invoices\n */\nexport function usePaginatedInvoices(\n options: UsePaginatedInvoicesOptions = {}\n): UsePaginatedInvoicesResult {\n const { status, billingAccountId, page = 1, pageSize = 20, search } = options;\n\n const { data, loading, error, refetch } = useGetPaginatedInvoicesQuery({\n variables: { status, billingAccountId, page, pageSize, search: search || undefined },\n fetchPolicy: 'cache-and-network',\n });\n\n const handleRefetch = useCallback(async () => {\n await refetch();\n }, [refetch]);\n\n return {\n invoices: data?.getPaginatedInvoices?.invoices || [],\n totalCount: data?.getPaginatedInvoices?.totalCount || 0,\n hasMore: data?.getPaginatedInvoices?.hasMore || false,\n page: data?.getPaginatedInvoices?.page || 1,\n pageSize: data?.getPaginatedInvoices?.pageSize || pageSize,\n totalPages: data?.getPaginatedInvoices?.totalPages || 0,\n isLoading: loading,\n error: error as Error | undefined,\n refetch: handleRefetch,\n };\n}\n\n/**\n * Hook for fetching a single invoice by ID\n */\nexport function useInvoice(\n id: string | undefined,\n billingAccountId: string | undefined\n): UseInvoiceResult {\n const { data, loading, error, refetch } = useGetInvoiceQuery({\n variables: { id: id!, billingAccountId: billingAccountId! },\n skip: !id || !billingAccountId,\n fetchPolicy: 'cache-and-network',\n });\n\n const handleRefetch = useCallback(async () => {\n await refetch();\n }, [refetch]);\n\n return {\n invoice: data?.getInvoice || null,\n isLoading: loading,\n error: error as Error | undefined,\n refetch: handleRefetch,\n };\n}\n\n/**\n * Hook for fetching an invoice by number\n */\nexport function useInvoiceByNumber(\n invoiceNumber: string | undefined,\n billingAccountId: string | undefined\n): UseInvoiceResult {\n const { data, loading, error, refetch } = useGetInvoiceByNumberQuery({\n variables: { invoiceNumber: invoiceNumber!, billingAccountId: billingAccountId! },\n skip: !invoiceNumber || !billingAccountId,\n fetchPolicy: 'cache-and-network',\n });\n\n const handleRefetch = useCallback(async () => {\n await refetch();\n }, [refetch]);\n\n return {\n invoice: data?.getInvoiceByNumber || null,\n isLoading: loading,\n error: error as Error | undefined,\n refetch: handleRefetch,\n };\n}\n\n/**\n * Hook for invoice mutations\n */\nexport function useInvoiceMutations(): UseInvoiceMutationsResult {\n const client = useApolloClient();\n\n const [generateInvoiceMutation, { loading: isGenerating }] = useGenerateInvoiceMutation();\n const [payInvoiceMutation, { loading: isPaying }] = usePayInvoiceMutation();\n const [voidInvoiceMutation, { loading: isVoiding }] = useVoidInvoiceMutation();\n const [retryInvoiceGenerationMutation, { loading: isRetrying }] =\n useRetryInvoiceGenerationMutation();\n\n const generateInvoice = useCallback(\n async (subscriptionId: string, billingAccountId: string): Promise<Invoice> => {\n try {\n const { data } = await generateInvoiceMutation({\n variables: { subscriptionId, billingAccountId },\n });\n await client.refetchQueries({\n include: [GetInvoicesDocument, GetPaginatedInvoicesDocument],\n });\n return data!.generateInvoice;\n } catch (error) {\n console.error('Failed to generate invoice:', error);\n throw error;\n }\n },\n [generateInvoiceMutation, client]\n );\n\n const payInvoice = useCallback(\n async (\n invoiceId: string,\n paymentMethodId: string,\n billingAccountId: string\n ): Promise<Invoice> => {\n try {\n const { data } = await payInvoiceMutation({\n variables: { invoiceId, paymentMethodId, billingAccountId },\n });\n await client.refetchQueries({\n include: [GetInvoicesDocument, GetPaginatedInvoicesDocument],\n });\n return data!.payInvoice;\n } catch (error) {\n console.error('Failed to pay invoice:', error);\n throw error;\n }\n },\n [payInvoiceMutation, client]\n );\n\n const voidInvoice = useCallback(\n async (invoiceId: string, billingAccountId: string): Promise<Invoice> => {\n try {\n const { data } = await voidInvoiceMutation({\n variables: { invoiceId, billingAccountId },\n });\n await client.refetchQueries({\n include: [GetInvoicesDocument, GetPaginatedInvoicesDocument],\n });\n return data!.voidInvoice;\n } catch (error) {\n console.error('Failed to void invoice:', error);\n throw error;\n }\n },\n [voidInvoiceMutation, client]\n );\n\n const retryInvoiceGeneration = useCallback(\n async (transactionId: string, billingAccountId: string): Promise<Invoice> => {\n try {\n const { data } = await retryInvoiceGenerationMutation({\n variables: { transactionId, billingAccountId },\n });\n // The transaction moves from \"no invoice yet\" to \"has an invoice\" —\n // refetch both the invoice list (it'll now include this one) and the\n // transactions list (its missing-invoice indicator should clear).\n await client.refetchQueries({\n include: [\n GetInvoicesDocument,\n GetPaginatedInvoicesDocument,\n GetTransactionsByBillingAccountDocument,\n ],\n });\n return data!.retryInvoiceGeneration;\n } catch (error) {\n console.error('Failed to retry invoice generation:', error);\n throw error;\n }\n },\n [retryInvoiceGenerationMutation, client]\n );\n\n return {\n generateInvoice,\n payInvoice,\n voidInvoice,\n retryInvoiceGeneration,\n isGenerating,\n isPaying,\n isVoiding,\n isRetrying,\n };\n}\n"],"mappings":";;;;AA2HA,SAAgBA,EACd,IAAuC,CAAC,GACZ;CAC5B,IAAM,EAAE,WAAQ,qBAAkB,UAAO,GAAG,cAAW,IAAI,cAAWC,GAEhE,EAAE,SAAM,YAAS,UAAO,eAAYC,EAA6B;EACrE,WAAW;GAAE;GAAQ;GAAkB;GAAM;GAAU,QAAQC,KAAU,KAAA;EAAU;EACnF,aAAa;CACf,CAAC,GAEKC,IAAgBC,EAAY,YAAY;EAC5C,MAAMC,EAAQ;CAChB,GAAG,CAACA,CAAO,CAAC;CAEZ,OAAO;EACL,UAAUC,GAAM,sBAAsB,YAAY,CAAC;EACnD,YAAYA,GAAM,sBAAsB,cAAc;EACtD,SAASA,GAAM,sBAAsB,WAAW;EAChD,MAAMA,GAAM,sBAAsB,QAAQ;EAC1C,UAAUA,GAAM,sBAAsB,YAAYC;EAClD,YAAYD,GAAM,sBAAsB,cAAc;EACtD,WAAWE;EACJ;EACP,SAASL;CACX;AACF;AAKA,SAAgBM,EACd,GACA,GACkB;CAClB,IAAM,EAAE,SAAM,YAAS,UAAO,eAAYC,EAAmB;EAC3D,WAAW;GAAM;GAAuB;EAAkB;EAC1D,MAAM,CAACC,KAAM,CAACC;EACd,aAAa;CACf,CAAC,GAEKT,IAAgBC,EAAY,YAAY;EAC5C,MAAMC,EAAQ;CAChB,GAAG,CAACA,CAAO,CA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EAAM;GACf,SAASwB,GAAO;IAEd,MADA,QAAQ,MAAM,2BAA2BA,CAAK,GACxCA;GACR;EACF,GACA,CAACR,GAAqBR,CAAM,CA+B5B;EACA,wBA7B6BV,EAC7B,OAAO,GAAuB,MAA+C;GAC3E,IAAI;IACF,IAAM,EAAE,YAAS,MAAMqB,EAA+B,EACpD,WAAW;KAAE;KAAe;IAAiB,EAC/C,CAAC;IAWD,OAPA,MAAMX,EAAO,eAAe,EAC1B,SAAS;KACPc;KACAC;KACAE;IACF,EACF,CAAC,GACMzB,EAAM;GACf,SAASwB,GAAO;IAEd,MADA,QAAQ,MAAM,uCAAuCA,CAAK,GACpDA;GACR;EACF,GACA,CAACL,GAAgCX,CAAM,CAOvC;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { useInvoiceMutations as e
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { useInvoiceMutations as e } from "./hooks/useInvoices.js";
|
|
2
|
+
import { InvoicesListPage as t } from "./pages/InvoicesListPage.js";
|
|
3
|
+
import { InvoiceDetailPage as n } from "./pages/InvoiceDetailPage.js";
|
|
4
|
+
import { useTransactions as r } from "./hooks/useTransactions.js";
|
|
5
|
+
import { useBillingWebhookLogs as i, useRefundMutations as a, useRefundRecords as o, useRefunds as s } from "./hooks/useRefunds.js";
|
|
6
|
+
import { useOrderCallbackMutations as c, useOrderCallbacks as l } from "./hooks/useOrderCallbacks.js";
|
|
5
7
|
import "./pages/index.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { BillingWebhookLogsPage as g } from "./pages/BillingWebhookLogsPage.js";
|
|
14
|
-
import { OrderCallbackLogsPage as _ } from "./pages/OrderCallbackLogsPage.js";
|
|
8
|
+
import { TransactionsPage as u } from "./pages/TransactionsPage.js";
|
|
9
|
+
import { PaymentMethodsPage as d } from "./pages/PaymentMethodsPage.js";
|
|
10
|
+
import { RefundsPage as f } from "./pages/RefundsPage.js";
|
|
11
|
+
import { RefundIssueLogsPage as p } from "./pages/RefundIssueLogsPage.js";
|
|
12
|
+
import { UserRefundsPage as m } from "./pages/UserRefundsPage.js";
|
|
13
|
+
import { BillingWebhookLogsPage as h } from "./pages/BillingWebhookLogsPage.js";
|
|
14
|
+
import { OrderCallbackLogsPage as g } from "./pages/OrderCallbackLogsPage.js";
|
|
15
15
|
import "./hooks/index.js";
|
|
16
|
-
export {
|
|
16
|
+
export { h as BillingWebhookLogsPage, n as InvoiceDetailPage, t as InvoicesListPage, g as OrderCallbackLogsPage, d as PaymentMethodsPage, p as RefundIssueLogsPage, f as RefundsPage, u as TransactionsPage, m as UserRefundsPage, i as useBillingWebhookLogs, e as useInvoiceMutations, c as useOrderCallbackMutations, l as useOrderCallbacks, a as useRefundMutations, o as useRefundRecords, s as useRefunds, r as useTransactions };
|
|
@@ -19,61 +19,61 @@ import { useSearchParams as E } from "react-router";
|
|
|
19
19
|
import { Fragment as D, jsx as O, jsxs as k } from "react/jsx-runtime";
|
|
20
20
|
// src/billing/modules/billing/pages/InvoicesListPage.tsx
|
|
21
21
|
var A = () => {
|
|
22
|
-
let t = m(), i =
|
|
22
|
+
let t = m(), i = p(), s = e(), c = a(), [l] = E(), f = l.get("billingAccountId") ?? void 0, { data: h } = o({ fetchPolicy: "cache-first" }), g = b(() => h?.getBillingAccountsByOrg ?? [], [h]), { payInvoice: A, voidInvoice: M } = n(), [N, P] = S(null), [F, I] = S(null), [L, R] = S(f);
|
|
23
23
|
y(() => {
|
|
24
|
-
|
|
25
|
-
}, [
|
|
26
|
-
let
|
|
27
|
-
y(() => (
|
|
28
|
-
|
|
24
|
+
R(f);
|
|
25
|
+
}, [f]);
|
|
26
|
+
let ee = b(() => (g.find((e) => e.isDefault) ?? g[0])?.id ?? void 0, [g]), z = L === void 0 ? ee ?? null : L, [B, V] = S("all"), [H, U] = S(""), [W, G] = S(""), [K, q] = S(1), J = x(null);
|
|
27
|
+
y(() => (J.current && clearTimeout(J.current), J.current = setTimeout(() => {
|
|
28
|
+
G(H), q(1);
|
|
29
29
|
}, 400), () => {
|
|
30
|
-
|
|
31
|
-
}), [
|
|
32
|
-
let { invoices:
|
|
33
|
-
billingAccountId:
|
|
34
|
-
status:
|
|
35
|
-
search:
|
|
36
|
-
page:
|
|
30
|
+
J.current && clearTimeout(J.current);
|
|
31
|
+
}), [H]);
|
|
32
|
+
let { invoices: Y, totalPages: X, isLoading: Z, error: Q, refetch: $ } = r({
|
|
33
|
+
billingAccountId: z ?? void 0,
|
|
34
|
+
status: B === "all" ? void 0 : B,
|
|
35
|
+
search: W || void 0,
|
|
36
|
+
page: K,
|
|
37
37
|
pageSize: 20
|
|
38
|
-
}),
|
|
39
|
-
let t = e.billingAccountId, n = t ?
|
|
40
|
-
if (!t)
|
|
41
|
-
else if (!n)
|
|
38
|
+
}), te = v(async (e) => {
|
|
39
|
+
let t = e.billingAccountId, n = t ? g.find((e) => e.id === t)?.defaultPaymentMethod : void 0;
|
|
40
|
+
if (!t) P("No billing account context");
|
|
41
|
+
else if (!n) P("Add and set a default payment method before paying this invoice.");
|
|
42
42
|
else {
|
|
43
|
-
|
|
43
|
+
P(null), I({
|
|
44
44
|
invoiceId: e.id,
|
|
45
45
|
action: "pay"
|
|
46
46
|
});
|
|
47
47
|
try {
|
|
48
|
-
await
|
|
48
|
+
await A(e.id, n, t), await $(), _("success");
|
|
49
49
|
} catch (e) {
|
|
50
|
-
|
|
50
|
+
P(e instanceof Error ? e.message : "Failed to pay invoice"), _("error");
|
|
51
51
|
} finally {
|
|
52
|
-
|
|
52
|
+
I(null);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}, [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
]),
|
|
56
|
+
g,
|
|
57
|
+
A,
|
|
58
|
+
$
|
|
59
|
+
]), ne = v(async (e) => {
|
|
60
60
|
let t = e.billingAccountId;
|
|
61
|
-
if (!t)
|
|
61
|
+
if (!t) P("No billing account context");
|
|
62
62
|
else {
|
|
63
|
-
|
|
63
|
+
P(null), I({
|
|
64
64
|
invoiceId: e.id,
|
|
65
65
|
action: "void"
|
|
66
66
|
});
|
|
67
67
|
try {
|
|
68
|
-
await
|
|
68
|
+
await M(e.id, t), await $(), _("success");
|
|
69
69
|
} catch (e) {
|
|
70
|
-
|
|
70
|
+
P(e instanceof Error ? e.message : "Failed to void invoice"), _("error");
|
|
71
71
|
} finally {
|
|
72
|
-
|
|
72
|
+
I(null);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
}, [
|
|
76
|
-
return
|
|
75
|
+
}, [$, M]);
|
|
76
|
+
return c.canViewInvoices ? Z && Y.length === 0 ? /* @__PURE__ */ k("div", {
|
|
77
77
|
className: "space-y-6 p-6",
|
|
78
78
|
children: [/* @__PURE__ */ O("div", { className: "h-8 w-48 bg-bg-sunken animate-pulse rounded" }), /* @__PURE__ */ O("div", {
|
|
79
79
|
className: "space-y-3",
|
|
@@ -94,7 +94,7 @@ var A = () => {
|
|
|
94
94
|
})
|
|
95
95
|
}, e))
|
|
96
96
|
})]
|
|
97
|
-
}) :
|
|
97
|
+
}) : Q ? /* @__PURE__ */ O("div", {
|
|
98
98
|
className: "flex items-center justify-center h-full min-h-[400px]",
|
|
99
99
|
children: /* @__PURE__ */ k("div", {
|
|
100
100
|
className: "text-center space-y-4",
|
|
@@ -120,11 +120,11 @@ var A = () => {
|
|
|
120
120
|
}),
|
|
121
121
|
/* @__PURE__ */ O("p", {
|
|
122
122
|
className: "text-sm text-text-secondary",
|
|
123
|
-
children:
|
|
123
|
+
children: Q.message
|
|
124
124
|
}),
|
|
125
125
|
/* @__PURE__ */ O("button", {
|
|
126
126
|
type: "button",
|
|
127
|
-
onClick: () =>
|
|
127
|
+
onClick: () => $(),
|
|
128
128
|
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",
|
|
129
129
|
children: t("billing.common.tryAgain", "Try Again")
|
|
130
130
|
})
|
|
@@ -134,40 +134,43 @@ var A = () => {
|
|
|
134
134
|
className: "space-y-6 px-6 lg:px-8 py-6",
|
|
135
135
|
children: [
|
|
136
136
|
/* @__PURE__ */ k("div", {
|
|
137
|
-
className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
|
|
138
|
-
children: [/* @__PURE__ */ k("div", {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
137
|
+
className: i ? "flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between" : "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
|
|
138
|
+
children: [/* @__PURE__ */ k("div", {
|
|
139
|
+
className: i ? "min-w-0 xl:max-w-3xl" : void 0,
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ O("h1", {
|
|
142
|
+
className: "text-2xl md:text-3xl font-semibold tracking-tight text-text-primary",
|
|
143
|
+
children: t("billing.invoices.title", "Invoices")
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ O("p", {
|
|
146
|
+
className: "text-sm text-text-secondary mt-1",
|
|
147
|
+
children: t("billing.invoices.subtitle", "View and manage your billing invoices")
|
|
148
|
+
}),
|
|
149
|
+
/* @__PURE__ */ O(w, {
|
|
150
|
+
className: "mt-3",
|
|
151
|
+
children: t("billing.invoices.purpose", "A record of everything you have been billed for — subscriptions, add-ons and one-off charges. Open an invoice to see line items, download the PDF, pay an outstanding amount, or request a refund.")
|
|
152
|
+
})
|
|
153
|
+
]
|
|
154
|
+
}), /* @__PURE__ */ k("div", {
|
|
155
|
+
className: i ? "flex flex-wrap items-center gap-3 xl:shrink-0 xl:justify-end" : "flex items-center gap-3",
|
|
153
156
|
children: [/* @__PURE__ */ k("button", {
|
|
154
157
|
type: "button",
|
|
155
|
-
onClick: () =>
|
|
156
|
-
className: "inline-flex items-center gap-2 px-3 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken hover:border-border-strong transition-all duration-200",
|
|
158
|
+
onClick: () => s("/refunds"),
|
|
159
|
+
className: "inline-flex items-center gap-2 whitespace-nowrap px-3 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken hover:border-border-strong transition-all duration-200",
|
|
157
160
|
children: [/* @__PURE__ */ O(T, { className: "size-4" }), t("billing.invoices.myRefunds", "My Refunds")]
|
|
158
|
-
}),
|
|
159
|
-
className: "flex items-center gap-2",
|
|
161
|
+
}), g.length > 1 && /* @__PURE__ */ k("div", {
|
|
162
|
+
className: i ? "flex w-full min-w-0 items-center gap-2 sm:w-auto" : "flex items-center gap-2",
|
|
160
163
|
children: [/* @__PURE__ */ O("label", {
|
|
161
164
|
className: "text-sm text-text-secondary whitespace-nowrap",
|
|
162
165
|
children: t("billing.invoices.billingAccountLabel", "Billing Account")
|
|
163
166
|
}), /* @__PURE__ */ k("select", {
|
|
164
|
-
value:
|
|
165
|
-
onChange: (e) =>
|
|
166
|
-
className: "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
|
|
167
|
+
value: z ?? "",
|
|
168
|
+
onChange: (e) => R(e.target.value || null),
|
|
169
|
+
className: `${i ? "min-w-0 flex-1 truncate sm:max-w-xs sm:flex-none " : ""}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`,
|
|
167
170
|
children: [/* @__PURE__ */ O("option", {
|
|
168
171
|
value: "",
|
|
169
172
|
children: t("billing.invoices.allAccounts", "All Accounts")
|
|
170
|
-
}),
|
|
173
|
+
}), g.map((e) => /* @__PURE__ */ k("option", {
|
|
171
174
|
value: e.id ?? "",
|
|
172
175
|
children: [e.name ?? e.email ?? e.id, e.isDefault ? t("billing.invoices.defaultSuffix", " (Default)") : ""]
|
|
173
176
|
}, e.id ?? ""))]
|
|
@@ -188,9 +191,9 @@ var A = () => {
|
|
|
188
191
|
].map((e) => /* @__PURE__ */ O("button", {
|
|
189
192
|
type: "button",
|
|
190
193
|
onClick: () => {
|
|
191
|
-
|
|
194
|
+
V(e), q(1);
|
|
192
195
|
},
|
|
193
|
-
className: `px-3 py-1.5 text-sm font-medium rounded-button transition-colors ${
|
|
196
|
+
className: `px-3 py-1.5 text-sm font-medium rounded-button transition-colors ${B === e ? "bg-bg-surface text-text-primary shadow-sm" : "text-text-secondary hover:text-text-primary"}`,
|
|
194
197
|
children: e === "all" ? "All" : u(e)
|
|
195
198
|
}, e))
|
|
196
199
|
}), /* @__PURE__ */ k("div", {
|
|
@@ -209,25 +212,25 @@ var A = () => {
|
|
|
209
212
|
}), /* @__PURE__ */ O("input", {
|
|
210
213
|
type: "text",
|
|
211
214
|
placeholder: t("billing.invoices.searchPlaceholder", "Search by invoice number..."),
|
|
212
|
-
value:
|
|
213
|
-
onChange: (e) =>
|
|
215
|
+
value: H,
|
|
216
|
+
onChange: (e) => U(e.target.value),
|
|
214
217
|
className: "w-full pl-[3.25rem] pr-4 py-2 text-sm border border-border-subtle rounded-button bg-bg-surface text-text-primary placeholder:text-text-placeholder focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] focus:border-transparent"
|
|
215
218
|
})]
|
|
216
219
|
})]
|
|
217
220
|
}),
|
|
218
|
-
|
|
221
|
+
N && /* @__PURE__ */ O("div", {
|
|
219
222
|
className: "rounded-button border border-status-error-border bg-status-error-bg-subtle p-3",
|
|
220
223
|
children: /* @__PURE__ */ O("p", {
|
|
221
224
|
className: "text-sm text-status-error-text",
|
|
222
|
-
children:
|
|
225
|
+
children: N
|
|
223
226
|
})
|
|
224
227
|
}),
|
|
225
|
-
!
|
|
226
|
-
illustration:
|
|
228
|
+
!Z && Y.length === 0 ? /* @__PURE__ */ O(C, {
|
|
229
|
+
illustration: B !== "all" || W ? "empty-search" : "empty-files",
|
|
227
230
|
title: t("billing.invoices.noInvoicesFound", "No invoices found"),
|
|
228
|
-
description:
|
|
231
|
+
description: B !== "all" || W ? t("billing.invoices.noInvoicesFiltered", "No invoices match your filters.") : t("billing.invoices.noInvoicesYet", "You don't have any invoices yet.")
|
|
229
232
|
}) : /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O("div", {
|
|
230
|
-
className:
|
|
233
|
+
className: `border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 ${i ? "overflow-x-auto" : "overflow-hidden"}`,
|
|
231
234
|
children: /* @__PURE__ */ k("table", {
|
|
232
235
|
className: "w-full",
|
|
233
236
|
children: [/* @__PURE__ */ O("thead", {
|
|
@@ -241,7 +244,7 @@ var A = () => {
|
|
|
241
244
|
className: "text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted",
|
|
242
245
|
children: t("billing.common.status", "Status")
|
|
243
246
|
}),
|
|
244
|
-
!
|
|
247
|
+
!z && g.length > 1 && /* @__PURE__ */ O("th", {
|
|
245
248
|
className: "text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted hidden lg:table-cell",
|
|
246
249
|
children: t("billing.common.account", "Account")
|
|
247
250
|
}),
|
|
@@ -264,40 +267,40 @@ var A = () => {
|
|
|
264
267
|
] })
|
|
265
268
|
}), /* @__PURE__ */ O("tbody", {
|
|
266
269
|
className: "divide-y divide-border-subtle",
|
|
267
|
-
children:
|
|
270
|
+
children: Y.map((e) => /* @__PURE__ */ O(j, {
|
|
268
271
|
invoice: e,
|
|
269
|
-
onView: () =>
|
|
270
|
-
canPay:
|
|
271
|
-
canVoid:
|
|
272
|
-
onPay:
|
|
273
|
-
onVoid:
|
|
274
|
-
isProcessing:
|
|
275
|
-
processingAction:
|
|
276
|
-
showAccount: !
|
|
277
|
-
accountName:
|
|
272
|
+
onView: () => s(d(`/invoices/${e.id}`, e.billingAccountId)),
|
|
273
|
+
canPay: c.canPayInvoice,
|
|
274
|
+
canVoid: c.canVoidInvoice,
|
|
275
|
+
onPay: te,
|
|
276
|
+
onVoid: ne,
|
|
277
|
+
isProcessing: F?.invoiceId === e.id,
|
|
278
|
+
processingAction: F?.invoiceId === e.id ? F.action : void 0,
|
|
279
|
+
showAccount: !z && g.length > 1,
|
|
280
|
+
accountName: g.find((t) => t.id === e.billingAccountId)?.name ?? null
|
|
278
281
|
}, e.id))
|
|
279
282
|
})]
|
|
280
283
|
})
|
|
281
|
-
}),
|
|
284
|
+
}), X > 1 && /* @__PURE__ */ k("div", {
|
|
282
285
|
className: "flex items-center justify-between pt-2",
|
|
283
286
|
children: [/* @__PURE__ */ O("p", {
|
|
284
287
|
className: "text-sm text-text-secondary",
|
|
285
288
|
children: t("billing.common.pageOf", "Page {{page}} of {{totalPages}}", {
|
|
286
|
-
page:
|
|
287
|
-
totalPages:
|
|
289
|
+
page: K,
|
|
290
|
+
totalPages: X
|
|
288
291
|
})
|
|
289
292
|
}), /* @__PURE__ */ k("div", {
|
|
290
293
|
className: "flex items-center gap-2",
|
|
291
294
|
children: [/* @__PURE__ */ O("button", {
|
|
292
295
|
type: "button",
|
|
293
|
-
onClick: () =>
|
|
294
|
-
disabled:
|
|
296
|
+
onClick: () => q((e) => Math.max(1, e - 1)),
|
|
297
|
+
disabled: K <= 1,
|
|
295
298
|
className: "px-3 py-1.5 text-sm font-medium border border-border-subtle rounded-button bg-bg-surface text-text-primary hover:bg-bg-sunken disabled:opacity-40 disabled:cursor-not-allowed transition-colors",
|
|
296
299
|
children: t("billing.common.previous", "Previous")
|
|
297
300
|
}), /* @__PURE__ */ O("button", {
|
|
298
301
|
type: "button",
|
|
299
|
-
onClick: () =>
|
|
300
|
-
disabled:
|
|
302
|
+
onClick: () => q((e) => Math.min(X, e + 1)),
|
|
303
|
+
disabled: K >= X,
|
|
301
304
|
className: "px-3 py-1.5 text-sm font-medium border border-border-subtle rounded-button bg-bg-surface text-text-primary hover:bg-bg-sunken disabled:opacity-40 disabled:cursor-not-allowed transition-colors",
|
|
302
305
|
children: t("billing.common.next", "Next")
|
|
303
306
|
})]
|
|
@@ -400,13 +403,13 @@ var A = () => {
|
|
|
400
403
|
children: e.dueDate ? c(e.dueDate, "short") : "—"
|
|
401
404
|
}),
|
|
402
405
|
/* @__PURE__ */ O("td", {
|
|
403
|
-
className:
|
|
406
|
+
className: `p-4 text-right font-medium text-text-primary ${C ? "whitespace-nowrap" : ""}`,
|
|
404
407
|
children: s(e.total, e.currency)
|
|
405
408
|
}),
|
|
406
409
|
/* @__PURE__ */ O("td", {
|
|
407
410
|
className: "p-4 text-right",
|
|
408
411
|
children: /* @__PURE__ */ k("div", {
|
|
409
|
-
className:
|
|
412
|
+
className: `relative flex items-center justify-end ${C ? "flex-wrap gap-1" : "gap-2"}`,
|
|
410
413
|
children: [
|
|
411
414
|
e.invoiceUrl ? /* @__PURE__ */ O("a", {
|
|
412
415
|
href: e.invoiceUrl,
|