diff --git a/src/lib/constants.ts b/src/lib/constants.ts index c945a9ea9..12bc2fd80 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -260,31 +260,39 @@ export const eventServices: Array = [ export const usageRates = { 'tier-0': [ - { resource: 'Organization members', limit: '1', rate: 'lorem' }, - { resource: 'Bandwidth', limit: '1', rate: 'lorem' }, - { resource: 'Storage', limit: '1', rate: 'lorem' }, - { resource: 'Function executions', limit: '1', rate: 'lorem' }, - { resource: 'Active users', limit: '1', rate: 'lorem' }, - { resource: 'Concurrent connections', limit: '1', rate: 'lorem' } - ], - 'tier-1': [ - { resource: 'Organization members', limit: '1', rate: 'lorem' }, - { resource: 'Bandwidth', limit: '1', rate: 'lorem' }, - { resource: 'Storage', limit: '1', rate: 'lorem' }, - { resource: 'Function executions', limit: '1', rate: 'lorem' }, - { resource: 'Active users', limit: '1', rate: 'lorem' }, - { resource: 'Concurrent connections', limit: '1', rate: 'lorem' } - ], - 'tier-2': [ - { resource: 'Organization members', limit: 'Unlimited', rate: '20$/member' }, + { resource: 'Organization members', limit: 'Unlimited', rate: '$20/member' }, { resource: 'Bandwidth', limit: '1TB', rate: '$0.04/GB' }, { resource: 'Storage', limit: '150GB', rate: '$0.025/GB' }, - { resource: 'Function executions', limit: '3500000 executions', rate: '$2/1M executions' }, - { resource: 'Active users', limit: '200000', rate: '$0.0012/users' }, { - resource: 'Concurrent connections', - limit: '750 connections', - rate: '$5/1000 connections' - } + resource: 'Function executions', + limit: '3,500,000 executions', + rate: '$2/1M executions' + }, + { resource: 'Active users', limit: '200,000 AU', rate: '$0.0012/user' }, + { resource: 'Concurrent connections', limit: '750 connections', rate: '$5/1K connections' } + ], + 'tier-1': [ + { resource: 'Organization members', limit: 'Unlimited', rate: '$20/member' }, + { resource: 'Bandwidth', limit: '1TB', rate: '$0.04/GB' }, + { resource: 'Storage', limit: '150GB', rate: '$0.025/GB' }, + { + resource: 'Function executions', + limit: '3,500,000 executions', + rate: '$2/1M executions' + }, + { resource: 'Active users', limit: '200,000 AU', rate: '$0.0012/user' }, + { resource: 'Concurrent connections', limit: '750 connections', rate: '$5/1K connections' } + ], + 'tier-2': [ + { resource: 'Organization members', limit: 'Unlimited', rate: '$20/member' }, + { resource: 'Bandwidth', limit: '1TB', rate: '$0.04/GB' }, + { resource: 'Storage', limit: '150GB', rate: '$0.025/GB' }, + { + resource: 'Function executions', + limit: '3,500,000 executions', + rate: '$2/1M executions' + }, + { resource: 'Active users', limit: '200,000 AU', rate: '$0.0012/user' }, + { resource: 'Concurrent connections', limit: '750 connections', rate: '$5/1K connections' } ] }; diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index a7861041c..1e0270e05 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -30,6 +30,7 @@ export type Invoice = { from: string; to: string; status: string; + dueAt: string; }; export type InvoiceList = { @@ -176,7 +177,7 @@ export class Billing { organizationId: string, billingPlan: string, paymentMethodId: string - ): Promise { + ): Promise { const path = `/organizations/${organizationId}/plan`; const params = { organizationId, diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte new file mode 100644 index 000000000..bb352eda3 --- /dev/null +++ b/src/routes/console/changeOrganizationTierCloud.svelte @@ -0,0 +1,107 @@ + + + diff --git a/src/routes/console/createOrganizationCloud.svelte b/src/routes/console/createOrganizationCloud.svelte index 909fef323..f31001466 100644 --- a/src/routes/console/createOrganizationCloud.svelte +++ b/src/routes/console/createOrganizationCloud.svelte @@ -72,7 +72,7 @@ $createOrganization = { id: null, name: null, - billingPlan: 'tier-2', + billingPlan: 'tier-1', paymentMethodId: null, collaborators: [] }; @@ -99,7 +99,7 @@ {toLocaleDate(invoice.from)} - test + {invoice.status} {invoice.amount} - {invoice.aggregationId} + + {invoice.$id} - + diff --git a/src/routes/console/wizard/cloudOrganization/step2.svelte b/src/routes/console/wizard/cloudOrganization/step2.svelte index 59bd7c6b4..d17eb341c 100644 --- a/src/routes/console/wizard/cloudOrganization/step2.svelte +++ b/src/routes/console/wizard/cloudOrganization/step2.svelte @@ -181,4 +181,4 @@ - + diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/step1.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/step1.svelte new file mode 100644 index 000000000..498d56068 --- /dev/null +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/step1.svelte @@ -0,0 +1,84 @@ + + + + Choose a plan + +

Plan

+

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

+
    + {#if $organization.billingPlan !== 'tier-0'} +
  • + + +
    +

    + {tierFree.name} - ${tierFree.price}/month +

    +

    {tierFree.description}

    +
    +
    +
    +
  • + {/if} + {#if $organization.billingPlan !== 'tier-1'} +
  • + + +
    +

    + {tierPro.name} - ${tierPro.price}/month per organization member + + exta usage +

    +

    + {tierPro.description} +

    +
    + 14 DAY FREE TRIAL +
    +
    +
  • + {/if} + {#if $organization.billingPlan !== 'tier-2'} +
  • + + +
    +

    + {tierScale.name} - ${tierScale.price}/month + exta usage +

    +

    + {tierScale.description} +

    +
    + 14 DAY FREE TRIAL +
    +
    +
  • + {/if} +
+
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/step2.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/step2.svelte new file mode 100644 index 000000000..7ee7cf059 --- /dev/null +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/step2.svelte @@ -0,0 +1,182 @@ + + + + Payment details + Add a payment method to your organization. + + +
+ {#if methods?.total} + {#each methods.paymentMethods as method} +
+ +
+ {/each} + {/if} + +
+ {#if methods?.total} + + {/if} + {#if $changeOrganizationTier.paymentMethodId === null} + + + +
+ +
+
+ {/if} +
+
+ + +

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

+
+ {#if budgetEnabled} + + {/if} +
+
+ + diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/step3.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/step3.svelte new file mode 100644 index 000000000..020e47ef2 --- /dev/null +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/step3.svelte @@ -0,0 +1,97 @@ + + + + Invite collaborators + + 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 === 'tier-2'} + You can add unlimited organization members on the Scale plan at no cost. Each member + added will receive an email invite to your organization on completion. + {:else if $changeOrganizationTier.billingPlan === 'tier-1'} + You can add unlimited organization members on the Pro plan for $15 each. Each member + added will receive an email invite to your organization on completion. + {/if} + + +
+
+ + + + + +
+
+ + {#if $changeOrganizationTier?.collaborators?.length} +
+ + + Collaborator + {#if $changeOrganizationTier.billingPlan === 'tier-1'} + Cost + {/if} + + + + {#each $changeOrganizationTier.collaborators as collaborator} + + {collaborator} + {#if $changeOrganizationTier.billingPlan === 'tier-1'} + 15$ + {/if} + + + + + {/each} + +
+
+ {/if} +
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/step4.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/step4.svelte new file mode 100644 index 000000000..c356ca920 --- /dev/null +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/step4.svelte @@ -0,0 +1,78 @@ + + + + Confirm your details + + Confirm the details of your new organization and start your free trial. + + +

Organization name

+
+

{$organization.name}

+ {#if $changeOrganizationTier?.id} + {$changeOrganizationTier.id} + {/if} +
+ +
+

Organization members

+

{collaboratorsNumber} invited

+
+
+

Payment

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

Card ending in {card.last4} {card.brand}

+ {/await} +
+ +
+ +

{plan.name} plan

+

${plan.price}

+
+ +

Invited members

+

${plan.collaboratorPrice * collaboratorsNumber}

+
+
+ +

Estimated total

+

${totalExpences}

+
+ +

+ This amount and any extra usage fees will be charged on a recurring 30 day billing cycle + after your trial period ends on {toLocaleDate(billingPayDate.toString())}. +

+
+ diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts new file mode 100644 index 000000000..a904e471d --- /dev/null +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts @@ -0,0 +1,15 @@ +import type { Tier } from '$lib/stores/billing'; +import { writable } from 'svelte/store'; + +export const changeOrganizationTier = writable<{ + id?: string; + billingPlan: Tier; + paymentMethodId: string; + billingBudget?: number; + collaborators?: string[]; +}>({ + id: null, + billingPlan: 'tier-1', + paymentMethodId: null, + collaborators: [] +});