diff --git a/src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte b/src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte index 552288765e..e663f984b8 100644 --- a/src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte +++ b/src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte @@ -40,26 +40,14 @@ const endpoint = getApiEndpoint(); const hasPaymentError = $derived(invoiceList?.invoices.some((invoice) => invoice?.lastError)); - /** - * Special case handling for the first page! - * - * As per Damodar - `there is some logic to **hide current cycle invoice** in the endpoint`. - * - * Due to this, the first page always loads `limit - 1` invoices which is inconsistent! - * Therefore, we load `limit + 1` to counter that so the returned invoices are consistent. - */ - onMount(() => request(true)); + onMount(loadInvoices); - async function request(patchQuery: boolean = false) { + async function loadInvoices() { isLoadingInvoices = true; invoiceList = await sdk.forConsole.billing.listInvoices(page.params.organization, [ Query.orderDesc('$createdAt'), - - // first page extra must have an extra limit! - Query.limit(patchQuery ? limit + 1 : limit), - - // so an invoice isn't repeated on 2nd page! - Query.offset(patchQuery ? offset : offset + 1) + Query.limit(limit), + Query.offset(offset) ]); isLoadingInvoices = false; @@ -73,7 +61,7 @@ $effect(() => { if (page.url.searchParams.get('type') === 'validate-invoice') { window.history.replaceState({}, '', page.url.pathname); - request(); + loadInvoices(); } }); @@ -197,7 +185,7 @@ hidePages bind:offset total={invoiceList.total} - on:change={() => request()} /> + on:change={loadInvoices} /> {/if} {:else}