Skip to content

Commit

Permalink
Merge pull request #1514 from appwrite/feat-plan-summary-to-server-load
Browse files Browse the repository at this point in the history
Load all data for plan summary in advance
  • Loading branch information
TorstenDittmann authored Nov 13, 2024
2 parents 77f693d + 476df58 commit c197f15
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@
<div class="common-section">
<Heading tag="h2" size="5">Billing</Heading>
</div>
<PlanSummary />
<PlanSummary
creditList={data?.creditList}
members={data?.members}
currentPlan={data?.currentPlan}
invoices={data?.invoices.invoices} />
<PaymentHistory />
<PaymentMethods />
<BillingAddress billingAddress={data?.billingAddress} />
Expand Down
24 changes: 21 additions & 3 deletions src/routes/(console)/organization-[organization]/billing/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { Query } from '@appwrite.io/console';

export const load: PageLoad = async ({ parent, depends }) => {
const { organization, scopes } = await parent();
Expand All @@ -24,17 +25,34 @@ export const load: PageLoad = async ({ parent, depends }) => {
.catch(() => null)
: null;

const [paymentMethods, addressList, aggregationList, billingAddress] = await Promise.all([
const [
paymentMethods,
addressList,
aggregationList,
billingAddress,
currentPlan,
creditList,
invoices
] = await Promise.all([
sdk.forConsole.billing.listPaymentMethods(),
sdk.forConsole.billing.listAddresses(),
sdk.forConsole.billing.listAggregation(organization.$id),
billingAddressPromise
billingAddressPromise,
sdk.forConsole.billing.getPlan(organization.$id),
sdk.forConsole.billing.listCredits(organization.$id),
sdk.forConsole.billing.listInvoices(organization.$id, [
Query.limit(1),
Query.equal('from', organization.billingCurrentInvoiceDate)
])
]);

return {
paymentMethods,
addressList,
aggregationList,
billingAddress
billingAddress,
currentPlan,
creditList,
invoices
};
};
Loading

0 comments on commit c197f15

Please sign in to comment.