mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: add credit wizard
This commit is contained in:
1 parent
ead4c42a95
commit
bd265cc3a6
3 files changed
+15
-5
No files matched your search
@@ -68,7 +68,7 @@
|
||||
</span>
|
||||
</slot>
|
||||
</div>
|
||||
<Button text on:click={removeCoupon}>Remove</Button>
|
||||
<Button round text on:click={removeCoupon}><span class="icon-x"></span></Button>
|
||||
</div>
|
||||
{/if}
|
||||
</FormList>
|
||||
@@ -71,9 +71,10 @@
|
||||
<p class="text">Appwrite credit will automatically be applied to your next invoice.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<div class="u-flex u-cross-center u-main-space-between">
|
||||
<h4 class="body-text-1 u-bold">
|
||||
Credit balance <span class="inline-tag">${balance}</span>
|
||||
</h4>
|
||||
<div class="u-flex u-gap-8 u-cross-center">
|
||||
<h4 class="body-text-1 u-bold">Credit balance</h4>
|
||||
<span class="inline-tag">${balance}</span>
|
||||
</div>
|
||||
{#if creditList?.total}
|
||||
<Button secondary on:click={handleCredits}>
|
||||
<span class="icon-plus" aria-hidden="true"></span>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { onMount } from 'svelte';
|
||||
import { addCreditWizardStore } from '../store';
|
||||
|
||||
let coupon: string;
|
||||
@@ -18,6 +19,7 @@
|
||||
try {
|
||||
const response = await sdk.forConsole.billing.getCoupon(coupon);
|
||||
couponData = response;
|
||||
$addCreditWizardStore.coupon = coupon;
|
||||
coupon = null;
|
||||
} catch (error) {
|
||||
couponData.code = coupon;
|
||||
@@ -26,6 +28,13 @@
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if ($addCreditWizardStore.coupon) {
|
||||
coupon = $addCreditWizardStore.coupon;
|
||||
validateCoupon();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<WizardStep beforeSubmit={validateCoupon}>
|
||||
@@ -41,6 +50,6 @@
|
||||
$addCreditWizardStore.coupon = e.detail.code;
|
||||
}}
|
||||
let:data>
|
||||
<span>{data.code} has been successfully added</span>
|
||||
<span>{data.code.toUpperCase()} has been successfully added</span>
|
||||
</CouponInput>
|
||||
</WizardStep>
|
||||
Reference in new issue
Block a user