0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(console): fix manually update tenant open invoice bug (#6747)

This commit is contained in:
Darcy Ye 2024-10-24 18:40:03 +08:00 committed by GitHub
parent f2d280466d
commit 2d3295ea28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,12 +21,18 @@ function BillingHistory() {
const { currentTenantId, updateTenant } = useContext(TenantsContext); const { currentTenantId, updateTenant } = useContext(TenantsContext);
const { data: invoices, error } = useInvoices(currentTenantId); const { data: invoices, error } = useInvoices(currentTenantId);
const isLoadingInvoices = !invoices && !error; const isLoadingInvoices = !invoices && !error;
const displayInvoices = useMemo( const displayInvoices = useMemo(
// Don't show draft invoices // Don't show draft invoices
() => invoices?.filter(({ status }) => status !== 'draft'), () => invoices?.filter(({ status }) => status !== 'draft'),
[invoices] [invoices]
); );
const openInvoices = useMemo(
() => invoices?.filter(({ status }) => status === 'open'),
[invoices]
);
const openStripeHostedInvoicePage = useCallback( const openStripeHostedInvoicePage = useCallback(
async (invoiceId: string) => { async (invoiceId: string) => {
const { hostedInvoiceUrl } = await cloudApi.get( const { hostedInvoiceUrl } = await cloudApi.get(
@ -42,12 +48,12 @@ function BillingHistory() {
); );
useEffect(() => { useEffect(() => {
if (invoices) { if (openInvoices) {
updateTenant(currentTenantId, { updateTenant(currentTenantId, {
openInvoices: invoices, openInvoices,
}); });
} }
}, [currentTenantId, invoices, updateTenant]); }, [currentTenantId, openInvoices, updateTenant]);
return ( return (
<div> <div>