diff --git a/src/routes/(console)/organization-[organization]/billing/+page.svelte b/src/routes/(console)/organization-[organization]/billing/+page.svelte
index 1ee3264c2..ee169c683 100644
--- a/src/routes/(console)/organization-[organization]/billing/+page.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/+page.svelte
@@ -1,6 +1,5 @@
@@ -93,7 +93,7 @@
{#if $failedInvoice}
{#if $failedInvoice?.lastError}
- The scheduled payment for {$organization.name} failed due to following error: {$failedInvoice.lastError}
+ The scheduled payment for {organization.name} failed due to following error: {$failedInvoice.lastError}
@@ -115,16 +115,16 @@
{#if defaultPaymentMethod?.failed && !backupPaymentMethod}
+ title={`The default payment method for ${organization.name} has expired`}>
To avoid service disruptions in your organization's projects, please update your payment
details.
{/if}
- {#if $organization?.billingPlanDowngrade}
+ {#if organization?.billingPlanDowngrade}
- Your organization has changed to {tierToPlan($organization?.billingPlanDowngrade).name} plan.
- You will continue to have access to {tierToPlan($organization?.billingPlan).name} plan features
- until your billing period ends on {toLocaleDate($organization.billingNextInvoiceDate)}.
+ Your organization has changed to {tierToPlan(organization?.billingPlanDowngrade).name} plan.
+ You will continue to have access to {tierToPlan(organization?.billingPlan).name} plan features
+ until your billing period ends on {toLocaleDate(organization.billingNextInvoiceDate)}.
{/if}
Billing
@@ -137,7 +137,7 @@
-
+
diff --git a/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte b/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte
index 81a72d60b..5743273b9 100644
--- a/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte
@@ -7,18 +7,20 @@
import { Button, Form } from '$lib/elements/forms';
import { symmetricDifference } from '$lib/helpers/array';
import { addNotification } from '$lib/stores/notifications';
- import { currentPlan, organization } from '$lib/stores/organization';
+ import { type Organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
- import { onMount } from 'svelte';
import { Alert, Icon, Table } from '@appwrite.io/pink-svelte';
import { IconTrash } from '@appwrite.io/pink-icons-svelte';
import InputSelect from '$lib/elements/forms/inputSelect.svelte';
+ import type { Plan } from '$lib/sdk/billing';
+ export let organization: Organization;
+ export let currentPlan: Plan;
export let alertsEnabled = false;
let search: string;
let selectedAlert: number;
- let alerts: number[] = [];
+ let alerts: number[] = organization?.budgetAlerts ?? [];
$: options = [
{ value: 25, label: '25%', disabled: false },
@@ -33,10 +35,6 @@
};
});
- onMount(() => {
- alerts = $organization?.budgetAlerts ?? [];
- });
-
function addAlert() {
if (alerts.some((alert) => alert === selectedAlert)) {
return;
@@ -50,8 +48,8 @@
async function updateBudget() {
try {
await sdk.forConsole.billing.updateBudget(
- $organization.$id,
- $organization.billingBudget,
+ organization.$id,
+ organization.billingBudget,
alerts
);
@@ -60,7 +58,7 @@
addNotification({
type: 'success',
isHtml: true,
- message: ` ${alerts.length === 0 ? 'Budget alerts removed from' : alerts.length > 1 ? `Budget alerts added to` : 'A budget alert has been added to'} ${$organization.name}`
+ message: ` ${alerts.length === 0 ? 'Budget alerts removed from' : alerts.length > 1 ? `Budget alerts added to` : 'A budget alert has been added to'} ${organization.name}`
});
trackEvent(Submit.BudgetAlertsUpdate, {
alerts
@@ -75,26 +73,26 @@
}
$: isButtonDisabled =
- symmetricDifference(alerts, $organization.budgetAlerts).length === 0 || !alertsEnabled;
+ symmetricDifference(alerts, organization.budgetAlerts).length === 0 || !alertsEnabled;
Billing alerts
- {#if !$currentPlan.budgeting}
+ {#if !currentPlan.budgeting}
Get notified by email when your organization meets a percentage of your budget cap. {tierToPlan($organization.billingPlan).name} organizations will receive one notification
+ >{tierToPlan(organization.billingPlan).name} organizations will receive one notification
at 75% resource usage.
{:else}
Get notified by email when your organization meets or exceeds a percentage of your specified
billing alert(s).
{/if}
- {#if !$currentPlan.budgeting}
+ {#if !currentPlan.budgeting}
Upgrade to a Pro plan to manage when you receive billing alerts for your
organization.
- {:else if !$currentPlan.budgetCapEnabled}
+ {:else if !currentPlan.budgetCapEnabled}
Budget caps are not supported on your current plan. For more information, please
reach out to your customer success manager.
@@ -150,7 +148,7 @@
- 0} />
+ 0} />