From 3ea5d1f2b9565baa3c123e24105a21ec3d7f7f4f Mon Sep 17 00:00:00 2001 From: ernstmul Date: Tue, 26 Nov 2024 10:23:30 +0100 Subject: [PATCH] Fix for when no invoices are available --- .../organization-[organization]/billing/planSummary.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte index a0b0d4166d..c84356b753 100644 --- a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte +++ b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte @@ -18,15 +18,15 @@ export let currentPlan: Plan; export let creditList: CreditList; - const currentInvoice: Invoice = invoices[0]; + const currentInvoice: Invoice | undefined = invoices.length > 0 ? invoices[0] : undefined; const extraMembers = members.total > 1 ? members.total - 1 : 0; const availableCredit = creditList.available; const today = new Date(); const isTrial = new Date($organization?.billingStartDate).getTime() - today.getTime() > 0 && $plansInfo.get($organization.billingPlan)?.trialDays; - const extraUsage = currentInvoice.amount - currentPlan?.price; - const extraAddons = currentInvoice.usage?.length; + const extraUsage = currentInvoice ? currentInvoice.amount - currentPlan?.price : 0; + const extraAddons = currentInvoice ? currentInvoice.usage?.length : 0; {#if $organization}