Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: api usage. #1734

Merged
merged 3 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/lib/commandCenter/searchers/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import { goto } from '$app/navigation';
import { base } from '$app/paths';
import { sdk } from '$lib/stores/sdk';
import type { Searcher } from '../commands';
import { isCloud } from '$lib/system';

export const orgSearcher = (async (query: string) => {
const { teams } = await sdk.forConsole.teams.list();
const { teams } = !isCloud
? await sdk.forConsole.teams.list()
: await sdk.forConsole.billing.listOrganization();

return teams
.filter((organization) => organization.name.toLowerCase().includes(query.toLowerCase()))
.map((organization) => {
Expand Down
4 changes: 3 additions & 1 deletion src/routes/(console)/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export const load: LayoutLoad = async ({ params, fetch, depends, parent }) => {
}, new Map<Tier, Plan>());
}

const organizations = await sdk.forConsole.teams.list();
const organizations = !isCloud
? await sdk.forConsole.teams.list()
: await sdk.forConsole.billing.listOrganization();

let projects = [];
let currentOrgId = params.organization ? params.organization : prefs.organization;
Expand Down
13 changes: 8 additions & 5 deletions src/routes/(console)/account/organizations/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { CARD_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
import { isCloud } from '$lib/system';

export const load: PageLoad = async ({ url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, CARD_LIMIT);
const offset = pageToOffset(page, limit);

const queries = [Query.offset(offset), Query.limit(limit), Query.orderDesc('')];

const organizations = !isCloud
? await sdk.forConsole.teams.list(queries)
: await sdk.forConsole.billing.listOrganization(queries);

return {
offset,
limit,
organizations: await sdk.forConsole.teams.list([
Query.offset(offset),
Query.limit(limit),
Query.orderDesc('')
])
organizations
};
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { Dependencies } from '$lib/constants';
import type { OrganizationList } from '$lib/stores/organization.js';
import { sdk } from '$lib/stores/sdk';
import { isCloud } from '$lib/system';

export const load = async ({ parent, depends }) => {
depends(Dependencies.DOMAINS);

const organizations = !isCloud
? await sdk.forConsole.teams.list()
: await sdk.forConsole.billing.listOrganization();

const { domain } = await parent();
return {
domain,
organizations: (await sdk.forConsole.teams.list()) as OrganizationList
organizations
};
};
8 changes: 6 additions & 2 deletions src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ export const load: LayoutLoad = async ({ depends, url, route }) => {
}

if (account) {
const organizations = !isCloud
? await sdk.forConsole.teams.list()
: await sdk.forConsole.billing.listOrganization();

return {
account: account,
organizations: await sdk.forConsole.teams.list()
account,
organizations
};
}

Expand Down
Loading