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
18 changes: 8 additions & 10 deletions src/routes/(public)/(guest)/register/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,18 @@
await sdk.forConsole.account.create(ID.unique(), mail, pass, name ?? '');
await sdk.forConsole.account.createEmailPasswordSession(mail, pass);
if ($redirectTo) {
window.location.href = $redirectTo;
return;
}
await invalidate(Dependencies.ACCOUNT);
trackEvent(Submit.AccountCreate, { campaign_name: data?.couponData?.code });
if (data?.couponData?.code) {
await goto(`${base}/apply-credit?code=${data?.couponData?.code}`);
return;
}
if (data?.campaign) {
} else if (data?.campaign?.$id) {
await goto(`${base}/apply-credit?campaign=${data.campaign.$id}`);
return;
}
if (page.url.searchParams) {
} else if ($redirectTo) {
window.location.href = $redirectTo;
return;
} else if (page.url.searchParams) {
const redirect = page.url.searchParams.get('redirect');
page.url.searchParams.delete('redirect');
if (redirect) {
Expand All @@ -60,6 +56,8 @@
} else {
await goto(base);
}
await invalidate(Dependencies.ACCOUNT);
} catch (error) {
disabled = false;
addNotification({
Expand Down
6 changes: 4 additions & 2 deletions src/routes/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ const userVisitedEducationPage = (): boolean => {
export const load: PageLoad = async ({ parent, url }) => {
const { organizations, account } = await parent();

const isApplyingCredit = url.pathname.includes('apply-credit');

if (userVisitedEducationPage()) {
await handleGithubEducationMembership(account.name, account.email);
redirect(303, base);
} else if (organizations.total) {
} else if (organizations.total && !isApplyingCredit) {
const teamId = account.prefs.organization ?? organizations.teams[0].$id;
if (!teamId) {
redirect(303, `${base}/account/organizations${url.search}`);
} else {
redirect(303, `${base}/organization-${teamId}${url.search}`);
}
} else {
} else if (!isApplyingCredit) {
redirect(303, `${base}/onboarding/create-project${url.search}`);
}
};
Expand Down