Skip to content

Commit ccca8e9

Browse files
Merge pull request #2299 from appwrite/fix-plan-summary
plan summary respect downgrade using next plan
2 parents e3ca560 + c668702 commit ccca8e9

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/routes/(console)/organization-[organization]/billing/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
<PlanSummary
133133
availableCredit={data?.availableCredit}
134134
currentPlan={data?.currentPlan}
135+
nextPlan={data?.nextPlan}
135136
currentAggregation={data?.billingAggregation} />
136137
{:else}
137138
<PlanSummaryOld

src/routes/(console)/organization-[organization]/billing/+page.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,18 @@ export const load: PageLoad = async ({ parent, depends }) => {
5757
organization?.billingPlan !== BillingPlan.GITHUB_EDUCATION))
5858
: false;
5959

60-
const [paymentMethods, addressList, billingAddress, availableCredit] = await Promise.all([
61-
sdk.forConsole.billing.listPaymentMethods(),
62-
sdk.forConsole.billing.listAddresses(),
63-
billingAddressPromise,
64-
areCreditsSupported ? sdk.forConsole.billing.getAvailableCredit(organization.$id) : null
65-
]);
60+
const [paymentMethods, addressList, billingAddress, availableCredit, billingPlanDowngrade] =
61+
await Promise.all([
62+
sdk.forConsole.billing.listPaymentMethods(),
63+
sdk.forConsole.billing.listAddresses(),
64+
billingAddressPromise,
65+
areCreditsSupported
66+
? sdk.forConsole.billing.getAvailableCredit(organization.$id)
67+
: null,
68+
organization.billingPlanDowngrade
69+
? sdk.forConsole.billing.getPlan(organization.billingPlanDowngrade)
70+
: null
71+
]);
6672

6773
// make number
6874
const credits = availableCredit ? availableCredit.available : null;
@@ -76,6 +82,7 @@ export const load: PageLoad = async ({ parent, depends }) => {
7682
billingInvoice,
7783
areCreditsSupported,
7884
countryList,
79-
locale
85+
locale,
86+
nextPlan: billingPlanDowngrade
8087
};
8188
};

src/routes/(console)/organization-[organization]/billing/planSummary.svelte

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import { IconTag } from '@appwrite.io/pink-icons-svelte';
2525
2626
export let currentPlan: Plan;
27+
export let nextPlan: Plan | null = null;
2728
export let currentAggregation: AggregationTeam | undefined = undefined;
2829
export let availableCredit: number | undefined = undefined;
2930
@@ -149,10 +150,7 @@
149150
item: 'Base plan',
150151
usage: '',
151152
price: formatCurrency(
152-
Math.max(
153-
(currentAggregation?.amount ?? currentPlan?.price ?? 0) - availableCredit,
154-
0
155-
)
153+
Math.max((nextPlan?.price ?? currentPlan?.price ?? 0) - availableCredit, 0)
156154
)
157155
},
158156
children: []

0 commit comments

Comments
 (0)