diff --git a/src/lib/components/billing/validateCreditModal.svelte b/src/lib/components/billing/validateCreditModal.svelte index 130532a7b..b2c3f6190 100644 --- a/src/lib/components/billing/validateCreditModal.svelte +++ b/src/lib/components/billing/validateCreditModal.svelte @@ -38,14 +38,6 @@ message: 'Credits applied successfully' }); } - couponData = response; - dispatch('validation', couponData); - coupon = null; - show = false; - addNotification({ - type: 'success', - message: 'Credits applied successfully' - }); } catch (e) { error = e.message; } diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte index 0c743dcad..dbb3add04 100644 --- a/src/routes/(console)/apply-credit/+page.svelte +++ b/src/routes/(console)/apply-credit/+page.svelte @@ -8,7 +8,7 @@ import { Button, Form, InputSelect, InputTags, InputText } from '$lib/elements/forms'; import { toLocaleDate } from '$lib/helpers/date'; import { Wizard } from '$lib/layout'; - import { type PaymentList, type Plan } from '$lib/sdk/billing'; + import type { PaymentList, Plan } from '$lib/sdk/billing'; import { addNotification } from '$lib/stores/notifications'; import { organizationList, @@ -72,7 +72,7 @@ let tempOrgId = null; let currentPlan: Plan; - $: onlyNewOrgs = (campaign && campaign.onlyNewOrgs) || (couponData && couponData.onlyNewOrgs); + $: onlyNewOrgs = campaign?.onlyNewOrgs || couponData?.onlyNewOrgs; $: selectedOrgId = tempOrgId; @@ -174,7 +174,7 @@ '', clientSecret, paymentMethodId, - '/console/apply-credit?' + params.toString() + `/console/apply-credit?${params}` ); org = await sdk.forConsole.billing.validateOrganization(org.teamId, collaborators); } @@ -205,7 +205,7 @@ async function addCoupon() { try { - const response = await sdk.forConsole.billing.getCoupon(coupon); + const response = await sdk.forConsole.billing.getCouponAccount(coupon); couponData = response; coupon = null; addNotification({ diff --git a/src/routes/(console)/create-organization/+page.svelte b/src/routes/(console)/create-organization/+page.svelte index 77049390e..d6aa47b66 100644 --- a/src/routes/(console)/create-organization/+page.svelte +++ b/src/routes/(console)/create-organization/+page.svelte @@ -11,7 +11,7 @@ import type { Coupon } from '$lib/sdk/billing'; import { isOrganization, tierToPlan } from '$lib/stores/billing'; import { addNotification } from '$lib/stores/notifications'; - import { type OrganizationError, type Organization } from '$lib/stores/organization'; + import type { OrganizationError, Organization } from '$lib/stores/organization'; import { sdk } from '$lib/stores/sdk'; import { confirmPayment } from '$lib/stores/stripe'; import { ID } from '@appwrite.io/console'; @@ -35,11 +35,6 @@ let billingPlan: BillingPlan = BillingPlan.FREE; let paymentMethodId: string; let collaborators: string[] = []; - let couponData: Partial = { - code: null, - status: null, - credits: null - }; let taxId: string; let billingBudget: number; @@ -54,9 +49,9 @@ const coupon = page.url.searchParams.get('coupon'); try { const response = await sdk.forConsole.billing.getCouponAccount(coupon); - couponData = response; + selectedCoupon = response; } catch (e) { - couponData = { + selectedCoupon = { code: null, status: null, credits: null @@ -127,7 +122,7 @@ selectedPlan, paymentMethodId, null, - couponData.code ? couponData.code : null, + selectedCoupon.code ? selectedCoupon.code : null, collaborators, billingBudget, taxId @@ -148,7 +143,7 @@ '', clientSecret, paymentMethodId, - '/console/create-organization?' + params.toString() + `/console/create-organization?${params}` ); await validate(org.teamId, collaborators); } diff --git a/src/routes/(console)/create-organization/+page.ts b/src/routes/(console)/create-organization/+page.ts index c3eff35d6..150cd76f3 100644 --- a/src/routes/(console)/create-organization/+page.ts +++ b/src/routes/(console)/create-organization/+page.ts @@ -42,7 +42,7 @@ async function getCoupon(url: URL): Promise { if (url.searchParams.has('code')) { const coupon = url.searchParams.get('code'); try { - return sdk.forConsole.billing.getCoupon(coupon); + return sdk.forConsole.billing.getCouponAccount(coupon); } catch (e) { return null; } diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte index ae83f8c26..84b4d093f 100644 --- a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte @@ -54,7 +54,6 @@ let showCreditModal = false; let feedbackDowngradeReason: string; let feedbackMessage: string; - let couponData: Partial = data.coupon; afterNavigate(({ from }) => { previousPage = from?.url?.pathname || previousPage; @@ -63,9 +62,9 @@ if (page.url.searchParams.has('code')) { const coupon = page.url.searchParams.get('code'); try { - couponData = await sdk.forConsole.billing.getCouponAccount(coupon); + selectedCoupon = await sdk.forConsole.billing.getCouponAccount(coupon); } catch (e) { - couponData = { + selectedCoupon = { code: null, status: null, credits: null @@ -191,7 +190,7 @@ selectedPlan, paymentMethodId, null, - couponData?.code, + selectedCoupon?.code, newCollaborators, billingBudget, taxId ? taxId : null diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.ts b/src/routes/(console)/organization-[organization]/change-plan/+page.ts index e3d79c69e..b698d60dc 100644 --- a/src/routes/(console)/organization-[organization]/change-plan/+page.ts +++ b/src/routes/(console)/organization-[organization]/change-plan/+page.ts @@ -49,7 +49,7 @@ async function getCoupon(url: URL): Promise { if (url.searchParams.has('code')) { const coupon = url.searchParams.get('code'); try { - return sdk.forConsole.billing.getCoupon(coupon); + return sdk.forConsole.billing.getCouponAccount(coupon); } catch (e) { return null; }