diff --git a/src/lib/components/backupDatabaseAlert.svelte b/src/lib/components/backupDatabaseAlert.svelte index dd1b30559..af3dedc2e 100644 --- a/src/lib/components/backupDatabaseAlert.svelte +++ b/src/lib/components/backupDatabaseAlert.svelte @@ -1,11 +1,10 @@ {#if $showPolicyAlert && isCloud && $organization?.$id && $page.url.pathname.match(/\/databases\/database-[^/]+$/)} - {@const isFreePlan = $organization?.billingPlan === BillingPlan.FREE} + {@const isFreePlan = isFreeTier($organization?.billingPlan)} {@const subtitle = isFreePlan ? 'Upgrade your plan to ensure your data stays safe and backed up' diff --git a/src/lib/components/backupRestoreBox.svelte b/src/lib/components/backupRestoreBox.svelte index 69d3dd60f..514cb2c84 100644 --- a/src/lib/components/backupRestoreBox.svelte +++ b/src/lib/components/backupRestoreBox.svelte @@ -4,7 +4,7 @@ import { onMount } from 'svelte'; import { isCloud, isSelfHosted } from '$lib/system'; import { organization } from '$lib/stores/organization'; - import { BillingPlan, Dependencies } from '$lib/constants'; + import { Dependencies } from '$lib/constants'; import type { BackupArchive, BackupRestoration } from '$lib/sdk/backups'; import { goto, invalidate } from '$app/navigation'; import { page } from '$app/stores'; @@ -12,6 +12,7 @@ import { base } from '$app/paths'; import { getProjectId } from '$lib/helpers/project'; import { toLocaleDate } from '$lib/helpers/date'; + import { isFreeTier } from '$lib/stores/billing'; const backupRestoreItems: { archives: Map; @@ -120,7 +121,7 @@ onMount(() => { // fast path: don't subscribe if org is on a free plan or is self-hosted. - if (isSelfHosted || (isCloud && $organization.billingPlan === BillingPlan.FREE)) return; + if (isSelfHosted || (isCloud && isFreeTier($organization.billingPlan))) return; return sdk.forConsole.client.subscribe('console', (response) => { if (!response.channels.includes(`projects.${getProjectId()}`)) return; diff --git a/src/lib/components/billing/alerts/limitReached.svelte b/src/lib/components/billing/alerts/limitReached.svelte index f3b5cc4b9..cb4d4a84a 100644 --- a/src/lib/components/billing/alerts/limitReached.svelte +++ b/src/lib/components/billing/alerts/limitReached.svelte @@ -5,11 +5,17 @@ import { BillingPlan } from '$lib/constants'; import { Button } from '$lib/elements/forms'; import { HeaderAlert } from '$lib/layout'; - import { hideBillingHeaderRoutes, readOnly, tierToPlan, upgradeURL } from '$lib/stores/billing'; + import { + hideBillingHeaderRoutes, + isFreeTier, + readOnly, + tierToPlan, + upgradeURL + } from '$lib/stores/billing'; import { organization } from '$lib/stores/organization'; -{#if $organization?.$id && $organization?.billingPlan === BillingPlan.FREE && $readOnly && !hideBillingHeaderRoutes.includes($page.url.pathname)} +{#if $organization?.$id && isFreeTier($organization?.billingPlan) && $readOnly && !hideBillingHeaderRoutes.includes($page.url.pathname)} diff --git a/src/lib/components/billing/alerts/newDevUpgradePro.svelte b/src/lib/components/billing/alerts/newDevUpgradePro.svelte index 7f8c30878..3a69b4c6e 100644 --- a/src/lib/components/billing/alerts/newDevUpgradePro.svelte +++ b/src/lib/components/billing/alerts/newDevUpgradePro.svelte @@ -2,11 +2,12 @@ import { base } from '$app/paths'; import { page } from '$app/stores'; import { trackEvent } from '$lib/actions/analytics'; - import { BillingPlan, NEW_DEV_PRO_UPGRADE_COUPON } from '$lib/constants'; + import { NEW_DEV_PRO_UPGRADE_COUPON } from '$lib/constants'; import { Button } from '$lib/elements/forms'; import { organization } from '$lib/stores/organization'; import { activeHeaderAlert } from '$routes/(console)/store'; import GradientBanner from '../gradientBanner.svelte'; + import { isFreeTier } from '$lib/stores/billing'; let show = true; @@ -21,7 +22,7 @@ } -{#if show && $organization?.$id && $organization?.billingPlan === BillingPlan.FREE && !$page.url.pathname.includes('/console/account')} +{#if show && $organization?.$id && isFreeTier($organization?.billingPlan) && !$page.url.pathname.includes('/console/account')}
Get $50 Cloud credits for Appwrite Pro. diff --git a/src/lib/components/billing/planComparisonBox.svelte b/src/lib/components/billing/planComparisonBox.svelte index 6d11df4fd..04c7d3351 100644 --- a/src/lib/components/billing/planComparisonBox.svelte +++ b/src/lib/components/billing/planComparisonBox.svelte @@ -1,38 +1,32 @@
- (selectedTab = BillingPlan.FREE)}> - {tierFree.name} - - (selectedTab = BillingPlan.PRO)}> - {tierPro.name} - - (selectedTab = BillingPlan.SCALE)}> - {tierScale.name} - + {#each $plansInfo.entries() as [tier, plan] (tier)} + (selectedTab = tier)}> + {plan.name} + + {/each}
- {#if selectedTab === BillingPlan.FREE} + {#if isFreeTier(selectedTab)}

{plan.name} plan

{#if downgrade}
    diff --git a/src/lib/components/billing/planSelection.svelte b/src/lib/components/billing/planSelection.svelte index 76d307374..20849850e 100644 --- a/src/lib/components/billing/planSelection.svelte +++ b/src/lib/components/billing/planSelection.svelte @@ -1,7 +1,6 @@ {#if billingPlan}
      -
    • - - -
      -

      - {tierFree.name} - {#if $organization?.billingPlan === BillingPlan.FREE && !isNewOrg} - Current plan - {/if} -

      -

      - {tierFree.description} -

      -

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

      -
      -
      -
      -
    • - -
    • - - -
      -

      - {tierPro.name} - {#if $organization?.billingPlan === BillingPlan.PRO && !isNewOrg} - Current plan - {/if} -

      -

      - {tierPro.description} -

      -

      - {formatCurrency(proPlan?.price ?? 0)} per member/month + usage -

      -
      -
      -
      -
    • -
    • - - -
      -

      - {tierScale.name} - {#if $organization?.billingPlan === BillingPlan.SCALE && !isNewOrg} - Current plan - {/if} -

      -

      - {tierScale.description} -

      -

      - {formatCurrency(scalePlan?.price ?? 0)} per month + usage -

      -
      -
      -
      -
    • + {#each $plansInfo.entries() as [tier, plan] (tier)} +
    • + + +
      +

      + {plan.name} + {#if isFreeTier($organization?.billingPlan) && !isNewOrg} + Current plan + {/if} +

      +

      + {plan.desc} +

      +

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

      +
      +
      +
      +
    • + {/each}
    {/if} diff --git a/src/lib/components/billing/selectPlan.svelte b/src/lib/components/billing/selectPlan.svelte index 8aae2f0ac..e52275e85 100644 --- a/src/lib/components/billing/selectPlan.svelte +++ b/src/lib/components/billing/selectPlan.svelte @@ -1,7 +1,6 @@ diff --git a/src/lib/components/bottomModalAlert.svelte b/src/lib/components/bottomModalAlert.svelte index 03ace8873..ce2cdf2f7 100644 --- a/src/lib/components/bottomModalAlert.svelte +++ b/src/lib/components/bottomModalAlert.svelte @@ -11,7 +11,7 @@ import { onMount } from 'svelte'; import { organization } from '$lib/stores/organization'; import { BillingPlan } from '$lib/constants'; - import { upgradeURL } from '$lib/stores/billing'; + import { isFreeTier, upgradeURL } from '$lib/stores/billing'; import { addBottomModalAlerts } from '$routes/(console)/bottomAlerts'; import { project } from '$routes/(console)/project-[project]/store'; import { page } from '$app/stores'; @@ -74,11 +74,9 @@ case 'free': return false; case 'pro': - return organizationPlan === BillingPlan.FREE; + return isFreeTier(organizationPlan); case 'scale': - return ( - organizationPlan === BillingPlan.FREE || organizationPlan === BillingPlan.PRO - ); + return isFreeTier(organizationPlan) || organizationPlan === BillingPlan.PRO; } } diff --git a/src/lib/components/emptyCardImageCloud.svelte b/src/lib/components/emptyCardImageCloud.svelte index fd9b1c3df..022a341d5 100644 --- a/src/lib/components/emptyCardImageCloud.svelte +++ b/src/lib/components/emptyCardImageCloud.svelte @@ -1,6 +1,4 @@ {#if isCloud} - {#if $organization?.billingPlan !== BillingPlan.FREE} + {#if !isFreeTier($organization?.billingPlan)}

    Roles - {#if $organization?.billingPlan === BillingPlan.FREE} + {#if isFreeTier($organization?.billingPlan)} Pro plan {/if}

    @@ -27,7 +26,7 @@

    Roles - {#if $organization?.billingPlan === BillingPlan.FREE} + {#if isFreeTier($organization?.billingPlan)} Pro plan {/if}

    diff --git a/src/lib/layout/activity.svelte b/src/lib/layout/activity.svelte index e1d691863..80795510b 100644 --- a/src/lib/layout/activity.svelte +++ b/src/lib/layout/activity.svelte @@ -18,11 +18,10 @@ import { Container, ContainerHeader } from '$lib/layout'; import { hoursToDays, toLocaleDateTime } from '$lib/helpers/date'; import type { Models } from '@appwrite.io/console'; - import { tierToPlan, type PlanServices } from '$lib/stores/billing'; + import { tierToPlan, type PlanServices, isFreeTier } from '$lib/stores/billing'; import { isCloud } from '$lib/system'; import { organization } from '$lib/stores/organization'; import { Button } from '$lib/elements/forms'; - import { BillingPlan } from '$lib/constants'; export let logs: Models.LogList; export let offset = 0; @@ -52,7 +51,7 @@ Logs are retained in rolling {hoursToDays(limit)} intervals with the {tierToPlan($organization.billingPlan).name} plan. - {#if $organization?.billingPlan === BillingPlan.FREE} + {#if isFreeTier($organization?.billingPlan)} to increase your log retention for a longer period. {/if} diff --git a/src/lib/layout/containerButton.svelte b/src/lib/layout/containerButton.svelte index e0b0512d3..2588011bc 100644 --- a/src/lib/layout/containerButton.svelte +++ b/src/lib/layout/containerButton.svelte @@ -1,17 +1,15 @@ @@ -219,7 +219,7 @@ .

    - {#if billingPlan !== BillingPlan.FREE} + {#if !isFreeTier(billingPlan)} - {#if billingPlan !== BillingPlan.FREE} + {#if !isFreeTier(billingPlan)} {:else} diff --git a/src/routes/(console)/onboarding/+page.svelte b/src/routes/(console)/onboarding/+page.svelte index b32451e1a..87cfccbda 100644 --- a/src/routes/(console)/onboarding/+page.svelte +++ b/src/routes/(console)/onboarding/+page.svelte @@ -12,7 +12,13 @@ import { isCloud } from '$lib/system'; import { ID } from '@appwrite.io/console'; import { onMount } from 'svelte'; - import { tierToPlan, type Tier, plansInfo, isOrganization } from '$lib/stores/billing'; + import { + tierToPlan, + type Tier, + plansInfo, + isOrganization, + isFreeTier + } from '$lib/stores/billing'; import { formatCurrency } from '$lib/helpers/numbers'; import { base } from '$app/paths'; import { checkPricingRefAndRedirect } from '$lib/helpers/pricingRedirect'; @@ -46,7 +52,7 @@ async function handleSubmit() { const orgName = name?.length ? name : 'Personal Projects'; if (isCloud) { - if (plan === BillingPlan.FREE) { + if (isFreeTier(plan)) { try { const org = await sdk.forConsole.billing.createOrganization( ID.unique(), diff --git a/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte b/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte index 23275fe0f..776730731 100644 --- a/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte +++ b/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte @@ -19,9 +19,8 @@ import { Button } from '$lib/elements/forms'; import AddCreditModal from './addCreditModal.svelte'; import { formatCurrency } from '$lib/helpers/numbers'; - import { BillingPlan } from '$lib/constants'; import { trackEvent } from '$lib/actions/analytics'; - import { upgradeURL } from '$lib/stores/billing'; + import { isFreeTier, upgradeURL } from '$lib/stores/billing'; import { Pill } from '$lib/elements'; import { tooltip } from '$lib/actions/tooltip'; @@ -89,14 +88,14 @@ } - + - {$organization?.billingPlan === BillingPlan.FREE ? 'Credits' : 'Available credit'} + {isFreeTier($organization?.billingPlan) ? 'Credits' : 'Available credit'}

    Appwrite credit will automatically be applied to your next invoice.

    - {#if $organization?.billingPlan === BillingPlan.FREE} + {#if isFreeTier($organization?.billingPlan)} Upgrade to Pro to add credits Upgrade to a Pro plan to add credits to your organization. For more information on what @@ -173,7 +172,7 @@ {/if} - {#if $organization?.billingPlan === BillingPlan.FREE} + {#if isFreeTier($organization?.billingPlan)}
    - {#if $organization?.billingPlan !== BillingPlan.FREE && $organization?.billingPlan !== BillingPlan.GITHUB_EDUCATION} + {#if !isFreeTier($organization?.billingPlan) && !isGithubEducationTier($organization?.billingPlan)}
    {#if $organization?.backupPaymentMethodId}

    Backup

    @@ -330,5 +330,5 @@ bind:showDelete {hasOtherMethod} isBackup={isSelectedBackup} - disabled={$organization?.billingPlan !== BillingPlan.FREE && !hasOtherMethod} /> + disabled={!isFreeTier($organization?.billingPlan) && !hasOtherMethod} /> {/if} diff --git a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte index 1e08e5190..dc603e9ee 100644 --- a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte +++ b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte @@ -3,7 +3,7 @@ import { Card, CardGrid, Collapsible, CollapsibleItem, Heading } from '$lib/components'; import { Button } from '$lib/elements/forms'; import { toLocaleDate } from '$lib/helpers/date'; - import { plansInfo, upgradeURL } from '$lib/stores/billing'; + import { isFreeTier, isGithubEducationTier, plansInfo, upgradeURL } from '$lib/stores/billing'; import { organization } from '$lib/stores/organization'; import type { Aggregation, CreditList, Invoice, Plan } from '$lib/sdk/billing'; import { abbreviateNumber, formatCurrency, formatNumberWithCommas } from '$lib/helpers/numbers'; @@ -46,8 +46,7 @@
    {currentPlan.name} plan
    - {isTrial || - $organization?.billingPlan === BillingPlan.GITHUB_EDUCATION + {isTrial || isGithubEducationTier($organization?.billingPlan) ? formatCurrency(0) : currentPlan ? formatCurrency(currentPlan?.price) @@ -173,7 +172,7 @@ {/if} - {#if $organization?.billingPlan !== BillingPlan.FREE && $organization?.billingPlan !== BillingPlan.GITHUB_EDUCATION} + {#if !isFreeTier($organization?.billingPlan) && !isGithubEducationTier($organization?.billingPlan)} - {#if $organization?.billingPlan === BillingPlan.FREE || $organization?.billingPlan === BillingPlan.GITHUB_EDUCATION} + {#if isFreeTier($organization?.billingPlan) || isGithubEducationTier($organization?.billingPlan)}

    - {:else if $organization.billingPlan === BillingPlan.FREE} + {:else if isFreeTier($organization.billingPlan)}

    If you exceed the limits of the Free plan, services for your organization's projects may be disrupted. diff --git a/src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte b/src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte index 87c7b1903..be01e6ba4 100644 --- a/src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte +++ b/src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte @@ -15,7 +15,7 @@ } from '$lib/elements/table'; import { toLocaleDate } from '$lib/helpers/date'; import { formatCurrency } from '$lib/helpers/numbers'; - import { plansInfo, tierToPlan } from '$lib/stores/billing'; + import { isFreeTier, plansInfo, tierToPlan } from '$lib/stores/billing'; import { newMemberModal, organization } from '$lib/stores/organization'; import type { Models } from '@appwrite.io/console'; @@ -30,7 +30,7 @@

    The number of members in your organization.

    - {#if $organization.billingPlan !== BillingPlan.FREE} + {#if !isFreeTier($organization.billingPlan)}

    diff --git a/src/routes/(console)/project-[project]/auth/templates/emailSignature.svelte b/src/routes/(console)/project-[project]/auth/templates/emailSignature.svelte index 718bf25a3..c67751d24 100644 --- a/src/routes/(console)/project-[project]/auth/templates/emailSignature.svelte +++ b/src/routes/(console)/project-[project]/auth/templates/emailSignature.svelte @@ -15,7 +15,7 @@

    Enable or disable Appwrite branding in your email template signature.

    - +
    {#if $app.themeInUse === 'dark'} @@ -51,7 +51,8 @@
    Upgrade to edit email signature - Upgrade to a {nextTier} plan to enable or disable Appwrite branding in your emails. + + Upgrade to a paid plan to enable or disable Appwrite branding in your emails.
- {#if $organization?.billingPlan === BillingPlan.FREE} + {#if isFreeTier($organization?.billingPlan)}

diff --git a/src/routes/(console)/project-[project]/functions/function-[function]/settings/updateRuntime.svelte b/src/routes/(console)/project-[project]/functions/function-[function]/settings/updateRuntime.svelte index 1f06dbe9c..12aa68d30 100644 --- a/src/routes/(console)/project-[project]/functions/function-[function]/settings/updateRuntime.svelte +++ b/src/routes/(console)/project-[project]/functions/function-[function]/settings/updateRuntime.svelte @@ -3,7 +3,7 @@ import { page } from '$app/stores'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; import { CardGrid, Heading } from '$lib/components'; - import { BillingPlan, Dependencies } from '$lib/constants'; + import { Dependencies } from '$lib/constants'; import { Button, Form, FormList } from '$lib/elements/forms'; import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; @@ -17,6 +17,7 @@ import { isCloud } from '$lib/system'; import { organization } from '$lib/stores/organization'; import SpecificationsTooltip from '$lib/wizards/functions/components/specificationsTooltip.svelte'; + import { isFreeTier } from '$lib/stores/billing'; const functionId = $page.params.function; let runtime: string = null; @@ -108,7 +109,7 @@ placeholder="Select runtime specification" bind:value={specification} options={specificationOptions} - popover={isCloud && $organization?.billingPlan === BillingPlan.FREE + popover={isCloud && isFreeTier($organization?.billingPlan) ? SpecificationsTooltip : null} required diff --git a/src/routes/(console)/project-[project]/settings/smtp/+page.svelte b/src/routes/(console)/project-[project]/settings/smtp/+page.svelte index e735055b1..c8d92cdf6 100644 --- a/src/routes/(console)/project-[project]/settings/smtp/+page.svelte +++ b/src/routes/(console)/project-[project]/settings/smtp/+page.svelte @@ -13,7 +13,7 @@ import InputPassword from '$lib/elements/forms/inputPassword.svelte'; import { sdk } from '$lib/stores/sdk'; import { invalidate } from '$app/navigation'; - import { BillingPlan, Dependencies } from '$lib/constants'; + import { Dependencies } from '$lib/constants'; import { addNotification } from '$lib/stores/notifications'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; import InputNumber from '$lib/elements/forms/inputNumber.svelte'; @@ -23,7 +23,7 @@ import { organization } from '$lib/stores/organization'; import { type SMTPSecure } from '@appwrite.io/console'; import InputSelect from '$lib/elements/forms/inputSelect.svelte'; - import { upgradeURL } from '$lib/stores/billing'; + import { isFreeTier, upgradeURL } from '$lib/stores/billing'; let enabled = false; let senderName: string; @@ -132,7 +132,7 @@ class="link">here

- {#if $organization.billingPlan === BillingPlan.FREE} + {#if isFreeTier($organization.billingPlan)} Custom SMTP is a Pro plan feature. Upgrade to enable custom SMTP sever. @@ -204,9 +204,7 @@ {/if} - diff --git a/src/routes/(console)/project-[project]/settings/usage/[[invoice]]/+page.svelte b/src/routes/(console)/project-[project]/settings/usage/[[invoice]]/+page.svelte index a0d8c2410..e13f22d92 100644 --- a/src/routes/(console)/project-[project]/settings/usage/[[invoice]]/+page.svelte +++ b/src/routes/(console)/project-[project]/settings/usage/[[invoice]]/+page.svelte @@ -10,7 +10,7 @@ Table, TableRowLink } from '$lib/elements/table'; - import { showUsageRatesModal, tierToPlan, upgradeURL } from '$lib/stores/billing'; + import { isFreeTier, showUsageRatesModal, tierToPlan, upgradeURL } from '$lib/stores/billing'; import { organization } from '$lib/stores/organization'; import { Button } from '$lib/elements/forms'; import { bytesToSize, humanFileSize, mbSecondsToGBHours } from '$lib/helpers/sizeConvertion'; @@ -66,7 +66,7 @@
Usage - {#if $organization?.billingPlan === BillingPlan.FREE} + {#if isFreeTier($organization?.billingPlan)} @@ -87,7 +87,7 @@ on:click={() => ($showUsageRatesModal = true)} link>Learn more about plan usage limits.

- {:else if $organization.billingPlan === BillingPlan.FREE} + {:else if isFreeTier($organization.billingPlan)}

If you exceed the limits of the {plan} plan, services for your projects may be disrupted. Upgrade for greater capacity. diff --git a/src/routes/(console)/project-[project]/storage/bucket-[bucket]/settings/updateMaxFileSize.svelte b/src/routes/(console)/project-[project]/storage/bucket-[bucket]/settings/updateMaxFileSize.svelte index 9509002bd..effac892f 100644 --- a/src/routes/(console)/project-[project]/storage/bucket-[bucket]/settings/updateMaxFileSize.svelte +++ b/src/routes/(console)/project-[project]/storage/bucket-[bucket]/settings/updateMaxFileSize.svelte @@ -1,11 +1,10 @@