From cc8811b2764b101503fa2c64fddf27a6a7fbe0d1 Mon Sep 17 00:00:00 2001 From: Darshan Date: Mon, 26 Jan 2026 15:54:24 +0530 Subject: [PATCH] update: address comments. --- src/lib/components/backupRestoreBox.svelte | 2 +- src/lib/components/billing/index.ts | 1 - .../components/billing/planSelection.svelte | 11 +--- src/lib/components/billing/selectPlan.svelte | 59 ------------------- .../account/organizations/+page.svelte | 2 +- .../(console)/apply-credit/+page.svelte | 19 ++++-- 6 files changed, 20 insertions(+), 74 deletions(-) delete mode 100644 src/lib/components/billing/selectPlan.svelte diff --git a/src/lib/components/backupRestoreBox.svelte b/src/lib/components/backupRestoreBox.svelte index b506beb6f..b97c4d5e3 100644 --- a/src/lib/components/backupRestoreBox.svelte +++ b/src/lib/components/backupRestoreBox.svelte @@ -125,7 +125,7 @@ } onMount(() => { - // fast path: don't subscribe if org is on a free plan or is self-hosted. + // fast path: don't subscribe if org doesn't support backups or is self-hosted. if (isSelfHosted || (isCloud && !$organization?.billingPlanDetails.backupsEnabled)) return; return realtime.forProject(page.params.region, 'console', (response) => { diff --git a/src/lib/components/billing/index.ts b/src/lib/components/billing/index.ts index 11e9245b3..eac388917 100644 --- a/src/lib/components/billing/index.ts +++ b/src/lib/components/billing/index.ts @@ -6,4 +6,3 @@ export { default as PlanComparisonBox } from './planComparisonBox.svelte'; export { default as EmptyCardCloud } from './emptyCardCloud.svelte'; export { default as CreditsApplied } from './creditsApplied.svelte'; export { default as PlanSelection } from './planSelection.svelte'; -export { default as SelectPlan } from './selectPlan.svelte'; diff --git a/src/lib/components/billing/planSelection.svelte b/src/lib/components/billing/planSelection.svelte index 2d8128582..fe1fd8f6a 100644 --- a/src/lib/components/billing/planSelection.svelte +++ b/src/lib/components/billing/planSelection.svelte @@ -21,13 +21,8 @@ let selectedPlan = $state(selectedBillingPlan.$id); - const plans = $derived(Object.values(page.data.plans.plans) as Models.BillingPlan[]); - const currentPlanInList = $derived(plans.some((plan) => plan.$id === $currentPlan?.$id)); - - // experiment to remove scale plan temporarily - const plansWithoutScale = $derived( - plans.filter((plan) => plan.group != BillingPlanGroup.Scale) - ); + const visiblePlans = $derived(Object.values(page.data.plans.plans) as Models.BillingPlan[]); + const currentPlanInList = $derived(visiblePlans.some((plan) => plan.$id === $currentPlan?.$id)); function shouldShowTooltip(plan: Models.BillingPlan) { if (plan.group !== BillingPlanGroup.Starter) return true; @@ -44,7 +39,7 @@ - {#each plansWithoutScale as plan} + {#each visiblePlans as plan} - import { formatCurrency } from '$lib/helpers/numbers'; - import { plansInfo } from '$lib/stores/billing'; - import { organization } from '$lib/stores/organization'; - import { LabelCard } from '..'; - import { BillingPlanGroup, type Models } from '@appwrite.io/console'; - - export let billingPlan: string; - export let anyOrgFree = false; - export let isNewOrg = false; - let classes: string = ''; - export { classes as class }; - - function shouldDisable(plan: Models.BillingPlan) { - return plan.group === BillingPlanGroup.Starter && anyOrgFree; - } - - function shouldShowTooltip(plan: Models.BillingPlan) { - if (plan.group !== BillingPlanGroup.Starter) return true; - else return !anyOrgFree; - } - - -{#if billingPlan} -
    - {#each $plansInfo.values() as plan} -
  • - - -
    -

    - {plan.name} - {#if $organization?.billingPlanId === plan.$id && !isNewOrg} - Current plan - {/if} -

    -

    - {plan.desc} -

    -

    - {formatCurrency(plan?.price ?? 0)} -

    -
    -
    -
    -
  • - {/each} -
-{/if} diff --git a/src/routes/(console)/account/organizations/+page.svelte b/src/routes/(console)/account/organizations/+page.svelte index 2d500bf97..b7582b664 100644 --- a/src/routes/(console)/account/organizations/+page.svelte +++ b/src/routes/(console)/account/organizations/+page.svelte @@ -66,7 +66,7 @@ } function isNonPayingOrganization(organization: Models.Organization): boolean { - // 0 priced plans don't need payment methods! + // plan doesn't require payments, it is a non-paying org! return !organization?.billingPlanDetails.requiresPaymentMethod; } diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte index 915076ac9..e59f094fd 100644 --- a/src/routes/(console)/apply-credit/+page.svelte +++ b/src/routes/(console)/apply-credit/+page.svelte @@ -279,6 +279,17 @@ ) { loadPaymentMethods(); } + + /* check if payment method selection is needed */ + $: needsPaymentMethod = + selectedOrgId && + (!selectedOrg?.billingPlanDetails.requiresPaymentMethod || !selectedOrg?.paymentMethodId); + + /* check if coupon code input should be shown */ + $: needsCouponInput = !data?.couponData?.code && selectedOrgId; + + /* show payment section if either payment method or coupon input is needed */ + $: showPaymentSection = needsPaymentMethod || needsCouponInput; @@ -302,7 +313,7 @@ {/if} - {#if selectedOrgId && (!selectedOrg?.billingPlanDetails.addons.seats.supported || !selectedOrg?.paymentMethodId)} + {#if selectedOrgId && !selectedOrg?.billingPlanDetails.addons.seats.supported} {#if selectedOrgId === newOrgId} - {#if (selectedOrgId && (!selectedOrg?.billingPlanDetails.requiresPaymentMethod || !selectedOrg?.paymentMethodId)) || (!data?.couponData?.code && selectedOrgId)} + {#if showPaymentSection}
- {#if selectedOrgId && (!selectedOrg?.billingPlanDetails.requiresPaymentMethod || !selectedOrg?.paymentMethodId)} + {#if needsPaymentMethod} {/if}
- {#if !data?.couponData?.code && selectedOrgId} + {#if needsCouponInput}