feat: clean unused folder, fix feedback, budget cap

This commit is contained in:
Arman
2023-07-25 15:32:21 +02:00
parent ed51179ceb
commit 83fd3459f8
13 changed files with 34 additions and 58 deletions
+2 -2
View File
@@ -3,8 +3,8 @@
import { onDestroy } from 'svelte';
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
import { feedbackData } from '$lib/stores/feedback';
import Step1 from './wizardFeedback/step1.svelte';
import Step2 from './wizardFeedback/step2.svelte';
import Step1 from './wizard/feedback/step1.svelte';
import Step2 from './wizard/feedback/step2.svelte';
onDestroy(() => {
feedbackData.reset();
@@ -109,6 +109,11 @@
+{project.platforms.length - 3}
</Pill>
{/if}
<svelte:fragment slot="icon">
{#if isCloud}
<p>region</p>
{/if}
</svelte:fragment>
</GridItem1>
{/each}
<svelte:fragment slot="empty">
@@ -16,7 +16,7 @@
<PaymentMethods />
<BillingAddress />
<BudgetCap />
{#if $organization?.billingPlan === 'tier-2'}
{#if $organization?.billingPlan !== 'tier-0' && !!$organization?.billingBudget}
<BudgetAlert />
{/if}
<AvailableCredit />
@@ -7,7 +7,7 @@
</script>
<CardGrid>
<Heading tag="h2" size="6">Billing Address</Heading>
<Heading tag="h2" size="6">Billing address</Heading>
<p class="text">
View or update your billing address. This address will appear on your invoice.
@@ -63,7 +63,7 @@
<Form onSubmit={updateBudget}>
<CardGrid>
<Heading tag="h2" size="6">Budget Alert Condition</Heading>
<Heading tag="h2" size="6">Budget alert aondition</Heading>
<p class="text">
Get notified by email when your organization meets or exceeds a percent of your
@@ -1,26 +1,39 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { Alert, CardGrid, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, Form, FormList, InputNumber, InputSwitch } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import UsageRates from '$routes/console/wizard/cloudOrganization/usageRates.svelte';
import { onMount } from 'svelte';
let capActive = false;
let budget: number;
let showRates = false;
onMount(() => {
budget = $organization?.billingBudget;
capActive = !!$organization?.billingBudget;
});
async function updateBudget() {
try {
await sdk.forConsole.billing.updateBudget($organization.$id, budget, []);
trackEvent(Submit.BudgetCapUpdate, {
budget: capActive ? budget : undefined
});
await sdk.forConsole.billing.updateBudget(
$organization.$id,
budget,
$organization.budgetAlert
);
invalidate(Dependencies.ORGANIZATION);
addNotification({
type: 'success',
message: `Budget cap enabled for ${$organization.name}`
});
trackEvent(Submit.BudgetCapUpdate, {
budget: capActive ? budget : undefined
});
} catch (error) {
addNotification({
type: 'error',
@@ -29,6 +42,10 @@
trackError(error, Submit.BudgetCapUpdate);
}
}
$: if (!capActive) {
budget = 0;
}
</script>
<Form onSubmit={updateBudget}>
@@ -43,7 +60,7 @@
class="link">Learn more about usage rates.</a>
</p>
<svelte:fragment slot="aside">
{#if $organization?.billingPlan !== 'tier-2'}
{#if $organization?.billingPlan === 'tier-0'}
<Alert type="info">
<svelte:fragment slot="title">
Budget caps are a Pro plan feature
@@ -60,7 +77,7 @@
<InputNumber
placeholder="Add budget cap"
id="cap"
label="Budget cap"
label="Budget cap ($USD)"
bind:value={budget} />
{/if}
</FormList>
@@ -68,7 +85,7 @@
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={$organization?.billingPlan !== 'tier-2'} submit>Update</Button>
<Button disabled={$organization?.billingBudget === budget} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -1,10 +0,0 @@
<script lang="ts">
import { Heading } from '$lib/components';
import { Container } from '$lib/layout';
import BudgetCap from './budgetCap.svelte';
</script>
<Container>
<Heading tag="h2" size="5">Billing</Heading>
<BudgetCap />
</Container>
@@ -1,31 +0,0 @@
<script>
import { CardGrid, Heading } from '$lib/components';
import { Button, Form, FormList, InputNumber, InputSwitch } from '$lib/elements/forms';
function update() {
console.log('test');
}
</script>
<Form onSubmit={update}>
<CardGrid>
<Heading tag="h2" size="6">Budget Cap</Heading>
<p class="text">
Restrict your resource usage by setting a budget cap. <a
class="link"
href="http://#"
target="_blank"
rel="noopener noreferrer">Learn more about usage rates</a
>.
</p>
<svelte:fragment slot="aside">
<FormList>
<InputSwitch label="Budget cap" />
<InputNumber label="Budget cap ($USD)" placeholder="Enter budget cap" />
</FormList>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -27,11 +27,6 @@
title: 'Usage',
event: 'usage',
hasChildren: true
},
{
href: `${path}/billing`,
title: 'Billing',
event: 'billing'
}
];
</script>