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 @@