diff --git a/src/lib/components/breadcrumbs.svelte b/src/lib/components/breadcrumbs.svelte index f67cd4acbe..dee3386e5a 100644 --- a/src/lib/components/breadcrumbs.svelte +++ b/src/lib/components/breadcrumbs.svelte @@ -236,6 +236,8 @@ } } + /* for stricter type */ + let selectedOrg: Organization; $: selectedOrg = organizations.find((org) => org.isSelected); $: organizationsBottomSheet = createOrganizationBottomSheet(selectedOrg); diff --git a/src/routes/(console)/account/organizations/+page.svelte b/src/routes/(console)/account/organizations/+page.svelte index f02940caf0..5475fa7d56 100644 --- a/src/routes/(console)/account/organizations/+page.svelte +++ b/src/routes/(console)/account/organizations/+page.svelte @@ -111,7 +111,7 @@ event="organization" offset={data.offset} on:click={createOrg} - disableEmpty={false} + disableEmpty={!resolvedProfile.showCreateOrganization} total={data.organizations.total}> {#each data.organizations.teams as organization} {@const avatarList = getMemberships(organization.$id)} diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte index 3d422d198b..8c9ab43f86 100644 --- a/src/routes/(console)/apply-credit/+page.svelte +++ b/src/routes/(console)/apply-credit/+page.svelte @@ -60,10 +60,14 @@ value: team.$id, label: team.name })) ?? []), - { - value: newOrgId, - label: 'Create new organization' - } + ...(resolvedProfile.showCreateOrganization + ? [ + { + value: newOrgId, + label: 'Create new organization' + } + ] + : []) ]; let name: string; let coupon: string; @@ -391,26 +395,32 @@ - + {#if resolvedProfile.showCreateOrganization} + + {/if} You can apply your credits to an organization at a later date. All other data entered will diff --git a/src/routes/(console)/onboarding/create-organization/+page.ts b/src/routes/(console)/onboarding/create-organization/+page.ts new file mode 100644 index 0000000000..8c307c67c9 --- /dev/null +++ b/src/routes/(console)/onboarding/create-organization/+page.ts @@ -0,0 +1,12 @@ +import { resolve } from '$app/paths'; +import { redirect } from '@sveltejs/kit'; +import type { PageLoad } from './$types'; +import { ProfileMode, resolvedProfile } from '$lib/profiles/index.svelte'; + +export const load: PageLoad = async ({ parent }) => { + const { organizations } = await parent(); + + if (resolvedProfile.id === ProfileMode.STUDIO && organizations.total > 0) { + redirect(303, resolve('/')); + } +}; diff --git a/src/routes/(console)/onboarding/create-project/+page.ts b/src/routes/(console)/onboarding/create-project/+page.ts index 40aad4419a..9328528ea7 100644 --- a/src/routes/(console)/onboarding/create-project/+page.ts +++ b/src/routes/(console)/onboarding/create-project/+page.ts @@ -7,14 +7,18 @@ import { ID, Query, type Models } from '@appwrite.io/console'; import { BillingPlan } from '$lib/constants'; import { redirect } from '@sveltejs/kit'; import { base, resolve } from '$app/paths'; -import { resolvedProfile } from '$lib/profiles/index.svelte'; +import { ProfileMode, resolvedProfile } from '$lib/profiles/index.svelte'; // TODO: this needs to be cleaned up! export const load: PageLoad = async ({ parent }) => { const { account, organizations } = await parent(); - const firstOrganization = organizations?.teams[0]?.$id; + /* short circuit and redirect */ + if (resolvedProfile.id === ProfileMode.STUDIO) { + redirect(303, resolve('/')); + } + const firstOrganization = organizations?.teams[0]?.$id; if (!resolvedProfile.showOnboarding) { if (!organizations?.total) { redirect(303, resolve('/(console)/create-organization'));