From 2d3295ea28e240c3ef9661e99bc66ab704176e3a Mon Sep 17 00:00:00 2001 From: Darcy Ye Date: Thu, 24 Oct 2024 18:40:03 +0800 Subject: [PATCH] fix(console): fix manually update tenant open invoice bug (#6747) --- .../pages/TenantSettings/BillingHistory/index.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 (