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:
parent
f2d280466d
commit
2d3295ea28
1 changed files with 9 additions and 3 deletions
|
@ -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>
|
||||||
|
|
Loading…
Reference in a new issue