mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: budget alerts
This commit is contained in:
@@ -5,7 +5,7 @@ import type { Models } from '@appwrite.io/console';
|
||||
export type Organization = Models.Team<Record<string, unknown>> & {
|
||||
billingBudget: number;
|
||||
billingPlan: string;
|
||||
budgetAlert: number[];
|
||||
budgetAlerts: number[];
|
||||
paymentMethodId: string;
|
||||
backupPaymentMethodId: string;
|
||||
billingCurrentInvoiceDate: string;
|
||||
|
||||
@@ -33,14 +33,14 @@
|
||||
];
|
||||
|
||||
onMount(() => {
|
||||
alerts = $organization?.budgetAlert ?? [];
|
||||
alerts = $organization?.budgetAlerts ?? [];
|
||||
});
|
||||
|
||||
function addAlert() {
|
||||
if (alerts.some((alert) => alert === selectedAlert)) {
|
||||
return;
|
||||
}
|
||||
if (alerts.length < 2) {
|
||||
if (alerts.length <= 2) {
|
||||
alerts = [...alerts, selectedAlert ? selectedAlert : parseInt(search)];
|
||||
search = '';
|
||||
selectedAlert = null;
|
||||
@@ -54,6 +54,7 @@
|
||||
$organization.billingBudget,
|
||||
alerts
|
||||
);
|
||||
|
||||
invalidate(Dependencies.ORGANIZATION);
|
||||
|
||||
addNotification({
|
||||
@@ -72,9 +73,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$: isButtonDisabled = symmetricDifference(alerts, $organization.budgetAlert).length === 0;
|
||||
|
||||
$: console.log($organization.budgetAlert, alerts);
|
||||
$: isButtonDisabled = symmetricDifference(alerts, $organization.budgetAlerts).length === 0;
|
||||
</script>
|
||||
|
||||
<Form onSubmit={updateBudget}>
|
||||
@@ -111,7 +110,7 @@
|
||||
<TableCellHead width={30} />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each alerts as alert}
|
||||
{#each alerts.sort() as alert}
|
||||
<TableRow>
|
||||
<TableCellText title="Percentage">
|
||||
{alert}%
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
await sdk.forConsole.billing.updateBudget(
|
||||
$organization.$id,
|
||||
budget,
|
||||
$organization.budgetAlert
|
||||
$organization.budgetAlerts
|
||||
);
|
||||
invalidate(Dependencies.ORGANIZATION);
|
||||
addNotification({
|
||||
|
||||
Reference in New Issue
Block a user