fix: org/team api usage.

This commit is contained in:
Darshan
2025-03-16 17:26:58 +05:30
parent 017245f748
commit a6901fc5a2
2 changed files with 13 additions and 6 deletions
@@ -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) => {
@@ -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('console', 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
};
};