File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
src/routes/(console)/onboarding/create-project Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 12
12
import CreateProject from ' $lib/layout/createProject.svelte' ;
13
13
import { loadAvailableRegions } from ' $routes/(console)/regions' ;
14
14
import { regions as regionsStore } from ' $lib/stores/organization' ;
15
+ import { user } from ' $lib/stores/user' ;
15
16
16
17
let isLoading = false ;
17
18
let id: string ;
18
19
let startAnimation = false ;
19
20
let projectName = ' Appwrite project' ;
20
21
let region = Region .Fra ;
22
+
21
23
export let data;
22
24
25
+ function markOnboardingComplete() {
26
+ const currentPrefs = data .accountPrefs ?? $user .prefs ;
27
+
28
+ const newPrefs = {
29
+ ... currentPrefs ,
30
+ newOnboardingCompleted: true
31
+ };
32
+
33
+ sdk .forConsole .account .updatePrefs (newPrefs );
34
+ }
35
+
23
36
async function createProject() {
24
37
isLoading = true ;
25
38
31
44
teamId ,
32
45
isCloud ? region : undefined
33
46
);
47
+
48
+ markOnboardingComplete ();
49
+
34
50
trackEvent (Submit .ProjectCreate , {
35
51
customId: !! id ,
36
52
teamId
Original file line number Diff line number Diff line change @@ -10,7 +10,17 @@ import { base } from '$app/paths';
10
10
11
11
// TODO: this needs to be cleaned up!
12
12
export const load : PageLoad = async ( { parent } ) => {
13
- const { organizations } = await parent ( ) ;
13
+ const { account, organizations } = await parent ( ) ;
14
+
15
+ const accountPrefs = account . prefs ;
16
+ const hasCompletedOnboarding = accountPrefs [ 'newOnboardingCompleted' ] ?? false ;
17
+
18
+ // user has already seen it, lets redirect now!
19
+ if ( hasCompletedOnboarding && ! organizations ?. total ) {
20
+ redirect ( 303 , `${ base } /onboarding/create-organization` ) ;
21
+ } else if ( hasCompletedOnboarding && organizations ?. total ) {
22
+ redirect ( 303 , `${ base } /organization-${ organizations . teams [ 0 ] . $id } ` ) ;
23
+ }
14
24
15
25
if ( ! organizations ?. total ) {
16
26
try {
@@ -30,6 +40,7 @@ export const load: PageLoad = async ({ parent }) => {
30
40
31
41
if ( isOrganization ( org ) ) {
32
42
return {
43
+ accountPrefs,
33
44
organization : org
34
45
} ;
35
46
} else {
@@ -40,6 +51,7 @@ export const load: PageLoad = async ({ parent }) => {
40
51
}
41
52
} else {
42
53
return {
54
+ accountPrefs,
43
55
organization : await sdk . forConsole . teams . create (
44
56
ID . unique ( ) ,
45
57
'Personal projects'
@@ -62,6 +74,7 @@ export const load: PageLoad = async ({ parent }) => {
62
74
}
63
75
if ( ! projects ?. total ) {
64
76
return {
77
+ accountPrefs,
65
78
organization : org
66
79
} ;
67
80
} else {
You can’t perform that action at this time.
0 commit comments