From dba4bf5d2abf35ed8bd422d5137b138a53e3d9b5 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 15 May 2024 15:54:58 +0200 Subject: [PATCH] chore: delete old wizard, small fixes --- .../components/billing}/planExcess.svelte | 0 .../change-plan/+page.svelte | 4 +- .../excesLimitModal.svelte | 2 +- .../addressDetails.svelte | 147 ------------- .../choosePlan.svelte | 195 ------------------ .../confirmDetails.svelte | 161 --------------- .../inviteMembers.svelte | 119 ----------- .../paymentDetails.svelte | 119 ----------- .../cloudOrganizationChangeTier/store.ts | 70 ------- .../usageExcess.svelte | 20 -- 10 files changed, 3 insertions(+), 834 deletions(-) rename src/{routes/console/wizard/cloudOrganizationChangeTier => lib/components/billing}/planExcess.svelte (100%) delete mode 100644 src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte delete mode 100644 src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte delete mode 100644 src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte delete mode 100644 src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte delete mode 100644 src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte delete mode 100644 src/routes/console/wizard/cloudOrganizationChangeTier/store.ts delete mode 100644 src/routes/console/wizard/cloudOrganizationChangeTier/usageExcess.svelte diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/planExcess.svelte b/src/lib/components/billing/planExcess.svelte similarity index 100% rename from src/routes/console/wizard/cloudOrganizationChangeTier/planExcess.svelte rename to src/lib/components/billing/planExcess.svelte diff --git a/src/routes/console/organization-[organization]/change-plan/+page.svelte b/src/routes/console/organization-[organization]/change-plan/+page.svelte index 714ba703d..92bbc10cb 100644 --- a/src/routes/console/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/console/organization-[organization]/change-plan/+page.svelte @@ -92,7 +92,7 @@ billingPlan = plan as BillingPlan; } } - billingPlan = $organization.billingPlan; + billingPlan = BillingPlan.PRO; }); async function loadPaymentMethods() { @@ -262,7 +262,7 @@ .

{#if anyOrgFree && billingPlan === BillingPlan.PRO} - + You are limited to one Starter organization per account. Consider upgrading or deleting - import { FormItem, FormList, InputSelect, InputText } from '$lib/elements/forms'; - import { WizardStep } from '$lib/layout'; - import { onMount } from 'svelte'; - import { sdk } from '$lib/stores/sdk'; - import { changeOrganizationTier } from './store'; - import { organization } from '$lib/stores/organization'; - import type { AddressesList } from '$lib/sdk/billing'; - import { RadioBoxes } from '$lib/components'; - import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; - - let options = [ - { - value: 'US', - label: 'United States' - } - ]; - let addressList: AddressesList; - let country: string; - let streetAddress: string; - let city: string; - let state: string; - let postalCode: string; - let addressLine2: string; - - async function handleAddress() { - if (!$changeOrganizationTier.billingAddressId) { - try { - const response = await sdk.forConsole.billing.createAddress( - country, - streetAddress, - city, - state, - postalCode ? postalCode : undefined, - addressLine2 ? addressLine2 : undefined - ); - $changeOrganizationTier.billingAddressId = response.$id; - trackEvent(Submit.BillingAddressCreate); - } catch (error) { - trackError(error, Submit.BillingAddressCreate); - throw new Error(error.message); - } - } - } - - onMount(async () => { - addressList = await sdk.forConsole.billing.listAddresses(); - $changeOrganizationTier.billingAddressId = $organization.billingAddressId - ? $organization.billingAddressId - : addressList.billingAddresses?.[0]?.$id ?? null; - const locale = await sdk.forProject.locale.get(); - if (locale?.countryCode && !$changeOrganizationTier.billingAddressId) { - country = locale.countryCode; - } - const countryList = await sdk.forProject.locale.listCountries(); - options = countryList.countries.map((country) => { - return { - value: country.code, - label: country.name - }; - }); - }); - - - - Billing address - Add a billing address for your organization. - - - {#if addressList} - - -
-

{element.streetAddress}

- {#if element?.addressLine2} -

{element.addressLine2}

- {/if} -

{element.city}

-

{element.state}

-

{element.postalCode}

-

{element.country}

-
-
- - - Add new billing address - - - - - - - - - - - - - -
- {/if} -
-
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte deleted file mode 100644 index 77430ca0d..000000000 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte +++ /dev/null @@ -1,195 +0,0 @@ - - - - Plan selection - -

Plan

-

- For more details on our plans, visit our pricing page. -

-
    -
  • - - -
    -

    - {tierFree.name} - {formatCurrency(freePlan.price)}/month -

    -

    {tierFree.description}

    -
    -
    - {#if $organization.billingPlan === BillingPlan.STARTER} - CURRENT PLAN - {/if} -
    -
    -
    -
  • -
  • - - -
    -

    - {tierPro.name} - {formatCurrency(proPlan.price)}/month per organization - member + extra usage -

    -

    - {tierPro.description} -

    -
    -
    - {#if $organization.billingPlan === BillingPlan.PRO} - CURRENT PLAN - {:else if proPlan?.trialDays} - {proPlan?.trialDays} DAY FREE TRIAL - {/if} -
    -
    -
    -
  • -
  • - - -
    -

    - {tierScale.name} - {formatCurrency(scalePlan.price)}/month + extra usage -

    -

    - {tierScale.description} -

    -
    -
    - COMING SOON -
    -
    -
    -
  • -
-
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte deleted file mode 100644 index 51ee8aeed..000000000 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte +++ /dev/null @@ -1,161 +0,0 @@ - - -{#if downgradeToStarter} - - Change confirmation - - Your feedback is important to us and helps us improve the services Appwrite offers. - Please let us know if there is a specific reason for changing your plan. - - - - - - -{:else} - - Details - - Confirm the details of your new organization{!$plansInfo.get( - $changeOrganizationTier.billingPlan - )?.trialDays - ? '.' - : ' and start your free trial.'} - - -

Organization name

-
-

{$organization.name}

-
- - {#if $changeOrganizationTier.billingPlan !== BillingPlan.STARTER} -
-

Additional members

-

{collaboratorsNumber} members

-
-
-

Payment

- {#await fetchCard()} -
-
-
- {:then card} - -

- Card ending in {card.last4} -

- -
- {/await} -
- {/if} - - - {#if $changeOrganizationTier.billingPlan !== BillingPlan.STARTER} - ($changeOrganizationTier.couponCode = e.detail.code)} /> - -

{plan.name} plan

-

{formatCurrency(plan.price)}

-
- -

Additional members ({collaboratorsNumber})

-

{formatCurrency(collaboratorPrice * collaboratorsNumber)}

-
- {#if couponData?.status === 'active'} - -

Credits applied ({couponData.credits})

-

-{formatCurrency(couponData.credits)}

-
- {/if} - {/if} - {@const estimatedTotal = - couponData?.status === 'active' - ? totalExpences - couponData.credits >= 0 - ? totalExpences - couponData.credits - : 0 - : totalExpences} -
- -

Estimated total

-

- {formatCurrency(estimatedTotal)} -

-
- -

- This amount, and any additional usage fees, will be charged on a recurring 30-day - billing cycle{!$plansInfo.get($changeOrganizationTier.billingPlan)?.trialDays - ? '' - : ` after your trial period ends on ${toLocaleDate(billingPayDate.toString())}`}. -

- - -{/if} diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte deleted file mode 100644 index 0695e7e0f..000000000 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte +++ /dev/null @@ -1,119 +0,0 @@ - - - - Invites - - Invite team members to collaborate with you in the Appwrite console. Members will have - access to all services and payment data within your organization. - - - - {#if $changeOrganizationTier.billingPlan === BillingPlan.SCALE} - You can add unlimited organization members on the {plan.name} plan at no cost. Each member - added will receive an email invite to your organization on completion. - {:else if $changeOrganizationTier.billingPlan === BillingPlan.PRO} - You can add unlimited organization members on the {plan.name} plan for - {formatCurrency(plan.addons.member.price)} each per month. Each member added will - receive an email invite to your organization on completion. - {/if} - - -
-
- - - - - -
-
- - {#if $changeOrganizationTier?.collaborators?.length} -
- - - Collaborator - {#if $changeOrganizationTier.billingPlan === BillingPlan.PRO} - Cost - {/if} - - - - {#each $changeOrganizationTier.collaborators as collaborator} - - {collaborator} - {#if $changeOrganizationTier.billingPlan === BillingPlan.PRO} - {formatCurrency(15)} - {/if} - - - - - {/each} - -
-
- {/if} -
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte deleted file mode 100644 index 99116f394..000000000 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte +++ /dev/null @@ -1,119 +0,0 @@ - - - - Payment details - - Confirm the payment method for your organization. - - - - - - -

- Restrict your resource usage by setting a budget cap. . -

- {#if budgetEnabled} -
- -
- {/if} -
-
-
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts deleted file mode 100644 index 57463d106..000000000 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { BillingPlan } from '$lib/constants'; -import type { WizardStepsType } from '$lib/layout/wizard.svelte'; -import { type Tier } from '$lib/stores/billing'; -import { writable } from 'svelte/store'; - -export const changeTierSteps = writable(new Map()); -export const isUpgrade = writable(false); -export const changeOrganizationFinalAction = writable('Create'); - -export const changeOrganizationTier = writable<{ - billingPlan: Tier; - paymentMethodId: string; - billingAddressId: string; - billingBudget?: number; - collaborators?: string[]; - isOverLimit?: boolean; - limitOverflow?: { - bandwidth?: number; - executions?: number; - storage?: number; - users?: number; - members?: number; - }; - taxId?: string; - feedbackMessage?: string; - feedbackDowngradeReason?: string; - couponCode?: string; -}>({ - billingPlan: BillingPlan.PRO, - paymentMethodId: null, - collaborators: [], - isOverLimit: false, - billingAddressId: null, - taxId: null -}); - -export const feedbackDowngradeOptions = [ - { - value: 'availableFeatures', - label: "The available features don't meet my needs" - }, - { - value: 'traction', - label: "My project isn't getting traction" - }, - { - value: 'bugs', - label: 'I experienced bugs or unexpected outages while using the console' - }, - { - value: 'starter', - label: 'The Starter plan is enough for my projects' - }, - { - value: 'budget', - label: "I don't have the budget" - }, - { - value: 'tryOut', - label: 'I just wanted to try it out' - }, - { - value: 'alternative', - label: 'I found an alternative/competitor to meet my needs' - }, - { - value: 'other', - label: 'Other' - } -]; diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/usageExcess.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/usageExcess.svelte deleted file mode 100644 index e5bd500fb..000000000 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/usageExcess.svelte +++ /dev/null @@ -1,20 +0,0 @@ - - - - - Your usage exceeds the limits of the {tierToPlan($organization.billingPlan).name} plan - - View the current usage for {$organization.name} and where you will exceed the limits of - your new plan. - - - -