diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 12bc2fd80..6dfc31a99 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -260,39 +260,82 @@ export const eventServices: Array = [ export const usageRates = { 'tier-0': [ - { 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: 'Organization members', amount: 'Unlimited', unit: '', rate: '$20/member' }, + { resource: 'Bandwidth', amount: 1, unit: 'TB', rate: '$0.04/GB' }, + { resource: 'Storage', amount: 150, unit: 'GB', rate: '$0.025/GB' }, { resource: 'Function executions', - limit: '3,500,000 executions', + amount: 3500000, + unit: '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' } + { + resource: 'Active users', + amount: 200000, + unit: 'AU', + rate: '$0.0012/user' + }, + { + resource: 'Concurrent connections', + amount: 750, + unit: '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: 'Organization members', + amount: 'Unlimited', + unit: '', + rate: '$20/member' + }, + { resource: 'Bandwidth', amount: 1, unit: 'TB', rate: '$0.04/GB' }, + { resource: 'Storage', amount: 150, unit: 'GB', rate: '$0.025/GB' }, { resource: 'Function executions', - limit: '3,500,000 executions', + amount: 3500000, + unit: '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' } + { + resource: 'Active users', + amount: 200000, + unit: 'AU', + rate: '$0.0012/user' + }, + { + resource: 'Concurrent connections', + amount: 750, + unit: '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: 'Organization members', + amount: 'Unlimited', + unit: '', + rate: '$20/member' + }, + { resource: 'Bandwidth', amount: 1, unit: 'TB', rate: '$0.04/GB' }, + { resource: 'Storage', amount: 150, unit: 'GB', rate: '$0.025/GB' }, { resource: 'Function executions', - limit: '3,500,000 executions', + amount: 3500000, + unit: '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' } + { + resource: 'Active users', + amount: 200000, + unit: 'AU', + rate: '$0.0012/user' + }, + { + resource: 'Concurrent connections', + amount: 750, + unit: 'connections', + rate: '$5/1K connections' + } ] }; diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index bfd05ba6e..d96006de2 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -236,7 +236,10 @@ export class Billing { ); } - async setOrganizationPaymentMethod(organizationId: string, paymentMethodId: string) { + async setOrganizationPaymentMethod( + organizationId: string, + paymentMethodId: string + ): Promise { const path = `/organizations/${organizationId}/payment-method`; const params = { organizationId, @@ -253,7 +256,10 @@ export class Billing { ); } - async setOrganizationPaymentMethodBackup(organizationId: string, paymentMethodId: string) { + async setOrganizationPaymentMethodBackup( + organizationId: string, + paymentMethodId: string + ): Promise { const path = `/organizations/${organizationId}/payment-method/backup`; const params = { organizationId, diff --git a/src/routes/console/organization-[organization]/billing/paymentMethods.svelte b/src/routes/console/organization-[organization]/billing/paymentMethods.svelte index 6dad85f71..8e538652e 100644 --- a/src/routes/console/organization-[organization]/billing/paymentMethods.svelte +++ b/src/routes/console/organization-[organization]/billing/paymentMethods.svelte @@ -74,46 +74,46 @@ } } - // async function removeDefaultMethod(){ - // try { - // await sdk.forConsole.billing.remove( - // $organization.$id, - // $organization.paymentMethodId - // ); - // addNotification({ - // type: 'success', - // message: `The payment method has been removed from ${$organization.name}` - // }); - // trackEvent(Submit.OrganizationPaymentRemoved); - // invalidate(Dependencies.ORGANIZATION); - // } catch (error) { - // addNotification({ - // type: 'error', - // message: error.message - // }); - // trackError(error, Submit.OrganizationPaymentRemoved); - // } - // } - // async function removeBackuptMethod(){ - // try { - // await sdk.forConsole.billing.remove( - // $organization.$id, - // $organization.paymentMethodId - // ); - // addNotification({ - // type: 'success', - // message: `The payment method has been removed from ${$organization.name}` - // }); - // trackEvent(Submit.OrganizationBackupPaymentRemoved); - // invalidate(Dependencies.ORGANIZATION); - // } catch (error) { - // addNotification({ - // type: 'error', - // message: error.message - // }); - // trackError(error, Submit.OrganizationBackupPaymentRemoved); - // } - // } + async function removeDefaultMethod() { + if (!$organization.paymentMethodId || !$organization.backupPaymentMethodId) return; + + try { + await sdk.forConsole.billing.setOrganizationPaymentMethod($organization.$id, null); + addNotification({ + type: 'success', + message: `The payment method has been removed from ${$organization.name}` + }); + trackEvent(Submit.OrganizationPaymentRemoved); + invalidate(Dependencies.ORGANIZATION); + } catch (error) { + addNotification({ + type: 'error', + message: error.message + }); + trackError(error, Submit.OrganizationPaymentRemoved); + } + } + async function removeBackuptMethod() { + if (!$organization.paymentMethodId || !$organization.backupPaymentMethodId) return; + try { + await sdk.forConsole.billing.setOrganizationPaymentMethodBackup( + $organization.$id, + undefined + ); + addNotification({ + type: 'success', + message: `The payment method has been removed from ${$organization.name}` + }); + trackEvent(Submit.OrganizationBackupPaymentRemoved); + invalidate(Dependencies.ORGANIZATION); + } catch (error) { + addNotification({ + type: 'error', + message: error.message + }); + trackError(error, Submit.OrganizationBackupPaymentRemoved); + } + } @@ -126,10 +126,34 @@

Default

{#if $organization?.paymentMethodId} - + + + + + { + console.log('test'); + }}> + Edit + + + Delete + + + + {:else}
@@ -169,7 +193,34 @@ {/if}

Backup

{#if $organization?.backupPaymentMethodId} - + + + + + { + console.log('test'); + }}> + Edit + + + Delete + + + + {:else}
diff --git a/src/routes/console/organization-[organization]/usage/[[period]]/+page.svelte b/src/routes/console/organization-[organization]/usage/[[period]]/+page.svelte index a5f97bdaa..28f6b039b 100644 --- a/src/routes/console/organization-[organization]/usage/[[period]]/+page.svelte +++ b/src/routes/console/organization-[organization]/usage/[[period]]/+page.svelte @@ -1,16 +1,34 @@ Usage

- Metrics are estimates updated every 24 hours and may not accurately reflect your - invoice. + If you exceed the limits of the Free plan, services for your projects may be disrupted. Upgrade for greater capacity.

Usage period:

@@ -18,14 +36,27 @@ JANUARY 2021
-
    - - {#each [] as project} - - {/each} -
+ + + Bandwidth + +

+ Calculated for all bandwidth used across all projects in your organization. +

+ + + + +
+ + Active users + +

Active users across all projects in your organization.

+ + + + +
Function executions @@ -35,7 +66,23 @@

- +
+ + + Storage + +

+ Calculated for all storage operations across all projects in your organization. +

+ + + + +
+ +

+ Metrics are estimates updated every 24 hours and may not accurately reflect your invoice. +

diff --git a/src/routes/console/wizard/cloudOrganization/usageRates.svelte b/src/routes/console/wizard/cloudOrganization/usageRates.svelte index f8c1a3d78..9daa5144f 100644 --- a/src/routes/console/wizard/cloudOrganization/usageRates.svelte +++ b/src/routes/console/wizard/cloudOrganization/usageRates.svelte @@ -39,7 +39,7 @@ {#each usageRates[tier] as usage} {usage.resource} - {usage.limit} + {usage.amount}{usage?.unit} {usage.rate} {/each}