diff --git a/packages/console/src/pages/TenantSettings/BillingHistory/index.tsx b/packages/console/src/pages/TenantSettings/BillingHistory/index.tsx index dcaf56d78..4e6bd8aab 100644 --- a/packages/console/src/pages/TenantSettings/BillingHistory/index.tsx +++ b/packages/console/src/pages/TenantSettings/BillingHistory/index.tsx @@ -21,12 +21,18 @@ function BillingHistory() { const { currentTenantId, updateTenant } = useContext(TenantsContext); const { data: invoices, error } = useInvoices(currentTenantId); const isLoadingInvoices = !invoices && !error; + const displayInvoices = useMemo( // Don't show draft invoices () => invoices?.filter(({ status }) => status !== 'draft'), [invoices] ); + const openInvoices = useMemo( + () => invoices?.filter(({ status }) => status === 'open'), + [invoices] + ); + const openStripeHostedInvoicePage = useCallback( async (invoiceId: string) => { const { hostedInvoiceUrl } = await cloudApi.get( @@ -42,12 +48,12 @@ function BillingHistory() { ); useEffect(() => { - if (invoices) { + if (openInvoices) { updateTenant(currentTenantId, { - openInvoices: invoices, + openInvoices, }); } - }, [currentTenantId, invoices, updateTenant]); + }, [currentTenantId, openInvoices, updateTenant]); return (