diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index e6688ea06a..c14b4b9494 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -130,12 +130,12 @@ export type PlanServices = | 'usersAddon' | 'webhooks'; -export function getServiceLimit(serviceId: PlanServices, tier: Tier = null): number { +export function getServiceLimit(serviceId: PlanServices, tier: Tier = null, plan?: Plan): number { if (!isCloud) return 0; if (!serviceId) return 0; const info = get(plansInfo); if (!info) return 0; - const plan = info.get(tier ?? get(organization)?.billingPlan); + plan ??= info.get(tier ?? get(organization)?.billingPlan); return plan?.[serviceId]; } diff --git a/src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.svelte b/src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.svelte index 8dddbb4190..82c211c198 100644 --- a/src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.svelte +++ b/src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.svelte @@ -4,7 +4,7 @@ import { getServiceLimit, showUsageRatesModal, - tierToPlan, + type Tier, upgradeURL } from '$lib/stores/billing'; import { organization } from '$lib/stores/organization'; @@ -21,23 +21,10 @@ export let data; - const tier = data?.currentInvoice?.plan ?? $organization?.billingPlan; - const plan = tierToPlan(tier).name; - - // let invoice = null; - // async function handlePeriodChange() { - // const target = invoice - // ? `/console/organization-${$organization.$id}/usage/${invoice}` - // : `/console/organization-${$organization.$id}/usage`; - // if ($page.url.pathname !== target) { - // await goto(target); - // } - // } - - // const cycles = data.invoices.invoices.map((invoice) => ({ - // label: toLocaleDate(invoice.from), - // value: invoice.$id - // })); + const tier = data?.plan + ? (data.plan.$id as Tier) + : (data?.currentInvoice?.plan ?? $organization?.billingPlan); + const plan = data?.plan ?? undefined; $: project = (data.organizationUsage as OrganizationUsage).projects; @@ -78,29 +65,11 @@
{:else if $organization.billingPlan === BillingPlan.FREE}- If you exceed the limits of the {plan} plan, services for your organization's projects + If you exceed the limits of the Free plan, services for your organization's projects may be disrupted. Upgrade for greater capacity.
{/if} - -