diff --git a/src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte b/src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte index ea6265f7c..dd3b9ecf7 100644 --- a/src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte +++ b/src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte @@ -29,10 +29,10 @@ import { trackEvent } from '$lib/actions/analytics'; import { selectedInvoice, showRetryModal } from './store'; import { organization } from '$lib/stores/organization'; - import { BillingPlan } from '$lib/constants'; let showDropdown = []; let showFailedError = false; + let isLoadingInvoices = true; let offset = 0; let invoiceList: InvoiceList = { @@ -46,6 +46,7 @@ onMount(request); async function request() { + isLoadingInvoices = true; invoiceList = await sdk.forConsole.billing.listInvoices($page.params.organization, [ Query.limit(limit), Query.offset(offset), @@ -53,6 +54,7 @@ Query.notEqual('status', 'pending'), Query.orderDesc('$createdAt') ]); + isLoadingInvoices = false; } function retryPayment(invoice: Invoice) { @@ -65,144 +67,150 @@ } -{#if $organization?.billingPlan === BillingPlan.FREE && invoiceList.total > 0} - - Payment history + + Payment history -

- Transaction history for this organization. Download invoices for more details about your - payments. -

- - {#if invoiceList.total > 0} - - - Due Date - Status - Amount Due - - - - {#each invoiceList?.invoices as invoice, i} - {@const status = invoice.status} - - - {toLocaleDate(invoice.dueAt)} - - - {#if invoice?.lastError} - - (showFailedError = true)} - button> - {status === 'requires_authentication' - ? 'failed' - : status} - - -
  • - The scheduled payment has failed. - - . -
  • -
    -
    - {:else} +

    + Transaction history for this organization. Download invoices for more details about your + payments. +

    + + {#if invoiceList.total > 0} + + + Due Date + Status + Amount Due + + + + {#each invoiceList?.invoices as invoice, i} + {@const status = invoice.status} + + + {toLocaleDate(invoice.dueAt)} + + + {#if invoice?.lastError} + + warning={status === 'pending'} + on:click={() => (showFailedError = true)} + button> {status === 'requires_authentication' ? 'failed' : status} - {/if} - - - {formatCurrency(invoice.grossAmount)} - - - - - - (showDropdown[i] = !showDropdown[i])} - event="view_invoice"> - View invoice - - { - showDropdown[i] = !showDropdown[i]; - }} - event="download_invoice"> - Download PDF - - {#if status === 'overdue' || status === 'failed'} - + The scheduled payment has failed. + + . + - - - {/each} - - -
    -

    Total results: {invoiceList?.total ?? 0}

    - -
    - {:else} - -

    - You have no payment history. After you receive your first invoice, you'll - see it here. -

    -
    - {/if} -
    -
    -{/if} + {:else} + + {status === 'requires_authentication' ? 'failed' : status} + + {/if} + + + {formatCurrency(invoice.grossAmount)} + + + + + + (showDropdown[i] = !showDropdown[i])} + event="view_invoice"> + View invoice + + { + showDropdown[i] = !showDropdown[i]; + }} + event="download_invoice"> + Download PDF + + {#if status === 'overdue' || status === 'failed'} + { + retryPayment(invoice); + showDropdown[i] = !showDropdown[i]; + trackEvent(`click_retry_payment`, { + from: 'button', + source: 'billing_invoice_menu' + }); + }}> + Retry payment + + {/if} + + + + + {/each} + + +
    +

    Total results: {invoiceList.total}

    + +
    + {:else if isLoadingInvoices} +
    +
    +
    + {:else} + +

    + You have no payment history. After you receive your first invoice, you'll see it + here. +

    +
    + {/if} + + + +