From c5cbea1c2043aa4189d78b49dd2a6615231fddea Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Thu, 1 Aug 2024 11:01:27 -0400 Subject: [PATCH 1/2] refactor: Improve adventure card UI and collection functionality --- .../src/lib/components/AdventureCard.svelte | 2 +- .../routes/adventures/[id]/+page.server.ts | 15 +- .../src/routes/adventures/[id]/+page.svelte | 295 ++++++++++++++---- 3 files changed, 249 insertions(+), 63 deletions(-) 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} From 9c6fcea5895962aae265181f1d649fa2373ef73b Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Thu, 1 Aug 2024 11:02:43 -0400 Subject: [PATCH 2/2] refactor: Remove unused toast functionality and map marker code --- frontend/src/routes/add/+page.svelte | 26 --- frontend/src/routes/toast/+page.svelte | 12 -- frontend/src/routes/view/+page.svelte | 253 ------------------------- 3 files changed, 291 deletions(-) delete mode 100644 frontend/src/routes/add/+page.svelte delete mode 100644 frontend/src/routes/toast/+page.svelte delete mode 100644 frontend/src/routes/view/+page.svelte diff --git a/frontend/src/routes/add/+page.svelte b/frontend/src/routes/add/+page.svelte deleted file mode 100644 index f692f5a..0000000 --- a/frontend/src/routes/add/+page.svelte +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - {#each markers as marker} - - {/each} - diff --git a/frontend/src/routes/toast/+page.svelte b/frontend/src/routes/toast/+page.svelte deleted file mode 100644 index 2e5f117..0000000 --- a/frontend/src/routes/toast/+page.svelte +++ /dev/null @@ -1,12 +0,0 @@ - - - diff --git a/frontend/src/routes/view/+page.svelte b/frontend/src/routes/view/+page.svelte deleted file mode 100644 index 9ec9a9a..0000000 --- a/frontend/src/routes/view/+page.svelte +++ /dev/null @@ -1,253 +0,0 @@ - - -
-
-
-
-
- Trip -
-
-
-
-

Maui, Hawaii

-
- -
- - - - - - - - - - - - - - - - 4.3 -
-
-
-
- - - - - Public -
-
- - - - - - - June 1 - June 10, 2024 -
-
- - - - - Maui, Hawaii, USA -
-
- - - - Snorkeling, Hiking, Relaxing -
- -
-
-

- Enjoy the beautiful beaches, lush tropical forests, and stunning waterfalls of Maui. - This trip is perfect for those looking to relax, explore, and create lasting memories. -

-
-
-
-
-
-
-

Trip Details

-
-
-
-

Trip Type

-

Beach Vacation

-
-
-

Collection

-

Summer Getaways

-
-
-
-
-

Latitude

-

20.7984° N

-
-
-

Longitude

-

156.3319° W

-
-
-
-
-
-
-
- -