|
1 | 1 | <script lang="ts"> |
2 | 2 | import { afterNavigate, goto, invalidate, preloadData } from '$app/navigation'; |
3 | | - import { base } from '$app/paths'; |
| 3 | + import { base, resolve } from '$app/paths'; |
4 | 4 | import { page } from '$app/state'; |
5 | 5 | import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; |
6 | 6 | import { PlanComparisonBox, PlanSelection, SelectPaymentMethod } from '$lib/components/billing'; |
|
20 | 20 | import { writable } from 'svelte/store'; |
21 | 21 | import EstimatedTotalBox from '$lib/components/billing/estimatedTotalBox.svelte'; |
22 | 22 | import { onMount } from 'svelte'; |
| 23 | + import type { PageProps } from './$types'; |
23 | 24 |
|
24 | | - export let data; |
| 25 | + const { data }: PageProps = $props(); |
25 | 26 |
|
26 | | - let selectedPlan: BillingPlan = data.plan as BillingPlan; |
27 | | - let selectedCoupon: Partial<Coupon> | null = data.coupon; |
28 | | - let previousPage: string = base; |
29 | | - let showExitModal = false; |
| 27 | + let showExitModal = $state(false); |
| 28 | + let previousPage: string = $state(resolve('/(console)')); |
| 29 | + let selectedPlan: BillingPlan = $state(data.plan as BillingPlan); |
| 30 | + let selectedCoupon: Partial<Coupon> | null = $state(data.coupon); |
30 | 31 |
|
31 | | - let formComponent: Form; |
32 | | - let isSubmitting = writable(false); |
| 32 | + let isSubmitting = $state(writable(false)); |
| 33 | + let formComponent: Form | null = $state(null); |
33 | 34 |
|
34 | | - let name: string; |
35 | | - let billingPlan: BillingPlan = BillingPlan.FREE; |
36 | | - let paymentMethodId: string; |
37 | | - let collaborators: string[] = []; |
38 | | - let taxId: string; |
| 35 | + let name: string | null = $state(null); |
| 36 | + let taxId: string | null = $state(null); |
| 37 | + let collaborators: string[] = $state([]); |
| 38 | + let paymentMethodId: string | null = $state(null); |
| 39 | + let billingPlan: BillingPlan = $state(BillingPlan.FREE); |
39 | 40 |
|
40 | | - let billingBudget: number; |
41 | | - let showCreditModal = false; |
| 41 | + let showCreditModal = $state(false); |
| 42 | + let billingBudget: number | undefined = $state(undefined); |
42 | 43 |
|
43 | 44 | afterNavigate(({ from }) => { |
44 | 45 | previousPage = from?.url?.pathname || previousPage; |
|
48 | 49 | if (page.url.searchParams.has('coupon')) { |
49 | 50 | const coupon = page.url.searchParams.get('coupon'); |
50 | 51 | try { |
51 | | - const response = await sdk.forConsole.billing.getCouponAccount(coupon); |
52 | | - selectedCoupon = response; |
| 52 | + selectedCoupon = await sdk.forConsole.billing.getCouponAccount(coupon); |
53 | 53 | } catch (e) { |
54 | 54 | selectedCoupon = { |
55 | 55 | code: null, |
|
200 | 200 | >. |
201 | 201 | </Typography.Text> |
202 | 202 |
|
203 | | - <PlanSelection bind:billingPlan={selectedPlan} isNewOrg /> |
| 203 | + <PlanSelection |
| 204 | + isNewOrg |
| 205 | + bind:billingPlan={selectedPlan} |
| 206 | + anyOrgFree={data.hasFreeOrganizations} /> |
204 | 207 | </Layout.Stack> |
205 | 208 | </Fieldset> |
206 | 209 | {#if selectedPlan !== BillingPlan.FREE} |
|
0 commit comments