diff --git a/frontend/src/lib/components/AdventureCard.svelte b/frontend/src/lib/components/AdventureCard.svelte index 58b7701..b813a9a 100644 --- a/frontend/src/lib/components/AdventureCard.svelte +++ b/frontend/src/lib/components/AdventureCard.svelte @@ -226,7 +226,7 @@ > {/if} - {#if (adventure.collection && adventure.type == 'visited') || adventure.type == 'planned'} + {#if adventure.collection && (adventure.type == 'visited' || adventure.type == 'planned')} diff --git a/frontend/src/routes/adventures/[id]/+page.server.ts b/frontend/src/routes/adventures/[id]/+page.server.ts index 109c54e..8c0a4bc 100644 --- a/frontend/src/routes/adventures/[id]/+page.server.ts +++ b/frontend/src/routes/adventures/[id]/+page.server.ts @@ -1,6 +1,6 @@ import type { PageServerLoad } from './$types'; const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL']; -import type { Adventure } from '$lib/types'; +import type { Adventure, Collection } from '$lib/types'; const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000'; export const load = (async (event) => { @@ -19,10 +19,21 @@ export const load = (async (event) => { }; } else { let adventure = (await request.json()) as Adventure; + let collection: Collection | null = null; + + if (adventure.collection) { + let res2 = await fetch(`${endpoint}/api/collections/${adventure.collection}/`, { + headers: { + Cookie: `${event.cookies.get('auth')}` + } + }); + collection = await res2.json(); + } return { props: { - adventure + adventure, + collection } }; } diff --git a/frontend/src/routes/adventures/[id]/+page.svelte b/frontend/src/routes/adventures/[id]/+page.svelte index ad938e9..44a4621 100644 --- a/frontend/src/routes/adventures/[id]/+page.svelte +++ b/frontend/src/routes/adventures/[id]/+page.svelte @@ -19,8 +19,10 @@ import type { PageData } from './$types'; import { goto } from '$app/navigation'; import Lost from '$lib/assets/undraw_lost.svg'; + import { DefaultMarker, MapLibre, Popup } from 'svelte-maplibre'; export let data: PageData; + console.log(data); let adventure: Adventure; @@ -62,66 +64,239 @@ {/if} + {#if adventure} - {#if adventure.name} -

{adventure.name}

- {/if} - {#if adventure.location} -

- {adventure.location} -

- {/if} - {#if adventure.date} -

- Visited on: {adventure.date} -

- {/if} - {#if adventure.rating !== undefined && adventure.rating !== null} -
-
- {#each Array.from({ length: 5 }, (_, i) => i + 1) as star} - - {/each} -
-
- {/if} - {#if adventure.description} -

{adventure.description}

- {/if} - {#if adventure.link} -
- - Visit Website - -
- {/if} - {#if adventure.activity_types && adventure.activity_types.length > 0} -
-

Activities: 

- -
- {/if} - {#if adventure.image} -
- - Adventure Image -
- {/if} + +
+
+
+

Trip Details

+
+
+
+

Trip Type

+

+ {adventure.type[0].toLocaleUpperCase() + adventure.type.slice(1)} +

+
+ {#if data.props.collection} +
+

Collection

+

{data.props.collection.name}

+
+ {/if} +
+ {#if adventure.longitude && adventure.latitude} +
+
+

Latitude

+

{adventure.latitude}° N

+
+
+

Longitude

+

{adventure.longitude}° W

+
+
+ + + + + + +
{adventure.name}
+

+ {adventure.type.charAt(0).toUpperCase() + adventure.type.slice(1)} +

+

+ {adventure.date + ? new Date(adventure.date).toLocaleDateString('en-US', { + timeZone: 'UTC' + }) + : ''} +

+
+
+
+ {/if} +
+
+
+ + + {/if}