+ {#if session && session._id}
+
+ {/if}
+ Customize Profile
+
+
+
+ {#if error}
+ {error}
+ {:else if loading}
+ Loading...
+ {/if}
+
+
+ View profile
+
+
+
+
+
+
+
+
+ {#if isDonator}
+
+
+
+
+ Windows: win+.
+ Mobile: Emoji keyboard
+
+ ⓘ
+
+ {/if}
+ Background
+
+ {#each backgroundNames as thisBackgroundName}
+ (backgroundName = thisBackgroundName)}
+ on:keypress={e => {
+ if (e.key === 'Enter') {
+ backgroundName = thisBackgroundName
+ }
+ }}
+ />
+ {/each}
+
+
+
+
diff --git a/src/routes/profile/+page.ts b/src/routes/profile/+page.ts
new file mode 100644
index 0000000..cdd2a93
--- /dev/null
+++ b/src/routes/profile/+page.ts
@@ -0,0 +1,44 @@
+import { fetchApi } from '$lib/api'
+import type { AccountSchema, SessionSchema } from '$lib/APITypes'
+import donators from '../../_donators.json'
+import admins from '../../_admins.json'
+import type { PageLoad } from './$types'
+import { redirect } from '@sveltejs/kit'
+
+export const load = (async ({ fetch, data }) => {
+ const sessionResponse: { session: SessionSchema | null; account: AccountSchema | null } | null =
+ await fetchApi(`accounts/session`, fetch, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ uuid: data.sid,
+ }),
+ }).then(r => r.json())
+
+ const playerResponse = sessionResponse?.account
+ ? await fetchApi(`player/${sessionResponse.account.minecraftUuid}`, fetch).then(r => r.json())
+ : null
+
+ // redirect to /login if the user is not logged in
+ if (
+ !sessionResponse ||
+ !sessionResponse.account ||
+ !sessionResponse.session ||
+ !playerResponse.player
+ ) {
+ throw redirect(303, '/login')
+ }
+
+ const isDonator =
+ donators.find(d => d?.uuid === sessionResponse.account?.minecraftUuid) !== undefined
+ const isAdmin = admins.find(a => a === sessionResponse.account?.minecraftUuid) !== undefined
+
+ return {
+ session: sessionResponse.session,
+ account: sessionResponse.account,
+ player: playerResponse,
+ isDonator: isDonator || isAdmin,
+ }
+}) as PageLoad
diff --git a/src/routes/profile/index.svelte b/src/routes/profile/index.svelte
deleted file mode 100644
index 0d5ad04..0000000
--- a/src/routes/profile/index.svelte
+++ /dev/null
@@ -1,219 +0,0 @@
-
-
-
-
-