From 54e2a1acfb62faeb055b4b3c75be28a9667dd3e7 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 5 Dec 2023 14:52:53 +0100 Subject: [PATCH] fix: wizards refactor, credits --- src/lib/layout/wizard.svelte | 1 + src/lib/stores/wizard.ts | 2 ++ .../billing/wizard/addCredit.svelte | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/layout/wizard.svelte b/src/lib/layout/wizard.svelte index 7f299cfa5..56bc565d6 100644 --- a/src/lib/layout/wizard.svelte +++ b/src/lib/layout/wizard.svelte @@ -65,6 +65,7 @@ try { await $wizard.interceptor(); } catch (error) { + if (!$wizard.interceptorNotificationEnabled) return; addNotification({ message: error.message, type: 'error' diff --git a/src/lib/stores/wizard.ts b/src/lib/stores/wizard.ts index b0e1c2a02..c14d4c88a 100644 --- a/src/lib/stores/wizard.ts +++ b/src/lib/stores/wizard.ts @@ -11,6 +11,7 @@ export type WizardStore = { interceptor?: () => Promise; 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 diff --git a/src/routes/console/organization-[organization]/billing/wizard/addCredit.svelte b/src/routes/console/organization-[organization]/billing/wizard/addCredit.svelte index 1900492cb..26a6f820a 100644 --- a/src/routes/console/organization-[organization]/billing/wizard/addCredit.svelte +++ b/src/routes/console/organization-[organization]/billing/wizard/addCredit.svelte @@ -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); } } @@ -35,6 +38,7 @@ { console.log(e.detail); $addCreditWizardStore.coupon = e.detail.code;