From 869813ed3ebd256b2ecfeb6e27fd935246f70905 Mon Sep 17 00:00:00 2001 From: Darshan Date: Mon, 2 Dec 2024 14:56:43 +0530 Subject: [PATCH 01/14] remove: `icon-x` button in a read-only view. --- src/lib/components/collapsibleItem.svelte | 7 +- .../billing/+page.svelte | 4 +- .../billing/availableCredit.svelte | 4 +- .../billing/budgetAlert.svelte | 126 +++++--- .../billing/budgetCap.svelte | 12 +- .../billing/paymentHistory.svelte | 244 +++++++------- .../billing/paymentMethods.svelte | 198 ++++++------ .../billing/planSummary.svelte | 302 ++++++++++-------- 8 files changed, 489 insertions(+), 408 deletions(-) diff --git a/src/lib/components/collapsibleItem.svelte b/src/lib/components/collapsibleItem.svelte index a16b634608..f98c8845eb 100644 --- a/src/lib/components/collapsibleItem.svelte +++ b/src/lib/components/collapsibleItem.svelte @@ -7,12 +7,15 @@ export let noContent = false; export let isInfo = false; export let gap = 16; + + export let style = null; + export let wrapperStyle = null;
  • {#if noContent} -
    -
    +
    +
    diff --git a/src/routes/(console)/organization-[organization]/billing/+page.svelte b/src/routes/(console)/organization-[organization]/billing/+page.svelte index d3d6b7fd1a..23802e0815 100644 --- a/src/routes/(console)/organization-[organization]/billing/+page.svelte +++ b/src/routes/(console)/organization-[organization]/billing/+page.svelte @@ -130,9 +130,7 @@ - {#if $organization?.billingPlan !== BillingPlan.FREE && !!$organization?.billingBudget} - - {/if} + diff --git a/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte b/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte index b0a1efd7fa..6efbb54340 100644 --- a/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte +++ b/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte @@ -90,7 +90,9 @@ - Available credit + + {$organization?.billingPlan === BillingPlan.FREE ? 'Credit' : 'Available credit'} +

    Appwrite credit will automatically be applied to your next invoice.

    diff --git a/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte b/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte index a75439aac4..9c391398bd 100644 --- a/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte +++ b/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte @@ -1,8 +1,9 @@ - - Payment history +{#if $organization?.billingPlan === BillingPlan.FREE && invoiceList.total > 0} + + 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} - +

    + 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} (showFailedError = true)} - button> + warning={status === 'pending'}> {status === 'requires_authentication' ? 'failed' : status} + {/if} + + + {formatCurrency(invoice.grossAmount)} + + + + -
  • - The scheduled payment has failed. . -
  • + showDropdown[i] = !showDropdown[i]; + trackEvent(`click_retry_payment`, { + from: 'button', + source: 'billing_invoice_menu' + }); + }}> + Retry payment + + {/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 ?? 0}

    - -
    - {:else} - -

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

    -
    - {/if} - - + + + {/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} diff --git a/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte b/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte index 4e7bdbcdc8..1a7938d240 100644 --- a/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte +++ b/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte @@ -99,7 +99,6 @@

    View or update your organization payment methods here.

    -

    Default

    {#if $organization?.paymentMethodId} @@ -196,112 +195,115 @@ {/if}
    -
    -

    Backup

    - {#if $organization?.backupPaymentMethodId} - - - - - {#if backupPaymentMethod.userId === $user.$id} + {#if $organization?.billingPlan !== BillingPlan.FREE} + +
    +

    Backup

    + {#if $organization?.backupPaymentMethodId} + + + + + {#if backupPaymentMethod.userId === $user.$id} + { + showEdit = true; + isSelectedBackup = true; + showDropdownBackup = false; + }}> + Edit + + {/if} { - showEdit = true; + showReplace = true; isSelectedBackup = true; showDropdownBackup = false; }}> - Edit + Replace - {/if} - { - showReplace = true; - isSelectedBackup = true; - showDropdownBackup = false; - }}> - Replace - - { - showDelete = true; - isSelectedBackup = true; - showDropdownBackup = false; - }}> - Delete - - - - - {:else} - {@const filteredPaymentMethods = $paymentMethods.paymentMethods.filter( - (o) => !!o.last4 && o.$id !== $organization?.paymentMethodId - )} -
    -
    -
    - - - - {#if $paymentMethods.total} - {#each filteredPaymentMethods as paymentMethod} - { - showDropdownBackup = true; - addBackupPaymentMethod(paymentMethod?.$id); - }}> - -

    - Card ending in {paymentMethod.last4} -

    - -
    -
    - {/each} - {/if} - (showPayment = true)}> - Add new payment method - -
    -
    -
    -
    - Add a backup payment method - + Delete + + + + + {:else} + {@const filteredPaymentMethods = $paymentMethods.paymentMethods.filter( + (o) => !!o.last4 && o.$id !== $organization?.paymentMethodId + )} +
    +
    +
    + + + + {#if $paymentMethods.total} + {#each filteredPaymentMethods as paymentMethod} + { + showDropdownBackup = true; + addBackupPaymentMethod(paymentMethod?.$id); + }}> + +

    + Card ending in {paymentMethod.last4} +

    + +
    +
    + {/each} + {/if} + (showPayment = true)}> + Add new payment method + +
    +
    +
    +
    + Add a backup payment method + +
    -
    -
    - {/if} -
    + + {/if} +
    + {/if}
    diff --git a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte index c84356b753..f356741add 100644 --- a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte +++ b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte @@ -1,6 +1,6 @@