From e5a29376e6e52ddf3f53de72f4af792bb4d08462 Mon Sep 17 00:00:00 2001 From: Darshan Date: Sun, 8 Jun 2025 10:45:44 +0530 Subject: [PATCH] add: current plan if not one of the base plans. --- .../components/billing/planSelection.svelte | 27 +++++++++++++++++-- src/lib/constants.ts | 2 ++ src/lib/stores/billing.ts | 15 +++++++---- .../enterpriseTrial.svelte | 7 +---- 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/lib/components/billing/planSelection.svelte b/src/lib/components/billing/planSelection.svelte index d2889d66f..7c1666675 100644 --- a/src/lib/components/billing/planSelection.svelte +++ b/src/lib/components/billing/planSelection.svelte @@ -1,8 +1,8 @@ @@ -72,4 +74,25 @@ {formatCurrency(scalePlan?.price ?? 0)} per month + usage + {#if !isBasePlan} + + + {#if $organization?.billingPlan === $currentPlan.$id && !isNewOrg} + + {/if} + + + {$currentPlan.desc} + + + {@const isZeroPrice = ($currentPlan?.price ?? 0) <= 0} + {@const price = formatCurrency($currentPlan?.price ?? 0)} + {isZeroPrice ? price : `${price} per month + usage`} + + + {/if} diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 067b354dd..cd9dc4364 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -530,6 +530,8 @@ export enum BillingPlan { ENTERPRISE = 'ent-1' } +export const BASE_BILLING_PLANS: string[] = [BillingPlan.FREE, BillingPlan.PRO, BillingPlan.SCALE]; + export const feedbackDowngradeOptions = [ { value: 'availableFeatures', diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 05dde454f..38b7be72e 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -28,7 +28,12 @@ import { Query } from '@appwrite.io/console'; import { derived, get, writable } from 'svelte/store'; import { headerAlert } from './headerAlert'; import { addNotification, notifications } from './notifications'; -import { currentPlan, organization, type Organization, type OrganizationError } from './organization'; +import { + currentPlan, + organization, + type Organization, + type OrganizationError +} from './organization'; import { canSeeBilling } from './roles'; import { sdk } from './sdk'; import { user } from './user'; @@ -270,11 +275,11 @@ export function isServiceLimited(serviceId: PlanServices, plan: Tier, total: num } export function checkForEnterpriseTrial(org: Organization) { - const remaining = calculateEnterpriseTrial(org); + const remaining = calculateEnterpriseTrial(org); console.log('remaining', remaining); - if(calculateEnterpriseTrial(org) > 0) { - headerAlert.add({ - id: 'temaEnterprieseTrial', + if (calculateEnterpriseTrial(org) > 0) { + headerAlert.add({ + id: 'teamEnterpriseTrial', component: EnterpriseTrial, show: true, importance: 11 diff --git a/src/routes/(console)/organization-[organization]/enterpriseTrial.svelte b/src/routes/(console)/organization-[organization]/enterpriseTrial.svelte index 8b2630249..75e27d112 100644 --- a/src/routes/(console)/organization-[organization]/enterpriseTrial.svelte +++ b/src/routes/(console)/organization-[organization]/enterpriseTrial.svelte @@ -55,12 +55,7 @@ Your enterprise trial expires in {remainingDays} days. - -