fix: onboarding

This commit is contained in:
Arman
2025-05-16 10:23:47 +02:00
parent ca40f54e4e
commit b53b943ac6
@@ -3,7 +3,7 @@ import { isCloud } from '$lib/system';
import { sdk } from '$lib/stores/sdk';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { isOrganization, tierToPlan } from '$lib/stores/billing';
import { ID } from '@appwrite.io/console';
import { ID, Query } from '@appwrite.io/console';
import { BillingPlan } from '$lib/constants';
import { redirect } from '@sveltejs/kit';
import { base } from '$app/paths';
@@ -49,6 +49,20 @@ export const load: PageLoad = async ({ parent }) => {
} catch (e) {
trackError(e, Submit.OrganizationCreate);
}
} else if (organizations?.total === 1) {
const org = organizations.teams[0];
const projects = await sdk.forConsole.projects.list([
Query.equal('teamId', org.$id),
Query.limit(1)
]);
if (!projects.total) {
return {
organization: org,
regions: await sdk.forConsole.billing.listRegions(org.$id)
};
} else {
redirect(303, `${base}/console/organization-${org.$id}`);
}
} else {
redirect(303, `${base}/console/organization-${organizations.teams[0].$id}`);
}