fix: wizards refactor, credits

This commit is contained in:
Arman committed 2023-12-05 14:52:53 +01:00
1 parent 36fcecab18
commit 54e2a1acfb
3 files changed
+8 -1

No files matched your search

+1
View File
@@ -65,6 +65,7 @@
try {
await $wizard.interceptor();
} catch (error) {
if (!$wizard.interceptorNotificationEnabled) return;
addNotification({
message: error.message,
type: 'error'
+2
View File
@@ -11,6 +11,7 @@ export type WizardStore = {
interceptor?: () => Promise<void>;
nextDisabled: boolean;
step: number;
interceptorNotificationEnabled: boolean;
};
function createWizardStore() {
@@ -19,6 +20,7 @@ function createWizardStore() {
component: null,
cover: null,
interceptor: null,
interceptorNotificationEnabled: true,
media: null,
nextDisabled: false,
step: 1
@@ -3,6 +3,7 @@
import { WizardStep } from '$lib/layout';
import type { Coupon } from '$lib/sdk/billing';
import { sdk } from '$lib/stores/sdk';
import { wizard } from '$lib/stores/wizard';
import { addCreditWizardStore } from '../store';
let coupon: string;
@@ -14,6 +15,7 @@
async function validateCoupon() {
if (couponData?.status === 'active') return;
console.log(couponData);
try {
const response = await sdk.forConsole.billing.getCoupon(coupon);
couponData = response;
@@ -22,7 +24,8 @@
console.log('test');
couponData.code = coupon;
couponData.status = 'error';
throw new Error(`${coupon} is not a valid promo code`);
$wizard.interceptorNotificationEnabled = false;
throw new Error(error);
}
}
</script>
@@ -35,6 +38,7 @@
</svelte:fragment>
<CouponInput
bind:coupon
bind:couponData
on:validation={(e) => {
console.log(e.detail);
$addCreditWizardStore.coupon = e.detail.code;