diff --git a/src/lib/components/billing/estimatedTotal.svelte b/src/lib/components/billing/estimatedTotal.svelte index fef543608..1af444fd3 100644 --- a/src/lib/components/billing/estimatedTotal.svelte +++ b/src/lib/components/billing/estimatedTotal.svelte @@ -1,21 +1,17 @@ -{#if isDowngrade} -
- -

- Your change will take effect once your current billing cycle ends on {toLocaleDate($organization.billingNextInvoiceDate)}. -

-
- +{#if error.length} + + + {error} + + {:else if estimation} - -
- - {#each estimation.items ?? [] as item} +
+ + {#each estimation.items ?? [] as item} + +

{item.label}

+

{formatCurrency(item.value)}

+
+ {/each} + {#each estimation.discounts ?? [] as item} + + {/each} +
-

{item.label}

-

{formatCurrency(item.value)}

+

+ Total due
+

+

+ {formatCurrency(estimation.grossAmount)} +

- {/each} - {#each estimation.discounts ?? [] as item} - - {/each} -
- -

- Total due
-

-

- {formatCurrency(estimation.grossAmount)} -

-
-

- You'll pay {formatCurrency(estimation.amount)} now. Once your credits run out, you'll be charged - {formatCurrency(estimation.amount)} every 30 days. -

+

+ You'll pay {formatCurrency(estimation.amount)} now. Once + your credits run out, you'll be charged + {formatCurrency(estimation.amount)} every 30 days. +

- - - {#if budgetEnabled} -
- -
- {/if} -
-
-
-{/if} \ No newline at end of file + + + {#if budgetEnabled} +
+ +
+ {/if} +
+
+
+{/if} diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte index 35c358b60..baf1f44cc 100644 --- a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte @@ -21,6 +21,7 @@ InputTextarea, Label } from '$lib/elements/forms'; + import { toLocaleDate } from '$lib/helpers/date.js'; import { formatCurrency } from '$lib/helpers/numbers'; import { WizardSecondaryContainer, @@ -76,6 +77,7 @@ let taxId: string; let billingBudget: number; let showCreditModal = false; + let error: string = ''; let feedbackDowngradeReason: string; let feedbackMessage: string; @@ -83,6 +85,7 @@ onMount(async () => { if ($page.url.searchParams.has('code')) { + couponId = $page.url.searchParams.get('code'); const coupon = $page.url.searchParams.get('code'); try { const response = await sdk.forConsole.billing.getCoupon(coupon); @@ -275,7 +278,7 @@ $: if (billingPlan !== BillingPlan.FREE) { loadPaymentMethods(); } - $: isButtonDisabled = $organization.billingPlan === billingPlan; + $: isButtonDisabled = $organization.billingPlan === billingPlan || error.length > 0; @@ -360,21 +363,26 @@ {#if billingPlan !== BillingPlan.FREE && $organization.billingPlan !== billingPlan && $organization.billingPlan !== BillingPlan.CUSTOM && isUpgrade} {:else if $organization.billingPlan !== BillingPlan.CUSTOM} {#if isDowngrade} - +
+ +

+ Your change will take effect once your current billing cycle ends on {toLocaleDate($organization.billingNextInvoiceDate)}. +

+
{/if} {/if} @@ -386,7 +394,7 @@