|
1 | 1 | <script lang="ts">
|
2 | 2 | import { Container } from '$lib/layout';
|
3 |
| - import { organization } from '$lib/stores/organization'; |
4 | 3 | import BudgetCap from './budgetCap.svelte';
|
5 | 4 | import PlanSummary from './planSummary.svelte';
|
6 | 5 | import BillingAddress from './billingAddress.svelte';
|
|
25 | 24 | import type { PageData } from './$types';
|
26 | 25 |
|
27 | 26 | export let data: PageData;
|
| 27 | + let organization = data.organization; |
28 | 28 |
|
29 | 29 | // why are these reactive?
|
30 | 30 | $: defaultPaymentMethod = data?.paymentMethods?.paymentMethods?.find(
|
31 |
| - (method: PaymentMethodData) => method.$id === $organization?.paymentMethodId |
| 31 | + (method: PaymentMethodData) => method.$id === organization?.paymentMethodId |
32 | 32 | );
|
33 | 33 |
|
34 | 34 | $: backupPaymentMethod = data?.paymentMethods?.paymentMethods?.find(
|
35 |
| - (method: PaymentMethodData) => method.$id === $organization?.backupPaymentMethodId |
| 35 | + (method: PaymentMethodData) => method.$id === organization?.backupPaymentMethodId |
36 | 36 | );
|
37 | 37 |
|
38 | 38 | onMount(async () => {
|
|
52 | 52 | );
|
53 | 53 |
|
54 | 54 | await confirmPayment(
|
55 |
| - $organization.$id, |
| 55 | + organization.$id, |
56 | 56 | invoice.clientSecret,
|
57 |
| - $organization.paymentMethodId, |
58 |
| - `${base}/organization-${$organization.$id}/billing?type=validate-invoice&invoice=${invoice.$id}` |
| 57 | + organization.paymentMethodId, |
| 58 | + `${base}/organization-${organization.$id}/billing?type=validate-invoice&invoice=${invoice.$id}` |
59 | 59 | );
|
60 | 60 | }
|
61 | 61 |
|
|
64 | 64 | page.url.searchParams.get('type') === 'validate-invoice'
|
65 | 65 | ) {
|
66 | 66 | const invoiceId = page.url.searchParams.get('invoice');
|
67 |
| - await sdk.forConsole.billing.updateInvoiceStatus($organization.$id, invoiceId); |
| 67 | + await sdk.forConsole.billing.updateInvoiceStatus(organization.$id, invoiceId); |
68 | 68 | invalidate(Dependencies.INVOICES);
|
69 | 69 | invalidate(Dependencies.ORGANIZATION);
|
70 | 70 | }
|
|
84 | 84 | }
|
85 | 85 | if (page.url.searchParams.has('clientSecret')) {
|
86 | 86 | const clientSecret = page.url.searchParams.get('clientSecret');
|
87 |
| - await confirmPayment($organization.$id, clientSecret, $organization.paymentMethodId); |
| 87 | + await confirmPayment(organization.$id, clientSecret, organization.paymentMethodId); |
88 | 88 | }
|
89 | 89 | });
|
90 | 90 | </script>
|
|
93 | 93 | {#if $failedInvoice}
|
94 | 94 | {#if $failedInvoice?.lastError}
|
95 | 95 | <Alert.Inline status="error">
|
96 |
| - The scheduled payment for {$organization.name} failed due to following error: {$failedInvoice.lastError} |
| 96 | + The scheduled payment for {organization.name} failed due to following error: {$failedInvoice.lastError} |
97 | 97 | <svelte:fragment slot="actions">
|
98 | 98 | <Button
|
99 | 99 | text
|
|
106 | 106 | {:else}
|
107 | 107 | <Alert.Inline
|
108 | 108 | status="error"
|
109 |
| - title={`The scheduled payment for ${$organization.name} failed`}> |
| 109 | + title={`The scheduled payment for ${organization.name} failed`}> |
110 | 110 | To avoid service disruptions in organization's your projects, please verify your
|
111 | 111 | payment details and update them if necessary.
|
112 | 112 | </Alert.Inline>
|
|
115 | 115 | {#if defaultPaymentMethod?.failed && !backupPaymentMethod}
|
116 | 116 | <Alert.Inline
|
117 | 117 | status="error"
|
118 |
| - title={`The default payment method for ${$organization.name} has expired`}> |
| 118 | + title={`The default payment method for ${organization.name} has expired`}> |
119 | 119 | To avoid service disruptions in your organization's projects, please update your payment
|
120 | 120 | details.
|
121 | 121 | </Alert.Inline>
|
122 | 122 | {/if}
|
123 |
| - {#if $organization?.billingPlanDowngrade} |
| 123 | + {#if organization?.billingPlanDowngrade} |
124 | 124 | <Alert.Inline status="info">
|
125 |
| - Your organization has changed to {tierToPlan($organization?.billingPlanDowngrade).name} plan. |
126 |
| - You will continue to have access to {tierToPlan($organization?.billingPlan).name} plan features |
127 |
| - until your billing period ends on {toLocaleDate($organization.billingNextInvoiceDate)}. |
| 125 | + Your organization has changed to {tierToPlan(organization?.billingPlanDowngrade).name} plan. |
| 126 | + You will continue to have access to {tierToPlan(organization?.billingPlan).name} plan features |
| 127 | + until your billing period ends on {toLocaleDate(organization.billingNextInvoiceDate)}. |
128 | 128 | </Alert.Inline>
|
129 | 129 | {/if}
|
130 | 130 | <Typography.Title>Billing</Typography.Title>
|
|
137 | 137 | <PaymentMethods methods={data?.paymentMethods} />
|
138 | 138 | <BillingAddress {data} />
|
139 | 139 | <TaxId />
|
140 |
| - <BudgetCap /> |
| 140 | + <BudgetCap organization={data?.organization} currentPlan={data?.currentPlan} /> |
141 | 141 | <AvailableCredit areCreditsSupported={data.areCreditsSupported} />
|
142 | 142 | </Container>
|
143 | 143 |
|
|
0 commit comments