Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib/components/breadcrumbs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@
}
}

/* for stricter type */
let selectedOrg: Organization;
$: selectedOrg = organizations.find((org) => org.isSelected);

$: organizationsBottomSheet = createOrganizationBottomSheet(selectedOrg);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(console)/account/organizations/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down
58 changes: 34 additions & 24 deletions src/routes/(console)/apply-credit/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/routes/(console)/onboarding/create-organization/+page.ts
Original file line number Diff line number Diff line change
@@ -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('/'));
}
};
8 changes: 6 additions & 2 deletions src/routes/(console)/onboarding/create-project/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
Loading