Skip to content

Commit

Permalink
Merge pull request #1733 from appwrite/revert-1721-revert-1675-feat-b…
Browse files Browse the repository at this point in the history
…udget-nullable

Revert "Revert "Console Feat: make budget cap nullable""
  • Loading branch information
lohanidamodar authored Mar 11, 2025
2 parents 27fded5 + f3507c8 commit 568aba8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/routes/(console)/create-organization/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
trackEvent(Submit.OrganizationCreate, {
plan: tierToPlan(billingPlan)?.name,
budget_cap_enabled: !!billingBudget,
budget_cap_enabled: billingBudget !== null,
members_invited: collaborators?.length
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import { Container } from '$lib/layout';
import { organization } from '$lib/stores/organization';
import BudgetAlert from './budgetAlert.svelte';
import BudgetCap from './budgetCap.svelte';
import PlanSummary from './planSummary.svelte';
import BillingAddress from './billingAddress.svelte';
Expand Down Expand Up @@ -128,7 +127,6 @@
<BillingAddress billingAddress={data?.billingAddress} />
<TaxId />
<BudgetCap />
<BudgetAlert />
<AvailableCredit />
</Container>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
export let alertsEnabled = false;
let search: string;
let selectedAlert: number;
let alerts: number[] = [];
Expand Down Expand Up @@ -74,7 +76,8 @@
}
}
$: isButtonDisabled = symmetricDifference(alerts, $organization.budgetAlerts).length === 0;
$: isButtonDisabled =
symmetricDifference(alerts, $organization.budgetAlerts).length === 0 || !alertsEnabled;
</script>

<Form onSubmit={updateBudget}>
Expand Down Expand Up @@ -107,6 +110,7 @@

<div class="u-flex u-gap-16">
<InputSelectSearch
disabled={!alertsEnabled}
label="Percentage (%) of budget cap"
placeholder="Select a percentage"
id="alerts"
Expand All @@ -118,7 +122,9 @@
<div style="align-self: flex-end">
<Button
secondary
disabled={alerts.length > 3 || (!search && !selectedAlert)}
disabled={alerts.length > 3 ||
(!search && !selectedAlert) ||
!alertsEnabled}
on:click={addAlert}>
Add alert
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
import { organization, currentPlan } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import BudgetAlert from './budgetAlert.svelte';
let capActive = false;
let budget: number;
onMount(() => {
budget = $organization?.billingBudget;
capActive = !!$organization?.billingBudget;
capActive = $organization?.billingBudget !== null;
});
async function updateBudget() {
Expand Down Expand Up @@ -44,7 +45,7 @@
}
$: if (!capActive) {
budget = 0;
budget = null;
}
</script>

Expand Down Expand Up @@ -113,3 +114,5 @@
</svelte:fragment>
</CardGrid>
</Form>

<BudgetAlert alertsEnabled={capActive && budget > 0} />

0 comments on commit 568aba8

Please sign in to comment.