diff --git a/src/routes/(public)/template-[template]/+page.svelte b/src/routes/(public)/template-[template]/+page.svelte index 2262fe075..5ec88102b 100644 --- a/src/routes/(public)/template-[template]/+page.svelte +++ b/src/routes/(public)/template-[template]/+page.svelte @@ -5,19 +5,13 @@ import { SvgIcon } from '$lib/components/index.js'; import { Button, Form, InputSelect } from '$lib/elements/forms'; import { getFlagUrl } from '$lib/helpers/flag.js'; - import type { Region } from '$lib/sdk/billing.js'; + import type { AllowedRegions, Region as RegionType } from '$lib/sdk/billing.js'; import { app } from '$lib/stores/app'; import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; import { getFrameworkIcon } from '$lib/stores/sites.js'; import { isCloud } from '$lib/system'; - import { - ID, - OAuthProvider, - Query, - type Models, - type Region as AppwriteRegion - } from '@appwrite.io/console'; + import { ID, OAuthProvider, Query, type Models, Region } from '@appwrite.io/console'; import { IconGithub, IconPencil, IconPlus } from '@appwrite.io/pink-icons-svelte'; import { Card, @@ -39,8 +33,8 @@ ); let projectName = $state(); let showCustomId = $state(false); - let region = $state(); - let regions = $state>([]); + let region = $state(); + let regions = $state>([]); let id = $state(); function getRegions() { @@ -101,7 +95,7 @@ id ?? ID.unique(), projectName, selectedOrg, - region as AppwriteRegion + isCloud ? (region as Region) : Region.Default ); trackEvent(Submit.ProjectCreate, { customId: !!id, @@ -124,7 +118,6 @@ $effect(() => { if (selectedOrg !== undefined) { - console.log('test'); fetchProjects(); } }); @@ -240,7 +233,7 @@ isProject bind:id /> - {#if isCloud && regions.length > 0} + {#if isCloud} { - if (!isCloud) redirect(303, '/'); - const { account } = await parent(); if (!url.searchParams.has('type')) { @@ -27,10 +26,13 @@ export const load = async ({ parent, url, params }) => { default: error(404, 'Type is not valid'); } - const organizations = account?.$id - ? await sdk.forConsole.billing.listOrganization() - : undefined; - // const organizations = account?.$id ? await sdk.forConsole.teams.list() : undefined; + + let organizations: Models.TeamList> | OrganizationList | undefined; + if (isCloud) { + organizations = account?.$id ? await sdk.forConsole.billing.listOrganization() : undefined; + } else { + organizations = account?.$id ? await sdk.forConsole.teams.list() : undefined; + } if (!organizations?.total && account?.$id) { await sdk.forConsole.billing.createOrganization(