From 16b2278bab073d9ba5724d0e6f64655212604497 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Mon, 2 Jun 2025 16:56:32 -0700 Subject: [PATCH 1/3] fix: update EstimatedTotalBox to display data from estimation --- .../billing/discountsApplied.svelte | 37 +++++++++++++++++++ .../billing/estimatedTotalBox.svelte | 23 ++++++------ 2 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 src/lib/components/billing/discountsApplied.svelte diff --git a/src/lib/components/billing/discountsApplied.svelte b/src/lib/components/billing/discountsApplied.svelte new file mode 100644 index 000000000..eed7a2bc7 --- /dev/null +++ b/src/lib/components/billing/discountsApplied.svelte @@ -0,0 +1,37 @@ + + +{#if adjustedValue > 0} + +
+

+ + + {label} + +

+
+ {#if value >= 100} +

Credits applied

+ {:else} + -{formatCurrency(adjustedValue)} + {/if} +
+{/if} diff --git a/src/lib/components/billing/estimatedTotalBox.svelte b/src/lib/components/billing/estimatedTotalBox.svelte index 438120824..dd7878890 100644 --- a/src/lib/components/billing/estimatedTotalBox.svelte +++ b/src/lib/components/billing/estimatedTotalBox.svelte @@ -7,6 +7,7 @@ import { CreditsApplied } from '.'; import { sdk } from '$lib/stores/sdk'; import { AppwriteException } from '@appwrite.io/console'; + import DiscountsApplied from './discountsApplied.svelte'; export let billingPlan: Tier; export let collaborators: string[]; @@ -35,7 +36,8 @@ if ( e.type === 'billing_coupon_not_found' || e.type === 'billing_coupon_already_used' || - e.type === 'billing_credit_unsupported' + e.type === 'billing_credit_unsupported' || + e.type === 'billing_coupon_not_eligible' ) { couponData = { code: null, @@ -65,7 +67,8 @@ if ( e.type === 'billing_coupon_not_found' || e.type === 'billing_coupon_already_used' || - e.type === 'billing_credit_unsupported' + e.type === 'billing_credit_unsupported' || + e.type === 'billing_coupon_not_eligible' ) { couponData = { code: null, @@ -80,13 +83,6 @@ $: organizationId ? getUpdatePlanEstimate(organizationId, billingPlan, collaborators, couponData?.code) : getEstimate(billingPlan, collaborators, couponData?.code); - - $: estimatedTotal = - couponData?.status === 'active' - ? estimation?.grossAmount - couponData.credits >= 0 - ? estimation?.grossAmount - couponData.credits - : 0 - : estimation?.grossAmount; {#if estimation} @@ -102,6 +98,9 @@ >{formatCurrency(item.value)} {/each} + {#each estimation.discounts ?? [] as item} + + {/each} {#if couponData?.status === 'active'} @@ -110,15 +109,15 @@ Total due - {formatCurrency(estimatedTotal)} + {formatCurrency(estimation.grossAmount)} - You'll pay {formatCurrency(estimatedTotal)} + You'll pay {formatCurrency(estimation.grossAmount)} now. {#if couponData?.code}Once your credits run out,{:else}Then{/if} you'll be charged - {formatCurrency(estimation.grossAmount)} every 30 days. + {formatCurrency(estimation.amount)} every 30 days. Date: Mon, 2 Jun 2025 17:07:38 -0700 Subject: [PATCH 2/3] fix: update Change plan to show Payment box when upgrading This will allow adding credits when upgrading. --- .../organization-[organization]/change-plan/+page.svelte | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte index efe13f1a3..b96c875c8 100644 --- a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte @@ -302,8 +302,7 @@ - - {#if selectedPlan !== BillingPlan.FREE && data.organization.billingPlan === BillingPlan.FREE} + {#if isUpgrade}
Date: Tue, 3 Jun 2025 09:50:09 +0530 Subject: [PATCH 3/3] fix: use pink2 components. --- .../billing/discountsApplied.svelte | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib/components/billing/discountsApplied.svelte b/src/lib/components/billing/discountsApplied.svelte index eed7a2bc7..3ff2d7add 100644 --- a/src/lib/components/billing/discountsApplied.svelte +++ b/src/lib/components/billing/discountsApplied.svelte @@ -1,6 +1,9 @@ {#if adjustedValue > 0} - -
-

- - - {label} - -

-
+ + + + {label} + {#if value >= 100} -

Credits applied

+ {:else} - -{formatCurrency(adjustedValue)} + -{formatCurrency(adjustedValue)} {/if} -
+ {/if}