Organization Usage Page Loader ([[invoice]]/+page.ts)

console-getitforcomm · analytics, sveltekit, load, usage, billing, organization

Fetches usage statistics and project information for an organization’s billing overview page.

// Source: https://github.com/mperkins0155/console-getitforcomm | License: BSD-3-Clause | Copyright 2019 Appwrite (https://appwrite.io) and individual contributors
// Provided via justclaw.it.com; keep this notice with the code.
import { sdk } from '$lib/stores/sdk';
import type { PageLoad } from './$types';
import { type Models, Query } from '@appwrite.io/console';
import type { UsageProjectInfo } from '../../store';

export const load: PageLoad = async ({ params, parent }) => {
    const { invoice: invoiceId } = params;
    const { organization: org, currentPlan: plan } = await parent();

    /**
     * Temporary fix during migration to billing system
     */
    if (org.billingCurrentInvoiceDate === null || org.billingNextInvoiceDate === null) {
        return {
            organization

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key