Skip to content

Commit f4b9f32

Browse files
committed
fix: hide alert when cap updated
1 parent ea73d54 commit f4b9f32

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/lib/stores/billing.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export const plansInfo = derived(page, ($page) => $page.data.plansInfo as PlansM
6565
export const daysLeftInTrial = writable<number>(0);
6666
export const readOnly = writable<boolean>(false);
6767

68+
export const showBudgetAlert = writable<boolean>(false);
69+
6870
export function getRoleLabel(role: string) {
6971
return roles.find((r) => r.value === role)?.label ?? role;
7072
}
@@ -275,9 +277,9 @@ export async function checkForUsageLimit(org: Organization) {
275277
if (!budgetLimit || budgetLimit < 100) {
276278
readOnly.set(false);
277279
return;
278-
279280
}
280281

282+
showBudgetAlert.set(true);
281283
headerAlert.add({
282284
id: 'budgetLimit',
283285
component: BudgetLimitAlert,

src/routes/(console)/organization-[organization]/billing/budgetCap.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { Alert, CardGrid, Heading } from '$lib/components';
55
import { BillingPlan, Dependencies } from '$lib/constants';
66
import { Button, Form, FormList, InputNumber, InputSwitch } from '$lib/elements/forms';
7-
import { showUsageRatesModal, upgradeURL } from '$lib/stores/billing';
7+
import { showBudgetAlert, showUsageRatesModal, upgradeURL } from '$lib/stores/billing';
88
import { addNotification } from '$lib/stores/notifications';
99
import { organization, currentPlan } from '$lib/stores/organization';
1010
import { sdk } from '$lib/stores/sdk';
@@ -27,6 +27,7 @@
2727
$organization.budgetAlerts
2828
);
2929
await invalidate(Dependencies.ORGANIZATION);
30+
showBudgetAlert.set(false);
3031
addNotification({
3132
type: 'success',
3233
isHtml: true,

src/routes/(console)/organization-[organization]/budgetLimitAlert.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import { Button } from '$lib/elements/forms';
55
import { organization } from '$lib/stores/organization';
66
import { HeaderAlert } from '$lib/layout';
7-
import { hideBillingHeaderRoutes, readOnly } from '$lib/stores/billing';
7+
import { hideBillingHeaderRoutes, readOnly, showBudgetAlert } from '$lib/stores/billing';
88
import { base } from '$app/paths';
99
</script>
1010

11-
{#if $organization?.$id && $organization?.billingPlan !== BillingPlan.FREE && $readOnly && !hideBillingHeaderRoutes.includes($page.url.pathname)}
11+
{#if $showBudgetAlert && $organization?.$id && $organization?.billingPlan !== BillingPlan.FREE && $readOnly && !hideBillingHeaderRoutes.includes($page.url.pathname)}
1212
<HeaderAlert type="error" title="Budget limit reached">
1313
<svelte:fragment>
1414
This organization has reached its budget limit and is now blocked. To continue using

0 commit comments

Comments
 (0)