mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
chore: delete old wizard, small fixes
This commit is contained in:
1 parent
760c15ebc9
commit
dba4bf5d2a
10 files changed
+3
-834
No files matched your search
File renamed without changes.
@@ -92,7 +92,7 @@
|
||||
billingPlan = plan as BillingPlan;
|
||||
}
|
||||
}
|
||||
billingPlan = $organization.billingPlan;
|
||||
billingPlan = BillingPlan.PRO;
|
||||
});
|
||||
|
||||
async function loadPaymentMethods() {
|
||||
@@ -262,7 +262,7 @@
|
||||
<Button href="https://appwrite.io/pricing" external link>pricing page</Button>.
|
||||
</p>
|
||||
{#if anyOrgFree && billingPlan === BillingPlan.PRO}
|
||||
<Alert type="warning" class="u-margin-block-8">
|
||||
<Alert type="warning" class="u-margin-block-16">
|
||||
You are limited to one Starter organization per account. Consider upgrading or
|
||||
deleting <Button link href={`${base}/console/organization-${anyOrgFree.$id}`}
|
||||
>{anyOrgFree.name}</Button
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import { plansInfo, tierToPlan, upgradeURL } from '$lib/stores/billing';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { onMount } from 'svelte';
|
||||
import PlanExcess from '../wizard/cloudOrganizationChangeTier/planExcess.svelte';
|
||||
import type { OrganizationUsage } from '$lib/sdk/billing';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
@@ -12,6 +11,7 @@
|
||||
import { goto } from '$app/navigation';
|
||||
import { last } from '$lib/helpers/array';
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import PlanExcess from '$lib/components/billing/planExcess.svelte';
|
||||
|
||||
export let show = false;
|
||||
const plan = $plansInfo?.get($organization.billingPlan);
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
<script lang="ts">
|
||||
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
|
||||
};
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<WizardStep beforeSubmit={handleAddress}>
|
||||
<svelte:fragment slot="title">Billing address</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">Add a billing address for your organization.</svelte:fragment>
|
||||
|
||||
<FormList class="u-margin-block-start-8">
|
||||
{#if addressList}
|
||||
<RadioBoxes
|
||||
total={addressList?.total}
|
||||
name="address"
|
||||
bind:group={$changeOrganizationTier.billingAddressId}
|
||||
elements={addressList.billingAddresses}>
|
||||
<svelte:fragment slot="element" let:element>
|
||||
<div
|
||||
class="u-line-height-1-5 u-flex u-flex-vertical u-gap-2"
|
||||
style="padding-inline:0.25rem">
|
||||
<p class="text">{element.streetAddress}</p>
|
||||
{#if element?.addressLine2}
|
||||
<p class="text">{element.addressLine2}</p>
|
||||
{/if}
|
||||
<p class="text">{element.city}</p>
|
||||
<p class="text">{element.state}</p>
|
||||
<p class="text">{element.postalCode}</p>
|
||||
<p class="text">{element.country}</p>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="new">
|
||||
<span style="padding-inline:0.25rem">Add new billing address</span>
|
||||
</svelte:fragment>
|
||||
|
||||
<FormList gap={16} class="u-margin-block-start-24">
|
||||
<InputText
|
||||
bind:value={$changeOrganizationTier.taxId}
|
||||
id="text"
|
||||
label="Tax ID"
|
||||
placeholder="Enter tax ID"
|
||||
optionalText="(optional)" />
|
||||
<InputSelect
|
||||
bind:value={country}
|
||||
{options}
|
||||
label="Country or region"
|
||||
placeholder="Select country or region"
|
||||
id="country"
|
||||
required />
|
||||
<InputText
|
||||
bind:value={streetAddress}
|
||||
id="address"
|
||||
label="Street address"
|
||||
placeholder="Enter street address"
|
||||
required />
|
||||
<InputText
|
||||
bind:value={addressLine2}
|
||||
id="address2"
|
||||
label="Address line 2"
|
||||
placeholder="Unit number, floor, etc." />
|
||||
<InputText
|
||||
bind:value={city}
|
||||
id="city"
|
||||
label="City or suburb"
|
||||
placeholder="Enter your city"
|
||||
required />
|
||||
<FormItem isMultiple>
|
||||
<InputText
|
||||
isMultiple
|
||||
fullWidth
|
||||
bind:value={state}
|
||||
id="state"
|
||||
label="State"
|
||||
placeholder="Enter your state"
|
||||
required />
|
||||
<InputText
|
||||
isMultiple
|
||||
fullWidth
|
||||
bind:value={postalCode}
|
||||
id="zip"
|
||||
label="Postal code"
|
||||
placeholder="Enter postal code" />
|
||||
</FormItem>
|
||||
</FormList>
|
||||
</RadioBoxes>
|
||||
{/if}
|
||||
</FormList>
|
||||
</WizardStep>
|
||||
@@ -1,195 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { LabelCard } from '$lib/components';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { plansInfo, tierFree, tierPro, tierScale } from '$lib/stores/billing';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { updateStepStatus } from '$lib/stores/wizard';
|
||||
import { onMount } from 'svelte';
|
||||
import { changeOrganizationTier, changeTierSteps, isUpgrade } from './store';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { OrganizationUsage } from '$lib/sdk/billing';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { sizeToBytes } from '$lib/helpers/sizeConvertion';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { BillingPlan } from '$lib/constants';
|
||||
import { formatCurrency } from '$lib/helpers/numbers';
|
||||
|
||||
let usage: OrganizationUsage = null;
|
||||
let members: Models.MembershipList = null;
|
||||
|
||||
$: if ($changeOrganizationTier.billingPlan === BillingPlan.STARTER && $changeTierSteps) {
|
||||
$changeTierSteps = updateStepStatus($changeTierSteps, 2, true);
|
||||
$changeTierSteps = updateStepStatus($changeTierSteps, 3, true);
|
||||
$changeTierSteps = updateStepStatus($changeTierSteps, 4, true);
|
||||
}
|
||||
|
||||
$: if (
|
||||
$changeOrganizationTier.billingPlan === BillingPlan.SCALE ||
|
||||
$changeOrganizationTier.billingPlan === BillingPlan.PRO
|
||||
) {
|
||||
$changeTierSteps = updateStepStatus($changeTierSteps, 2, false);
|
||||
$changeTierSteps = updateStepStatus($changeTierSteps, 3, false);
|
||||
$changeTierSteps = updateStepStatus($changeTierSteps, 4, false);
|
||||
}
|
||||
|
||||
$: if ($changeOrganizationTier.billingPlan) {
|
||||
$isUpgrade = $changeOrganizationTier.billingPlan > $organization.billingPlan;
|
||||
checkOverUsage();
|
||||
}
|
||||
|
||||
function checkOverUsage() {
|
||||
if (!usage) return;
|
||||
const plan = $plansInfo?.get($changeOrganizationTier.billingPlan);
|
||||
|
||||
const totBandwidth = usage?.bandwidth?.length > 0 ? usage.bandwidth[0].value : 0;
|
||||
const totUsers = usage?.users?.length > 0 ? usage.users[0].value : 0;
|
||||
$changeOrganizationTier.limitOverflow = {
|
||||
bandwidth: totBandwidth > plan.bandwidth ? totBandwidth - plan.bandwidth : 0,
|
||||
storage:
|
||||
usage.storageTotal > sizeToBytes(plan.storage, 'GB')
|
||||
? usage.storageTotal - plan.storage
|
||||
: 0,
|
||||
users: totUsers > plan.users ? totUsers - plan.users : 0,
|
||||
executions:
|
||||
usage.executionsTotal > plan.executions
|
||||
? usage.executionsTotal - plan.executions
|
||||
: 0,
|
||||
members: members.total > plan.members ? members.total - (plan.members || Infinity) : 0
|
||||
};
|
||||
if (
|
||||
($changeOrganizationTier.limitOverflow.bandwidth > 0 ||
|
||||
$changeOrganizationTier.limitOverflow.storage > 0 ||
|
||||
$changeOrganizationTier.limitOverflow.users > 0 ||
|
||||
$changeOrganizationTier.limitOverflow.executions > 0 ||
|
||||
$changeOrganizationTier.limitOverflow.members > 0) &&
|
||||
$changeOrganizationTier.billingPlan === BillingPlan.STARTER
|
||||
) {
|
||||
$changeOrganizationTier.isOverLimit = true;
|
||||
$changeTierSteps = updateStepStatus($changeTierSteps, 5, false);
|
||||
} else {
|
||||
$changeOrganizationTier.isOverLimit = false;
|
||||
$changeTierSteps = updateStepStatus($changeTierSteps, 5, true);
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
usage = await sdk.forConsole.billing.listUsage($organization.$id);
|
||||
members = await sdk.forConsole.teams.listMemberships($organization.$id);
|
||||
|
||||
//Select closest tier from starting one
|
||||
// if ($organization.billingPlan === BillingPlan.SCALE) {
|
||||
// $changeOrganizationTier.billingPlan = BillingPlan.PRO;
|
||||
// }
|
||||
// else
|
||||
if ($organization.billingPlan === BillingPlan.PRO) {
|
||||
$changeOrganizationTier.billingPlan = BillingPlan.STARTER;
|
||||
} else if ($organization.billingPlan === BillingPlan.STARTER) {
|
||||
$changeOrganizationTier.billingPlan = BillingPlan.PRO;
|
||||
}
|
||||
});
|
||||
|
||||
async function handleBefore() {
|
||||
if (!$changeOrganizationTier.billingPlan) {
|
||||
throw new Error('Please select a plan.');
|
||||
}
|
||||
if ($changeOrganizationTier.billingPlan === BillingPlan.STARTER) {
|
||||
$changeOrganizationTier.collaborators = [];
|
||||
}
|
||||
}
|
||||
|
||||
$: freePlan = $plansInfo?.get(BillingPlan.STARTER);
|
||||
$: proPlan = $plansInfo?.get(BillingPlan.PRO);
|
||||
$: scalePlan = $plansInfo?.get(BillingPlan.SCALE);
|
||||
</script>
|
||||
|
||||
<WizardStep beforeSubmit={handleBefore}>
|
||||
<svelte:fragment slot="title">Plan selection</svelte:fragment>
|
||||
|
||||
<p class="body-text-1 u-bold common-section">Plan</p>
|
||||
<p class="text u-margin-block-start-4">
|
||||
For more details on our plans, visit our <a
|
||||
class="link"
|
||||
href="http://appwrite.io/pricing"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer">pricing page</a
|
||||
>.
|
||||
</p>
|
||||
<ul
|
||||
class="u-flex u-flex-vertical u-gap-16 u-margin-block-start-8"
|
||||
style="--p-grid-item-size:16em; --p-grid-item-size-small-screens:16rem; --grid-gap: 1rem;">
|
||||
<li>
|
||||
<LabelCard
|
||||
name="plan"
|
||||
bind:group={$changeOrganizationTier.billingPlan}
|
||||
value="tier-0"
|
||||
disabled={$organization.billingPlan === BillingPlan.STARTER}>
|
||||
<svelte:fragment slot="custom" let:disabled>
|
||||
<div
|
||||
class="u-flex u-flex-vertical u-gap-4 u-width-full-line"
|
||||
class:u-opacity-50={disabled}>
|
||||
<h4 class="body-text-2 u-bold">
|
||||
{tierFree.name} - {formatCurrency(freePlan.price)}/month
|
||||
</h4>
|
||||
<p class="u-color-text-gray u-small">{tierFree.description}</p>
|
||||
</div>
|
||||
<div class:u-opacity-50={disabled}>
|
||||
{#if $organization.billingPlan === BillingPlan.STARTER}
|
||||
<Pill disabled>CURRENT PLAN</Pill>
|
||||
{/if}
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</LabelCard>
|
||||
</li>
|
||||
<li>
|
||||
<LabelCard
|
||||
name="plan"
|
||||
bind:group={$changeOrganizationTier.billingPlan}
|
||||
value="tier-1"
|
||||
disabled={$organization.billingPlan === BillingPlan.PRO}>
|
||||
<svelte:fragment slot="custom" let:disabled>
|
||||
<div
|
||||
class="u-flex u-flex-vertical u-gap-4 u-width-full-line"
|
||||
class:u-opacity-50={disabled}>
|
||||
<h4 class="body-text-2 u-bold">
|
||||
{tierPro.name} - {formatCurrency(proPlan.price)}/month per organization
|
||||
member + extra usage
|
||||
</h4>
|
||||
<p class="u-color-text-gray u-small">
|
||||
{tierPro.description}
|
||||
</p>
|
||||
</div>
|
||||
<div class:u-opacity-50={disabled}>
|
||||
{#if $organization.billingPlan === BillingPlan.PRO}
|
||||
<Pill disabled>CURRENT PLAN</Pill>
|
||||
{:else if proPlan?.trialDays}
|
||||
<Pill>{proPlan?.trialDays} DAY FREE TRIAL</Pill>
|
||||
{/if}
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</LabelCard>
|
||||
</li>
|
||||
<li>
|
||||
<LabelCard
|
||||
name="plan"
|
||||
bind:group={$changeOrganizationTier.billingPlan}
|
||||
value="tier-2"
|
||||
disabled>
|
||||
<svelte:fragment slot="custom" let:disabled>
|
||||
<div
|
||||
class="u-flex u-flex-vertical u-gap-4 u-width-full-line"
|
||||
class:u-opacity-50={disabled}>
|
||||
<h4 class="body-text-2 u-bold">
|
||||
{tierScale.name} - {formatCurrency(scalePlan.price)}/month + extra usage
|
||||
</h4>
|
||||
<p class="u-color-text-gray u-small">
|
||||
{tierScale.description}
|
||||
</p>
|
||||
</div>
|
||||
<div class:u-opacity-50={disabled}>
|
||||
<Pill disabled>COMING SOON</Pill>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</LabelCard>
|
||||
</li>
|
||||
</ul>
|
||||
</WizardStep>
|
||||
@@ -1,161 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Box, CreditCardBrandImage } from '$lib/components';
|
||||
import { CouponInput } from '$lib/components/billing';
|
||||
import { BillingPlan } from '$lib/constants';
|
||||
import { FormList, InputSelect, InputTextarea } from '$lib/elements/forms';
|
||||
import { toLocaleDate } from '$lib/helpers/date';
|
||||
import { formatCurrency } from '$lib/helpers/numbers';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import { plansInfo } from '$lib/stores/billing';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import {
|
||||
changeOrganizationFinalAction,
|
||||
changeOrganizationTier,
|
||||
feedbackDowngradeOptions,
|
||||
isUpgrade
|
||||
} from './store';
|
||||
|
||||
const plan = $plansInfo.get($changeOrganizationTier.billingPlan);
|
||||
const collaboratorPrice = plan?.addons.member?.price ?? 0;
|
||||
const collaboratorsNumber = $changeOrganizationTier?.collaborators?.length ?? 0;
|
||||
const totalExpences = plan.price + collaboratorPrice * collaboratorsNumber;
|
||||
const today = new Date();
|
||||
|
||||
$: billingPayDate = $isUpgrade
|
||||
? new Date(today.getTime() + 44 * 24 * 60 * 60 * 1000)
|
||||
: $organization.billingCurrentInvoiceDate;
|
||||
|
||||
let coupon: string = null;
|
||||
let couponData: Partial<Coupon> = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
};
|
||||
|
||||
async function fetchCard() {
|
||||
try {
|
||||
const card = await sdk.forConsole.billing.getPaymentMethod(
|
||||
$changeOrganizationTier.paymentMethodId
|
||||
);
|
||||
return card;
|
||||
} catch (error) {
|
||||
throw new Error(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
$: downgradeToStarter = $changeOrganizationTier.billingPlan === BillingPlan.STARTER;
|
||||
$: if (!$isUpgrade) {
|
||||
$changeOrganizationFinalAction = 'Confirm plan change';
|
||||
}
|
||||
|
||||
$: if (plan?.trialDays) {
|
||||
$changeOrganizationFinalAction = 'Start trial';
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if downgradeToStarter}
|
||||
<WizardStep>
|
||||
<svelte:fragment slot="title">Change confirmation</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">
|
||||
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.
|
||||
</svelte:fragment>
|
||||
<FormList>
|
||||
<InputSelect
|
||||
id="reason"
|
||||
label="What made you decide to change your plan?*"
|
||||
placeholder="Select one"
|
||||
required
|
||||
options={feedbackDowngradeOptions}
|
||||
bind:value={$changeOrganizationTier.feedbackDowngradeReason} />
|
||||
<InputTextarea
|
||||
id="comment"
|
||||
label="Your feedback here"
|
||||
placeholder="Enter feedback"
|
||||
bind:value={$changeOrganizationTier.feedbackMessage} />
|
||||
</FormList>
|
||||
</WizardStep>
|
||||
{:else}
|
||||
<WizardStep>
|
||||
<svelte:fragment slot="title">Details</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">
|
||||
Confirm the details of your new organization{!$plansInfo.get(
|
||||
$changeOrganizationTier.billingPlan
|
||||
)?.trialDays
|
||||
? '.'
|
||||
: ' and start your free trial.'}
|
||||
</svelte:fragment>
|
||||
|
||||
<p class="body-text-1 u-bold">Organization name</p>
|
||||
<div class="u-flex u-gap-8 u-cross-center u-margin-block-start-8">
|
||||
<p class="text">{$organization.name}</p>
|
||||
</div>
|
||||
|
||||
{#if $changeOrganizationTier.billingPlan !== BillingPlan.STARTER}
|
||||
<div class="u-margin-block-start-32">
|
||||
<p class="body-text-1 u-bold">Additional members</p>
|
||||
<p class="text u-margin-block-start-8">{collaboratorsNumber} members</p>
|
||||
</div>
|
||||
<div class="u-margin-block-start-32">
|
||||
<p class="body-text-1 u-bold">Payment</p>
|
||||
{#await fetchCard()}
|
||||
<div class="u-flex u-margin-block-start-8">
|
||||
<div class="loader is-small" />
|
||||
</div>
|
||||
{:then card}
|
||||
<span class="u-flex u-cross-center u-gap-8 u-margin-block-start-8">
|
||||
<p class="text">
|
||||
Card ending in {card.last4}
|
||||
</p>
|
||||
<CreditCardBrandImage brand={card.brand}></CreditCardBrandImage>
|
||||
</span>
|
||||
{/await}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<Box class="u-margin-block-start-32 u-flex u-flex-vertical u-gap-16" radius="small">
|
||||
{#if $changeOrganizationTier.billingPlan !== BillingPlan.STARTER}
|
||||
<CouponInput
|
||||
bind:coupon
|
||||
bind:couponData
|
||||
on:validation={(e) => ($changeOrganizationTier.couponCode = e.detail.code)} />
|
||||
<span class="u-flex u-main-space-between">
|
||||
<p class="text">{plan.name} plan</p>
|
||||
<p class="text">{formatCurrency(plan.price)}</p>
|
||||
</span>
|
||||
<span class="u-flex u-main-space-between">
|
||||
<p class="text">Additional members ({collaboratorsNumber})</p>
|
||||
<p class="text">{formatCurrency(collaboratorPrice * collaboratorsNumber)}</p>
|
||||
</span>
|
||||
{#if couponData?.status === 'active'}
|
||||
<span class="u-flex u-main-space-between">
|
||||
<p class="text">Credits applied ({couponData.credits})</p>
|
||||
<p class="text">-{formatCurrency(couponData.credits)}</p>
|
||||
</span>
|
||||
{/if}
|
||||
{/if}
|
||||
{@const estimatedTotal =
|
||||
couponData?.status === 'active'
|
||||
? totalExpences - couponData.credits >= 0
|
||||
? totalExpences - couponData.credits
|
||||
: 0
|
||||
: totalExpences}
|
||||
<div class="u-sep-block-start" />
|
||||
<span class="u-flex u-main-space-between">
|
||||
<p class="text">Estimated total</p>
|
||||
<p class="text">
|
||||
{formatCurrency(estimatedTotal)}
|
||||
</p>
|
||||
</span>
|
||||
|
||||
<p class="text u-margin-block-start-16">
|
||||
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())}`}.
|
||||
</p>
|
||||
</Box>
|
||||
</WizardStep>
|
||||
{/if}
|
||||
@@ -1,119 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Alert } from '$lib/components';
|
||||
import { Button, Form, FormList, InputEmail } from '$lib/elements/forms';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableCellHead,
|
||||
TableCellText,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from '$lib/elements/table';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { plansInfo } from '$lib/stores/billing';
|
||||
import { onMount } from 'svelte';
|
||||
import { changeOrganizationTier } from './store';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { BillingPlan } from '$lib/constants';
|
||||
import { formatCurrency } from '$lib/helpers/numbers';
|
||||
|
||||
const plan = $plansInfo.get($changeOrganizationTier.billingPlan);
|
||||
|
||||
let email: string;
|
||||
|
||||
onMount(async () => {
|
||||
const members = await sdk.forConsole.teams.listMemberships($organization.$id);
|
||||
if (members.total) {
|
||||
$changeOrganizationTier.collaborators = members.memberships
|
||||
.map((m) => {
|
||||
if (m.userEmail !== $user.email) return m.userEmail;
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
});
|
||||
|
||||
function addCollaborator() {
|
||||
if (!email) return;
|
||||
if ($changeOrganizationTier.collaborators.includes(email)) return;
|
||||
|
||||
$changeOrganizationTier.collaborators.push(email);
|
||||
$changeOrganizationTier = $changeOrganizationTier;
|
||||
email = '';
|
||||
}
|
||||
|
||||
function removeCollaborator(email: string) {
|
||||
$changeOrganizationTier.collaborators = $changeOrganizationTier.collaborators.filter(
|
||||
(collaborator) => collaborator !== email
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<WizardStep>
|
||||
<svelte:fragment slot="title">Invites</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">
|
||||
Invite team members to collaborate with you in the Appwrite console. Members will have
|
||||
access to all services and payment data within your organization.
|
||||
</svelte:fragment>
|
||||
|
||||
<Alert type="info">
|
||||
{#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
|
||||
<b>{formatCurrency(plan.addons.member.price)} each per month</b>. Each member added will
|
||||
receive an email invite to your organization on completion.
|
||||
{/if}
|
||||
</Alert>
|
||||
|
||||
<div class="u-margin-block-start-24">
|
||||
<Form onSubmit={addCollaborator}>
|
||||
<FormList>
|
||||
<InputEmail
|
||||
label="Email address"
|
||||
id="email"
|
||||
placeholder="Email address"
|
||||
bind:value={email}>
|
||||
<Button secondary submit>Add</Button>
|
||||
</InputEmail>
|
||||
</FormList>
|
||||
</Form>
|
||||
</div>
|
||||
|
||||
{#if $changeOrganizationTier?.collaborators?.length}
|
||||
<div class="u-margin-block-start-24">
|
||||
<Table noStyles noMargin>
|
||||
<TableHeader>
|
||||
<TableCellHead>Collaborator</TableCellHead>
|
||||
{#if $changeOrganizationTier.billingPlan === BillingPlan.PRO}
|
||||
<TableCellHead width={80}>Cost</TableCellHead>
|
||||
{/if}
|
||||
<TableCellHead width={40} />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each $changeOrganizationTier.collaborators as collaborator}
|
||||
<TableRow>
|
||||
<TableCellText title="collaborator">{collaborator}</TableCellText>
|
||||
{#if $changeOrganizationTier.billingPlan === BillingPlan.PRO}
|
||||
<TableCellText title="cost">{formatCurrency(15)}</TableCellText>
|
||||
{/if}
|
||||
<TableCell>
|
||||
<button
|
||||
type="button"
|
||||
class="button is-text is-only-icon"
|
||||
style="--button-size:1.5rem;"
|
||||
aria-label="remove collaborator"
|
||||
on:click={() => removeCollaborator(collaborator)}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
{/if}
|
||||
</WizardStep>
|
||||
@@ -1,119 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { FormList, InputNumber } from '$lib/elements/forms';
|
||||
import InputChoice from '$lib/elements/forms/inputChoice.svelte';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { changeOrganizationTier } from './store';
|
||||
import type { PaymentList, PaymentMethodData } from '$lib/sdk/billing';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { initializeStripe, isStripeInitialized, submitStripeCard } from '$lib/stores/stripe';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { showUsageRatesModal } from '$lib/stores/billing';
|
||||
import { PaymentBoxes } from '$lib/components/billing';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
let methods: PaymentList;
|
||||
let filteredMethods: PaymentMethodData[];
|
||||
let name: string;
|
||||
let budgetEnabled = false;
|
||||
let initialPaymentMethodId: string;
|
||||
onMount(async () => {
|
||||
methods = await sdk.forConsole.billing.listPaymentMethods();
|
||||
filteredMethods = methods?.paymentMethods.filter((method) => !!method?.last4);
|
||||
|
||||
initialPaymentMethodId =
|
||||
$organization?.paymentMethodId ??
|
||||
$organization?.backupPaymentMethodId ??
|
||||
filteredMethods[0]?.$id ??
|
||||
null;
|
||||
$changeOrganizationTier.paymentMethodId = initialPaymentMethodId;
|
||||
$changeOrganizationTier.billingBudget = $organization?.billingBudget;
|
||||
budgetEnabled = !!$organization?.billingBudget;
|
||||
});
|
||||
|
||||
async function handleSubmit() {
|
||||
if ($changeOrganizationTier.billingBudget < 0) {
|
||||
throw new Error('Budget cannot be negative');
|
||||
}
|
||||
if ($changeOrganizationTier.paymentMethodId) {
|
||||
const card = await sdk.forConsole.billing.getPaymentMethod(
|
||||
$changeOrganizationTier.paymentMethodId
|
||||
);
|
||||
if (!card?.last4) {
|
||||
throw new Error(
|
||||
'The payment method you selected is not valid. Please select a different one.'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const method = await submitStripeCard(name, $page?.params?.organization ?? null);
|
||||
const card = await sdk.forConsole.billing.getPaymentMethod(method.$id);
|
||||
if (card?.last4) {
|
||||
$changeOrganizationTier.paymentMethodId = method.$id;
|
||||
} else {
|
||||
throw new Error(
|
||||
'The payment method you selected is not valid. Please select a different one.'
|
||||
);
|
||||
}
|
||||
|
||||
invalidate(Dependencies.PAYMENT_METHODS);
|
||||
} catch (e) {
|
||||
throw new Error(e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$: if ($changeOrganizationTier.paymentMethodId === null && !$isStripeInitialized) {
|
||||
initializeStripe();
|
||||
}
|
||||
|
||||
$: if ($changeOrganizationTier.paymentMethodId) {
|
||||
isStripeInitialized.set(false);
|
||||
}
|
||||
|
||||
$: if (!budgetEnabled) {
|
||||
$changeOrganizationTier.billingBudget = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<WizardStep beforeSubmit={handleSubmit}>
|
||||
<svelte:fragment slot="title">Payment details</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">
|
||||
Confirm the payment method for your organization.
|
||||
</svelte:fragment>
|
||||
|
||||
<FormList>
|
||||
<PaymentBoxes
|
||||
methods={filteredMethods}
|
||||
bind:name
|
||||
bind:group={$changeOrganizationTier.paymentMethodId} />
|
||||
|
||||
<InputChoice
|
||||
type="switchbox"
|
||||
id="budget"
|
||||
label="Enable budget cap"
|
||||
tooltip="If enabled, you will be notified by email when your organization spend reaches 75% of the cap you set. Update your budget cap alerts in organization Settings."
|
||||
fullWidth
|
||||
bind:value={budgetEnabled}>
|
||||
<p class="text">
|
||||
Restrict your resource usage by setting a budget cap. <button
|
||||
class="link"
|
||||
type="button"
|
||||
on:click={() => ($showUsageRatesModal = true)}>
|
||||
Learn more about usage rates</button
|
||||
>.
|
||||
</p>
|
||||
{#if budgetEnabled}
|
||||
<div class="u-margin-block-start-16">
|
||||
<InputNumber
|
||||
id="budget"
|
||||
label="Budget cap (USD)"
|
||||
placeholder="0"
|
||||
bind:value={$changeOrganizationTier.billingBudget} />
|
||||
</div>
|
||||
{/if}
|
||||
</InputChoice>
|
||||
</FormList>
|
||||
</WizardStep>
|
||||
@@ -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<WizardStepsType>(new Map());
|
||||
export const isUpgrade = writable<boolean>(false);
|
||||
export const changeOrganizationFinalAction = writable<string>('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'
|
||||
}
|
||||
];
|
||||
@@ -1,20 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { tierToPlan } from '$lib/stores/billing';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import PlanExcess from './planExcess.svelte';
|
||||
import { changeOrganizationTier } from './store';
|
||||
</script>
|
||||
|
||||
<WizardStep>
|
||||
<svelte:fragment slot="title">
|
||||
Your usage exceeds the limits of the {tierToPlan($organization.billingPlan).name} plan</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">
|
||||
View the current usage for <b>{$organization.name}</b> and where you will exceed the limits of
|
||||
your new plan.
|
||||
</svelte:fragment>
|
||||
|
||||
<PlanExcess
|
||||
excess={$changeOrganizationTier.limitOverflow}
|
||||
currentTier={$changeOrganizationTier.billingPlan} />
|
||||
</WizardStep>
|
||||
Reference in new issue
Block a user