diff --git a/frontend/src/routes/app/adventures/+page.server.ts b/frontend/src/routes/app/adventures/+page.server.ts index 0af9215..e6ed55f 100644 --- a/frontend/src/routes/app/adventures/+page.server.ts +++ b/frontend/src/routes/app/adventures/+page.server.ts @@ -4,8 +4,7 @@ export const load: PageServerLoad = async ({ locals, url }) => { let successMessage: null | string = null; if (url.searchParams.get('created')) { successMessage = `Adventure created, check back in a few minutes`; - url.searchParams.delete('created'); - url.searchParams. + url.searchParams.delete('created'); } return { successMessage diff --git a/frontend/src/routes/app/adventures/+page.svelte b/frontend/src/routes/app/adventures/+page.svelte index d6f5329..7dcbdbf 100644 --- a/frontend/src/routes/app/adventures/+page.svelte +++ b/frontend/src/routes/app/adventures/+page.svelte @@ -23,8 +23,10 @@ {#each adventures as adventure (adventure.id)}
-

{adventure.title}

-

{adventure.description}

+ +

{adventure.title}

+

{adventure.description}

+
{/each} diff --git a/frontend/src/routes/app/adventures/[id]/+page.server.ts b/frontend/src/routes/app/adventures/[id]/+page.server.ts new file mode 100644 index 0000000..19bd7fc --- /dev/null +++ b/frontend/src/routes/app/adventures/[id]/+page.server.ts @@ -0,0 +1,29 @@ +import { getAdventureBffAdventureAdventureIdGet } from '@client'; +import type { PageServerLoad } from './$types'; +import { error } from '@sveltejs/kit'; + +export const load: PageServerLoad = async ({ locals, params }) => { + const response = await getAdventureBffAdventureAdventureIdGet({ + path: { + adventure_id: params.id + }, + headers: { + Authorization: `Bearer ${locals.authToken}` + } + }); + + if (response.error) { + console.error(`Error fetching an adventure:`); + console.error({ error: response.error }); + return error(400, `Error loading adventure`); + } + + const { title, entries, current_entry_choices } = response.data; + + response.data.entries.forEach((e) => console.log(e.story_text)); + return { + title: title, + entries, + choices: current_entry_choices + }; +}; diff --git a/frontend/src/routes/app/adventures/[id]/+page.svelte b/frontend/src/routes/app/adventures/[id]/+page.svelte new file mode 100644 index 0000000..dd64946 --- /dev/null +++ b/frontend/src/routes/app/adventures/[id]/+page.svelte @@ -0,0 +1,18 @@ + + +
+

{data.title}

+ + {#if latestEntry} + + {/if} +
+ + diff --git a/frontend/src/routes/app/adventures/[id]/LatestEntry.svelte b/frontend/src/routes/app/adventures/[id]/LatestEntry.svelte new file mode 100644 index 0000000..880efdaf8 --- /dev/null +++ b/frontend/src/routes/app/adventures/[id]/LatestEntry.svelte @@ -0,0 +1,181 @@ + + +
+
+
+ {#each sourceParagraphs as paragraph, index (index)} +

+ {paragraph} +

+ {/each} +
+
+ +
+
+

Translation

+
+ +
+ {#each translationParagraphs as paragraph, index (index)} +

+ {paragraph} +

+ {/each} +
+
+
+ +