Skip to content

Commit fdaea11

Browse files
authored
Merge pull request #2774 from appwrite/fix-create-org
2 parents d2e194b + 548905e commit fdaea11

File tree

5 files changed

+55
-27
lines changed

5 files changed

+55
-27
lines changed

src/lib/components/breadcrumbs.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@
236236
}
237237
}
238238
239+
/* for stricter type */
240+
let selectedOrg: Organization;
239241
$: selectedOrg = organizations.find((org) => org.isSelected);
240242
241243
$: organizationsBottomSheet = createOrganizationBottomSheet(selectedOrg);

src/routes/(console)/account/organizations/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
event="organization"
112112
offset={data.offset}
113113
on:click={createOrg}
114-
disableEmpty={false}
114+
disableEmpty={!resolvedProfile.showCreateOrganization}
115115
total={data.organizations.total}>
116116
{#each data.organizations.teams as organization}
117117
{@const avatarList = getMemberships(organization.$id)}

src/routes/(console)/apply-credit/+page.svelte

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@
6060
value: team.$id,
6161
label: team.name
6262
})) ?? []),
63-
{
64-
value: newOrgId,
65-
label: 'Create new organization'
66-
}
63+
...(resolvedProfile.showCreateOrganization
64+
? [
65+
{
66+
value: newOrgId,
67+
label: 'Create new organization'
68+
}
69+
]
70+
: [])
6771
];
6872
let name: string;
6973
let coupon: string;
@@ -391,26 +395,32 @@
391395
</svelte:fragment>
392396
<svelte:fragment slot="footer">
393397
<Button fullWidthMobile secondary on:click={() => (showExitModal = true)}>Cancel</Button>
394-
<Button
395-
fullWidthMobile
396-
on:click={() => {
397-
if (formComponent.checkValidity() && (!couponForm || couponForm.checkValidity())) {
398-
handleSubmit();
399-
}
400-
}}
401-
disabled={!couponData?.code || $isSubmitting}>
402-
{#if $isSubmitting}
403-
<span class="loader is-small is-transparent u-line-height-1-5" aria-hidden="true"
404-
></span>
405-
{/if}
406-
{#if selectedOrgId === newOrgId}
407-
Create organization
408-
{:else if isUpgrade()}
409-
Upgrade
410-
{:else}
411-
Apply
412-
{/if}
413-
</Button>
398+
{#if resolvedProfile.showCreateOrganization}
399+
<Button
400+
fullWidthMobile
401+
on:click={() => {
402+
if (
403+
formComponent.checkValidity() &&
404+
(!couponForm || couponForm.checkValidity())
405+
) {
406+
handleSubmit();
407+
}
408+
}}
409+
disabled={!couponData?.code || $isSubmitting}>
410+
{#if $isSubmitting}
411+
<span
412+
class="loader is-small is-transparent u-line-height-1-5"
413+
aria-hidden="true"></span>
414+
{/if}
415+
{#if selectedOrgId === newOrgId}
416+
Create organization
417+
{:else if isUpgrade()}
418+
Upgrade
419+
{:else}
420+
Apply
421+
{/if}
422+
</Button>
423+
{/if}
414424
</svelte:fragment>
415425
<svelte:fragment slot="exit">
416426
You can apply your credits to an organization at a later date. All other data entered will
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { resolve } from '$app/paths';
2+
import { redirect } from '@sveltejs/kit';
3+
import type { PageLoad } from './$types';
4+
import { ProfileMode, resolvedProfile } from '$lib/profiles/index.svelte';
5+
6+
export const load: PageLoad = async ({ parent }) => {
7+
const { organizations } = await parent();
8+
9+
if (resolvedProfile.id === ProfileMode.STUDIO && organizations.total > 0) {
10+
redirect(303, resolve('/'));
11+
}
12+
};

src/routes/(console)/onboarding/create-project/+page.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ import { ID, Query, type Models } from '@appwrite.io/console';
77
import { BillingPlan } from '$lib/constants';
88
import { redirect } from '@sveltejs/kit';
99
import { base, resolve } from '$app/paths';
10-
import { resolvedProfile } from '$lib/profiles/index.svelte';
10+
import { ProfileMode, resolvedProfile } from '$lib/profiles/index.svelte';
1111

1212
// TODO: this needs to be cleaned up!
1313
export const load: PageLoad = async ({ parent }) => {
1414
const { account, organizations } = await parent();
1515

16-
const firstOrganization = organizations?.teams[0]?.$id;
16+
/* short circuit and redirect */
17+
if (resolvedProfile.id === ProfileMode.STUDIO) {
18+
redirect(303, resolve('/'));
19+
}
1720

21+
const firstOrganization = organizations?.teams[0]?.$id;
1822
if (!resolvedProfile.showOnboarding) {
1923
if (!organizations?.total) {
2024
redirect(303, resolve('/(console)/create-organization'));

0 commit comments

Comments
 (0)