Merge pull request #2774 from appwrite/fix-create-org

This commit is contained in:
Darshan
2026-01-08 16:14:40 +05:30
committed by GitHub
5 changed files with 55 additions and 27 deletions
+2
View File
@@ -236,6 +236,8 @@
}
}
/* for stricter type */
let selectedOrg: Organization;
$: selectedOrg = organizations.find((org) => org.isSelected);
$: organizationsBottomSheet = createOrganizationBottomSheet(selectedOrg);
@@ -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)}
+34 -24
View File
@@ -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 @@
</svelte:fragment>
<svelte:fragment slot="footer">
<Button fullWidthMobile secondary on:click={() => (showExitModal = true)}>Cancel</Button>
<Button
fullWidthMobile
on:click={() => {
if (formComponent.checkValidity() && (!couponForm || couponForm.checkValidity())) {
handleSubmit();
}
}}
disabled={!couponData?.code || $isSubmitting}>
{#if $isSubmitting}
<span class="loader is-small is-transparent u-line-height-1-5" aria-hidden="true"
></span>
{/if}
{#if selectedOrgId === newOrgId}
Create organization
{:else if isUpgrade()}
Upgrade
{:else}
Apply
{/if}
</Button>
{#if resolvedProfile.showCreateOrganization}
<Button
fullWidthMobile
on:click={() => {
if (
formComponent.checkValidity() &&
(!couponForm || couponForm.checkValidity())
) {
handleSubmit();
}
}}
disabled={!couponData?.code || $isSubmitting}>
{#if $isSubmitting}
<span
class="loader is-small is-transparent u-line-height-1-5"
aria-hidden="true"></span>
{/if}
{#if selectedOrgId === newOrgId}
Create organization
{:else if isUpgrade()}
Upgrade
{:else}
Apply
{/if}
</Button>
{/if}
</svelte:fragment>
<svelte:fragment slot="exit">
You can apply your credits to an organization at a later date. All other data entered will
@@ -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('/'));
}
};
@@ -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'));