From 67aeaedb9ecb1fdbb8f5b60532f799c5d4a90348 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 20 Jan 2025 07:13:17 +0545 Subject: [PATCH] fixes to applying coupon --- src/lib/components/billing/estimatedTotal.svelte | 16 +++++++++++++++- .../(console)/create-organization/+page.svelte | 14 ++------------ .../change-plan/+page.svelte | 10 ++++++++++ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/lib/components/billing/estimatedTotal.svelte b/src/lib/components/billing/estimatedTotal.svelte index fa7a3b34e..fef543608 100644 --- a/src/lib/components/billing/estimatedTotal.svelte +++ b/src/lib/components/billing/estimatedTotal.svelte @@ -1,9 +1,11 @@ -{#if estimation} +{#if isDowngrade} +
+ +

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

+
+ +{:else if estimation}
{ if ($page.url.searchParams.has('coupon')) { - const coupon = $page.url.searchParams.get('coupon'); - try { - const response = await sdk.forConsole.billing.getCoupon(coupon); - couponData = response; - } catch (e) { - couponData = { - code: null, - status: null, - credits: null - }; - } + couponId = $page.url.searchParams.get('coupon'); } if ($page.url.searchParams.has('name')) { name = $page.url.searchParams.get('name'); @@ -152,7 +142,7 @@ billingPlan, paymentMethodId, null, - couponData?.code, + couponId, collaborators, billingBudget, taxId diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte index 025d73986..35c358b60 100644 --- a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte @@ -360,12 +360,22 @@ {#if billingPlan !== BillingPlan.FREE && $organization.billingPlan !== billingPlan && $organization.billingPlan !== BillingPlan.CUSTOM && isUpgrade} {:else if $organization.billingPlan !== BillingPlan.CUSTOM} + {#if isDowngrade} + + {/if} {/if}