From 6b6a3bc7e5bd44513ff05a3286bc06b21d6ace07 Mon Sep 17 00:00:00 2001 From: Ota Prokopec Date: Wed, 8 Feb 2023 20:16:26 +0100 Subject: [PATCH] login-games --- src/lib/utils/game.ts | 13 ++++++++++++ src/routes/game/game.svelte | 7 +++++-- src/routes/log_in.svelte | 35 ++++++++++++++++--------------- src/routes/profile/profile.svelte | 9 +++++--- 4 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 src/lib/utils/game.ts diff --git a/src/lib/utils/game.ts b/src/lib/utils/game.ts new file mode 100644 index 0000000..6c772b3 --- /dev/null +++ b/src/lib/utils/game.ts @@ -0,0 +1,13 @@ +import { databases } from '$lib/appwrite' +import { Query } from 'appwrite' +import database from 'svelte-appwrite-client/src/lib/database' + +export const load = async (pathName: string) => { + const checkPoints = [] + const game = (await databases.listDocuments('63cef30d6da945dd4250', '63cef4bd210fdf2e5888', [Query.equal('ExpURL', pathName.slice(1, pathName.length))])).documents[0] + const checkPointsIds = game.ExpCPsID + + for (const checkPointId of checkPointsIds) { + checkPoints.push(await databases.getDocument('63cef30d6da945dd4250', '63cef84d908acf805758', checkPointId)) + } +} diff --git a/src/routes/game/game.svelte b/src/routes/game/game.svelte index b07e649..d11c6d2 100644 --- a/src/routes/game/game.svelte +++ b/src/routes/game/game.svelte @@ -16,8 +16,11 @@ import collections from '$lib/collections' import { Query } from 'appwrite' - export let gameurl - const [gameData, loading] = collections.expiriences.getDocument([Query.equal('ExpURL', gameurl)]) + export let params + + const [gameData, loading] = collections.expiriences.getDocument([Query.equal('ExpURL', params.gameurl)]) + + $: console.log($gameData) $: $data = $loading ? $gameData : null diff --git a/src/routes/log_in.svelte b/src/routes/log_in.svelte index 25c72db..1571ea2 100644 --- a/src/routes/log_in.svelte +++ b/src/routes/log_in.svelte @@ -1,10 +1,21 @@
@@ -24,21 +35,11 @@
- {#if purpose === 'login'} -
- - - - - {:else} -
- - - - - - - {/if} +
+ + + emailLogin()} type="button" value="Sign in" /> +
@@ -192,7 +193,7 @@ line-height: 28px; } - input[type='submit'] { + input[type='button'] { background-color: #4263eb; color: white; diff --git a/src/routes/profile/profile.svelte b/src/routes/profile/profile.svelte index 8c0d926..903e533 100644 --- a/src/routes/profile/profile.svelte +++ b/src/routes/profile/profile.svelte @@ -13,6 +13,9 @@ import Point from '$lib/svg/Point.svelte' import PointSmall from '$lib/svg/PointSmall.svelte' import InputPicture from '$lib/Components/Inputs/InputPicture.svelte' + import { account, user } from '$lib/appwrite' + + $: console.log($user) const items = [ { @@ -32,7 +35,7 @@ itms: [ { icon: Help, text: 'Help' }, { icon: Warning, text: 'Terms & Conditions' }, - { icon: Logout, text: 'Log out' }, + { icon: Logout, text: 'Log out', onClick: () => user.deleteSessions() }, ], }, ] @@ -52,10 +55,10 @@
{#each items as { title, itms }}
{title}
- {#each itms as { icon, text }} + {#each itms as { icon, text, onClick }} - {text} + {/each}