From 89b4496313a3211f6c2b84264157d5f23e1b83df Mon Sep 17 00:00:00 2001 From: ernstmul Date: Fri, 20 Dec 2024 11:02:02 +0100 Subject: [PATCH 1/6] Add check to which plan the org is changing when applying the credits --- src/routes/(console)/apply-credit/+page.svelte | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte index 884fd1763..d39827c03 100644 --- a/src/routes/(console)/apply-credit/+page.svelte +++ b/src/routes/(console)/apply-credit/+page.svelte @@ -189,6 +189,18 @@ $: selectedOrg = $organizationList?.teams?.find( (team) => team.$id === selectedOrgId ) as Organization; + + function getNewBillingPlan(organization: Organization): BillingPlan { + if (organization?.billingPlan === BillingPlan.SCALE) { + return BillingPlan.SCALE; + } else if (campaign?.plan) { + return campaign.plan; + } else { + return BillingPlan.PRO; + } + } + + $: billingPlan = getNewBillingPlan(selectedOrg); From 94576911f51a5f21f01f583a35dfd9b9d420c8e0 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Fri, 20 Dec 2024 11:22:15 +0100 Subject: [PATCH 2/6] Fix typo --- src/lib/components/billing/estimatedTotalBox.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/billing/estimatedTotalBox.svelte b/src/lib/components/billing/estimatedTotalBox.svelte index b7ab73af7..a6c8db6a7 100644 --- a/src/lib/components/billing/estimatedTotalBox.svelte +++ b/src/lib/components/billing/estimatedTotalBox.svelte @@ -64,7 +64,7 @@

- You'll pay {formatCurrency(estimatedTotal)} now, with our first + You'll pay {formatCurrency(estimatedTotal)} now, with your first billing cycle starting on {!currentPlan.trialDays From 8c36c6202aab9f2d0b52e474ce390667eac35cfd Mon Sep 17 00:00:00 2001 From: ernstmul Date: Fri, 20 Dec 2024 11:24:04 +0100 Subject: [PATCH 3/6] Fix education plan not showing change to pro plan when applying credits --- src/routes/(console)/apply-credit/+page.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte index d39827c03..9bc53d5cb 100644 --- a/src/routes/(console)/apply-credit/+page.svelte +++ b/src/routes/(console)/apply-credit/+page.svelte @@ -280,7 +280,7 @@ {/if} - {#if selectedOrg?.$id && selectedOrg?.billingPlan !== BillingPlan.FREE} + {#if selectedOrg?.$id && selectedOrg?.billingPlan !== BillingPlan.FREE && selectedOrg?.billingPlan !== BillingPlan.GITHUB_EDUCATION}

Date: Mon, 23 Dec 2024 14:09:37 +0100 Subject: [PATCH 4/6] Switch to if statement setup --- src/routes/(console)/apply-credit/+page.svelte | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte index 9bc53d5cb..df8a16bf9 100644 --- a/src/routes/(console)/apply-credit/+page.svelte +++ b/src/routes/(console)/apply-credit/+page.svelte @@ -190,17 +190,11 @@ (team) => team.$id === selectedOrgId ) as Organization; - function getNewBillingPlan(organization: Organization): BillingPlan { - if (organization?.billingPlan === BillingPlan.SCALE) { - return BillingPlan.SCALE; - } else if (campaign?.plan) { - return campaign.plan; - } else { - return BillingPlan.PRO; - } + $: if (selectedOrg?.billingPlan === BillingPlan.SCALE) { + billingPlan = BillingPlan.SCALE; + } else if (campaign?.plan) { + billingPlan = campaign.plan; } - - $: billingPlan = getNewBillingPlan(selectedOrg); From ef116a39d0b8ab45b6dbe2761deaa65518769fca Mon Sep 17 00:00:00 2001 From: ernstmul Date: Mon, 23 Dec 2024 14:27:39 +0100 Subject: [PATCH 5/6] Change to ternary --- src/routes/(console)/+layout.ts | 1 + src/routes/(console)/apply-credit/+page.svelte | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/routes/(console)/+layout.ts b/src/routes/(console)/+layout.ts index 1f5bbfc3e..0521240c1 100644 --- a/src/routes/(console)/+layout.ts +++ b/src/routes/(console)/+layout.ts @@ -25,6 +25,7 @@ export const load: LayoutLoad = async ({ fetch, depends, parent }) => { let plansInfo = new Map(); if (isCloud) { const plansArray = await sdk.forConsole.billing.getPlansInfo(); + console.log('plansArray', plansArray); plansInfo = plansArray.plans.reduce((map, plan) => { map.set(plan.$id as Tier, plan); return map; diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte index df8a16bf9..95af6175f 100644 --- a/src/routes/(console)/apply-credit/+page.svelte +++ b/src/routes/(console)/apply-credit/+page.svelte @@ -190,11 +190,10 @@ (team) => team.$id === selectedOrgId ) as Organization; - $: if (selectedOrg?.billingPlan === BillingPlan.SCALE) { - billingPlan = BillingPlan.SCALE; - } else if (campaign?.plan) { - billingPlan = campaign.plan; - } + $: billingPlan = + selectedOrg?.billingPlan === BillingPlan.SCALE + ? BillingPlan.SCALE + : (campaign?.plan ?? BillingPlan.PRO); From b3af21dcfd52c01efccf68a20dfa1bfcb9c63817 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Mon, 23 Dec 2024 15:40:32 +0100 Subject: [PATCH 6/6] Remove console.log --- src/routes/(console)/+layout.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/routes/(console)/+layout.ts b/src/routes/(console)/+layout.ts index 0521240c1..1f5bbfc3e 100644 --- a/src/routes/(console)/+layout.ts +++ b/src/routes/(console)/+layout.ts @@ -25,7 +25,6 @@ export const load: LayoutLoad = async ({ fetch, depends, parent }) => { let plansInfo = new Map(); if (isCloud) { const plansArray = await sdk.forConsole.billing.getPlansInfo(); - console.log('plansArray', plansArray); plansInfo = plansArray.plans.reduce((map, plan) => { map.set(plan.$id as Tier, plan); return map;