@burdenoff/microfe-billing 2026.514.5 → 2026.514.6

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.
@@ -17,6 +17,7 @@ interface UsePaginatedInvoicesOptions {
17
17
  billingAccountId?: string;
18
18
  page?: number;
19
19
  pageSize?: number;
20
+ search?: string;
20
21
  }
21
22
  interface UsePaginatedInvoicesResult {
22
23
  invoices: Invoice[];
@@ -1 +1 @@
1
- {"version":3,"file":"useInvoices.d.ts","sourceRoot":"","sources":["../../../../../src/billing/modules/billing/hooks/useInvoices.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEpE,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,UAAU,iBAAiB;IACzB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,YAAY,EAAE,OAAO,EAAE,CAAC;IACxB,YAAY,EAAE,OAAO,EAAE,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,UAAU,2BAA2B;IACnC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,0BAA0B;IAClC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAA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BAAyB,CAmE/D"}
1
+ {"version":3,"file":"useInvoices.d.ts","sourceRoot":"","sources":["../../../../../src/billing/modules/billing/hooks/useInvoices.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEpE,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,UAAU,iBAAiB;IACzB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,YAAY,EAAE,OAAO,EAAE,CAAC;IACxB,YAAY,EAAE,OAAO,EAAE,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,UAAU,2BAA2B;IACnC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,0BAA0B;IAClC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,UAAU,gBAAgB;IACxB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,UAAU,yBAAyB;IACjC,eAAe,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACxF,UAAU,EAAE,CACV,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,KACrB,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/E,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,iBAAiB,CA8B/E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,2BAAgC,GACxC,0BAA0B,CAuB5B;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,gBAAgB,EAAE,MAAM,GAAG,SAAS,GACnC,gBAAgB,CAiBlB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,gBAAgB,EAAE,MAAM,GAAG,SAAS,GACnC,gBAAgB,CAiBlB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,yBAAyB,CAmE/D"}
@@ -1,27 +1,33 @@
1
- import { GetInvoicesDocument as e, useGenerateInvoiceMutation as t, useGetInvoiceQuery as n, useGetInvoicesQuery as r, usePayInvoiceMutation as i, useVoidInvoiceMutation as a } from "../../../../generated/global-operations.js";
2
- import { useCallback as o, useMemo as s } from "react";
3
- import { useApolloClient as c } from "@apollo/client/react";
1
+ import { GetInvoicesDocument as e, useGenerateInvoiceMutation as t, useGetInvoiceQuery as n, useGetPaginatedInvoicesQuery as r, usePayInvoiceMutation as i, useVoidInvoiceMutation as a } from "../../../../generated/global-operations.js";
2
+ import { useCallback as o } from "react";
3
+ import { useApolloClient as s } from "@apollo/client/react";
4
4
  //#region src/billing/modules/billing/hooks/useInvoices.ts
5
- function l(e = {}) {
6
- let { status: t, billingAccountId: n } = e, { data: i, loading: a, error: c, refetch: l } = r({
5
+ function c(e = {}) {
6
+ let { status: t, billingAccountId: n, page: i = 1, pageSize: a = 20, search: s } = e, { data: c, loading: l, error: u, refetch: d } = r({
7
7
  variables: {
8
8
  status: t,
9
- billingAccountId: n
9
+ billingAccountId: n,
10
+ page: i,
11
+ pageSize: a,
12
+ search: s || void 0
10
13
  },
11
14
  fetchPolicy: "cache-and-network"
12
- }), u = s(() => i?.getInvoices || [], [i?.getInvoices]);
15
+ }), f = o(async () => {
16
+ await d();
17
+ }, [d]);
13
18
  return {
14
- invoices: u,
15
- openInvoices: s(() => u.filter((e) => e.status === "OPEN"), [u]),
16
- paidInvoices: s(() => u.filter((e) => e.status === "PAID"), [u]),
17
- isLoading: a,
18
- error: c,
19
- refetch: o(async () => {
20
- await l();
21
- }, [l])
19
+ invoices: c?.getPaginatedInvoices?.invoices || [],
20
+ totalCount: c?.getPaginatedInvoices?.totalCount || 0,
21
+ hasMore: c?.getPaginatedInvoices?.hasMore || !1,
22
+ page: c?.getPaginatedInvoices?.page || 1,
23
+ pageSize: c?.getPaginatedInvoices?.pageSize || a,
24
+ totalPages: c?.getPaginatedInvoices?.totalPages || 0,
25
+ isLoading: l,
26
+ error: u,
27
+ refetch: f
22
28
  };
23
29
  }
24
- function u(e, t) {
30
+ function l(e, t) {
25
31
  let { data: r, loading: i, error: a, refetch: s } = n({
26
32
  variables: {
27
33
  id: e,
@@ -39,8 +45,8 @@ function u(e, t) {
39
45
  refetch: c
40
46
  };
41
47
  }
42
- function d() {
43
- let n = c(), [r, { loading: s }] = t(), [l, { loading: u }] = i(), [d, { loading: f }] = a();
48
+ function u() {
49
+ let n = s(), [r, { loading: c }] = t(), [l, { loading: u }] = i(), [d, { loading: f }] = a();
44
50
  return {
45
51
  generateInvoice: o(async (t, i) => {
46
52
  try {
@@ -76,12 +82,12 @@ function d() {
76
82
  throw console.error("Failed to void invoice:", e), e;
77
83
  }
78
84
  }, [d, n]),
79
- isGenerating: s,
85
+ isGenerating: c,
80
86
  isPaying: u,
81
87
  isVoiding: f
82
88
  };
83
89
  }
84
90
  //#endregion
85
- export { u as useInvoice, d as useInvoiceMutations, l as useInvoices };
91
+ export { l as useInvoice, u as useInvoiceMutations, c as usePaginatedInvoices };
86
92
 
87
93
  //# sourceMappingURL=useInvoices.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useInvoices.js","names":[],"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 GetInvoicesDocument,\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}\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 isGenerating: boolean;\n isPaying: boolean;\n isVoiding: 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 } = options;\n\n const { data, loading, error, refetch } = useGetPaginatedInvoicesQuery({\n variables: { status, billingAccountId, page, pageSize },\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\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({ include: [GetInvoicesDocument] });\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({ include: [GetInvoicesDocument] });\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({ include: [GetInvoicesDocument] });\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 return {\n generateInvoice,\n payInvoice,\n voidInvoice,\n isGenerating,\n isPaying,\n isVoiding,\n };\n}\n"],"mappings":";;;;AA2EA,SAAgB,EAAY,IAA8B,EAAE,EAAqB;CAC/E,IAAM,EAAE,WAAQ,wBAAqB,GAE/B,EAAE,SAAM,YAAS,UAAO,eAAY,EAAoB;EAC5D,WAAW;GAAE;GAAQ;GAAkB;EACvC,aAAa;EACd,CAAC,EAEI,IAAW,QAAyB,GAAM,eAAe,EAAE,EAAE,CAAC,GAAM,YAAY,CAAC;AAcvF,QAAO;EACL;EACA,cAdmB,QACZ,EAAS,QAAQ,MAAQ,EAAI,WAAY,OAAyB,EACxE,CAAC,EAAS,CAAC;EAaZ,cAXmB,QACZ,EAAS,QAAQ,MAAQ,EAAI,WAAY,OAAyB,EACxE,CAAC,EAAS,CAAC;EAUZ,WAAW;EACJ;EACP,SAVoB,EAAY,YAAY;AAC5C,SAAM,GAAS;KACd,CAAC,EAAQ,CAAC;EASZ;;AAoCH,SAAgB,EACd,GACA,GACkB;CAClB,IA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O,eAAe,EAAE,SAAS,CAAC,EAAoB,EAAE,CAAC,EACxD,EAAM;YACN,GAAO;AAEd,UADA,QAAQ,MAAM,2BAA2B,EAAM,EACzC;;KAGV,CAAC,GAAqB,EAAO,CAC9B;EAMC;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useInvoices.js","names":[],"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 GetInvoicesDocument,\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 isGenerating: boolean;\n isPaying: boolean;\n isVoiding: 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\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({ include: [GetInvoicesDocument] });\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({ include: [GetInvoicesDocument] });\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({ include: [GetInvoicesDocument] });\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 return {\n generateInvoice,\n payInvoice,\n voidInvoice,\n isGenerating,\n isPaying,\n isVoiding,\n };\n}\n"],"mappings":";;;;AA+GA,SAAgB,EACd,IAAuC,EAAE,EACb;CAC5B,IAAM,EAAE,WAAQ,qBAAkB,UAAO,GAAG,cAAW,IAAI,cAAW,GAEhE,EAAE,SAAM,YAAS,UAAO,eAAY,EAA6B;EACrE,WAAW;GAAE;GAAQ;GAAkB;GAAM;GAAU,QAAQ,KAAU,KAAA;GAAW;EACpF,aAAa;EACd,CAAC,EAEI,IAAgB,EAAY,YAAY;AAC5C,QAAM,GAAS;IACd,CAAC,EAAQ,CAAC;AAEb,QAAO;EACL,UAAU,GAAM,sBAAsB,YAAY,EAAE;EACpD,YAAY,GAAM,sBAAsB,cAAc;EACtD,SAAS,GAAM,sBAAsB,WAAW;EAChD,MAAM,GAAM,sBAAsB,QAAQ;EAC1C,UAAU,GAAM,sBAAsB,YAAY;EAClD,YAAY,GAAM,sBAAsB,cAAc;EACtD,WAAW;EACJ;EACP,SAAS;EACV;;AAMH,SAAgB,EACd,GACA,GACkB;CAClB,IAAM,EAAE,SAAM,YAAS,UAAO,eAAY,EAAmB;EAC3D,WAAW;GAAM;GAAuB;GAAmB;EAC3D,MAAM,CAAC,KAAM,CAAC;EACd,aAAa;EACd,CAAC,EAEI,IAAgB,EAAY,YAAY;AAC5C,QAAM,GAAS;IACd,CAAC,EAAQ,CAAC;AAEb,QAAO;EACL,SAAS,GAAM,cAAc;EAC7B,WAAW;EACJ;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/pages/InvoicesListPage.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAgC,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAwB9D,eAAO,MAAM,gBAAgB,EAAE,EAsV9B,CAAC"}
1
+ {"version":3,"file":"InvoicesListPage.d.ts","sourceRoot":"","sources":["../../../../../src/billing/modules/billing/pages/InvoicesListPage.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAwC,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAwBtE,eAAO,MAAM,gBAAgB,EAAE,EAgV9B,CAAC"}