mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix information on downgrade
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
import { abbreviateNumber } from '$lib/helpers/numbers';
|
||||
import { formatNum } from '$lib/helpers/string';
|
||||
import { onMount } from 'svelte';
|
||||
import type { OrganizationUsage } from '$lib/sdk/billing';
|
||||
import type { Aggregation } from '$lib/sdk/billing';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { BillingPlan } from '$lib/constants';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
@@ -33,16 +33,15 @@
|
||||
executions?: number;
|
||||
members?: number;
|
||||
} = null;
|
||||
let usage: OrganizationUsage = null;
|
||||
let aggregation: Aggregation = null;
|
||||
let showExcess = false;
|
||||
|
||||
onMount(async () => {
|
||||
usage = await sdk.forConsole.billing.listUsage(
|
||||
aggregation = await sdk.forConsole.billing.getAggregation(
|
||||
$organization.$id,
|
||||
$organization.billingCurrentInvoiceDate,
|
||||
new Date().toISOString()
|
||||
$organization.billingAggregationId
|
||||
);
|
||||
excess = calculateExcess(usage, plan, members);
|
||||
excess = calculateExcess(aggregation, plan);
|
||||
showExcess = Object.values(excess).some((value) => value > 0);
|
||||
});
|
||||
</script>
|
||||
@@ -50,14 +49,12 @@
|
||||
{#if showExcess}
|
||||
<Alert type="error" {...$$restProps}>
|
||||
<svelte:fragment slot="title">
|
||||
Your {tierToPlan($organization.billingPlan).name} plan subscription will end on {toLocaleDate(
|
||||
$organization.billingNextInvoiceDate
|
||||
)}
|
||||
Your organization will switch to {tierToPlan(BillingPlan.FREE).name} plan. You will continue
|
||||
to have access to {tierToPlan($organization.billingPlan).name} plan features until your billing
|
||||
period ends on {toLocaleDate($organization.billingNextInvoiceDate)}
|
||||
</svelte:fragment>
|
||||
Following payment of your final invoice, your organization will switch to the {tierToPlan(
|
||||
BillingPlan.FREE
|
||||
).name} plan. {#if excess?.members > 0}All team members except the owner will be removed on
|
||||
that date.{/if} Service disruptions may occur unless resource usage is reduced.
|
||||
{#if excess?.members > 0}All team members except the owner will be removed on that date.{/if}
|
||||
Service disruptions may occur unless resource usage is reduced.
|
||||
<!-- Any executions, bandwidth, or messaging usage will be reset at that time. -->
|
||||
<svelte:fragment slot="buttons">
|
||||
<Button
|
||||
@@ -83,7 +80,8 @@
|
||||
{#if excess?.members}
|
||||
<TableRow>
|
||||
<TableCellText title="members">Organization members</TableCellText>
|
||||
<TableCellText title="limit">{plan.members} members</TableCellText>
|
||||
<TableCellText title="limit"
|
||||
>{plan.addons.seats.limit || 0} members</TableCellText>
|
||||
<TableCell title="excess">
|
||||
<p class="u-color-text-danger u-flex u-cross-center u-gap-4">
|
||||
<span class="icon-arrow-up" />
|
||||
|
||||
@@ -10,7 +10,8 @@ import type {
|
||||
PlansMap,
|
||||
PaymentMethodData,
|
||||
OrganizationUsage,
|
||||
Plan
|
||||
Plan,
|
||||
Aggregation
|
||||
} from '$lib/sdk/billing';
|
||||
import { isCloud } from '$lib/system';
|
||||
import { cachedStore } from '$lib/helpers/cache';
|
||||
@@ -476,14 +477,12 @@ export const billingURL = derived(
|
||||
|
||||
export const hideBillingHeaderRoutes = ['/console/create-organization', '/console/account'];
|
||||
|
||||
export function calculateExcess(usage: OrganizationUsage, plan: Plan, members: number) {
|
||||
const totBandwidth = usage?.bandwidth?.length > 0 ? last(usage.bandwidth).value : 0;
|
||||
export function calculateExcess(addon: Aggregation, plan: Plan) {
|
||||
return {
|
||||
bandwidth: calculateResourceSurplus(totBandwidth, plan.bandwidth),
|
||||
storage: calculateResourceSurplus(usage?.storageTotal, plan.storage, 'GB'),
|
||||
users: calculateResourceSurplus(usage?.usersTotal, plan.users),
|
||||
executions: calculateResourceSurplus(usage?.executionsTotal, plan.executions, 'GB'),
|
||||
members: calculateResourceSurplus(members - 1, plan.addons.seats.limit || 0)
|
||||
bandwidth: calculateResourceSurplus(addon.usageBandwidth, plan.bandwidth),
|
||||
storage: calculateResourceSurplus(addon.usageStorage, plan.storage, 'GB'),
|
||||
executions: calculateResourceSurplus(addon.usageExecutions, plan.executions, 'GB'),
|
||||
members: addon.additionalMembers
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -370,8 +370,13 @@
|
||||
{:else if $organization.billingPlan !== BillingPlan.CUSTOM}
|
||||
{#if isDowngrade}
|
||||
<Card>
|
||||
Your change will take effect once your current billing cycle ends on <span
|
||||
class="u-bold"
|
||||
Your organization will switch to <span class="u-bold"
|
||||
>{tierToPlan(billingPlan).name} plan</span
|
||||
>. You will continue to have access to
|
||||
<span class="u-bold"
|
||||
>{tierToPlan($organization.billingPlan).name} plan</span>
|
||||
features until your billing period ends on
|
||||
<span class="u-bold"
|
||||
>{toLocaleDate($organization.billingNextInvoiceDate)}</span
|
||||
>.
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user