diff --git a/src/lib/components/billing/planExcess.svelte b/src/lib/components/billing/planExcess.svelte
index 153b5cb996..d940691deb 100644
--- a/src/lib/components/billing/planExcess.svelte
+++ b/src/lib/components/billing/planExcess.svelte
@@ -9,137 +9,128 @@
TableScroll
} from '$lib/elements/table';
import { Alert } from '$lib/components';
- import { plansInfo, type Tier } from '$lib/stores/billing';
+ import { calculateExcess, plansInfo, tierToPlan, type Tier } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { toLocaleDate } from '$lib/helpers/date';
import { Button } from '$lib/elements/forms';
import { humanFileSize } from '$lib/helpers/sizeConvertion';
- import { abbreviateNumber, formatCurrency } from '$lib/helpers/numbers';
+ import { abbreviateNumber } from '$lib/helpers/numbers';
import { formatNum } from '$lib/helpers/string';
- import { BillingPlan } from '$lib/constants';
+ import { onMount } from 'svelte';
+ import type { OrganizationUsage } from '$lib/sdk/billing';
+ import { sdk } from '$lib/stores/sdk';
- export let excess: {
+ export let tier: Tier;
+
+ const plan = $plansInfo?.get(tier);
+ let excess: {
bandwidth?: number;
storage?: number;
users?: number;
executions?: number;
members?: number;
} = null;
- export let currentTier: Tier;
+ let usage: OrganizationUsage = null;
+ let showExcess = false;
- const plan = $plansInfo?.get(currentTier);
- const collaboratorPrice = formatCurrency(plan?.addons.member?.price ?? 0);
+ onMount(async () => {
+ usage = await sdk.forConsole.billing.listUsage(
+ $organization.$id,
+ $organization.billingCurrentInvoiceDate,
+ new Date().toISOString()
+ );
+ excess = calculateExcess(usage, plan, $organization);
+ showExcess = Object.values(excess).some((value) => value > 0);
+ });
-
-
- {excess?.members} members
-
-
- {humanFileSize(excess?.storage)}
-
-
-
- {formatNum(excess?.executions)} executions
-
-
-
-
- {formatNum(excess?.users)} users
-
-
+
+ {excess?.members} members
+
+
+ {humanFileSize(excess?.storage)}
+
+
+
+ {formatNum(excess?.executions)} executions
+
+
+
+
+ {formatNum(excess?.users)} users
+
+