diff --git a/frontend/src/lib/components/AdventureCard.svelte b/frontend/src/lib/components/AdventureCard.svelte index d72fdfa..293984c 100644 --- a/frontend/src/lib/components/AdventureCard.svelte +++ b/frontend/src/lib/components/AdventureCard.svelte @@ -19,6 +19,7 @@ import DotsHorizontal from '~icons/mdi/dots-horizontal'; import DeleteWarning from './DeleteWarning.svelte'; import ImageDisplayModal from './ImageDisplayModal.svelte'; + import { typeToString } from '$lib'; export let type: string; export let user: User | null; @@ -209,16 +210,8 @@
- {#if adventure.type == 'visited'} -
Visited
- {:else if adventure.type == 'planned'} -
Planned
- {:else if adventure.type == 'lodging'} -
Lodging
- {:else if adventure.type == 'dining'} -
Dining
- {/if} - +
{typeToString(adventure.type)}
+
{adventure.visits.length > 0 ? 'Visited' : 'Planned'}
{adventure.is_public ? 'Public' : 'Private'}
{#if adventure.location && adventure.location !== ''} @@ -227,16 +220,13 @@

{adventure.location}

{/if} - {#if adventure.date && adventure.date !== ''} -
+ {#if adventure.visits.length > 0} + +
-

- {new Date(adventure.date).toLocaleDateString(undefined, { - timeZone: 'UTC' - })}{adventure.end_date && adventure.end_date !== '' - ? ' - ' + - new Date(adventure.end_date).toLocaleDateString(undefined, { timeZone: 'UTC' }) - : ''} +

+ {adventure.visits.length} + {adventure.visits.length > 1 ? 'visits' : 'visit'}

{/if} diff --git a/frontend/src/lib/components/AdventureModal.svelte b/frontend/src/lib/components/AdventureModal.svelte index 304f55c..c91137a 100644 --- a/frontend/src/lib/components/AdventureModal.svelte +++ b/frontend/src/lib/components/AdventureModal.svelte @@ -22,6 +22,7 @@ import Earth from '~icons/mdi/earth'; import ActivityComplete from './ActivityComplete.svelte'; import { appVersion } from '$lib/config'; + import { ADVENTURE_TYPES } from '$lib'; export let startDate: string | null = null; export let endDate: string | null = null; @@ -37,8 +38,7 @@ id: '', name: '', type: 'visited', - date: null, - end_date: null, + visits: [], link: null, description: null, activity_types: [], @@ -57,9 +57,7 @@ adventure = { id: adventureToEdit?.id || '', name: adventureToEdit?.name || '', - type: adventureToEdit?.type || 'visited', - date: adventureToEdit?.date || null, - end_date: adventureToEdit?.end_date || null, + type: adventureToEdit?.type || 'general', link: adventureToEdit?.link || null, description: adventureToEdit?.description || null, activity_types: adventureToEdit?.activity_types || [], @@ -70,7 +68,9 @@ location: adventureToEdit?.location || null, images: adventureToEdit?.images || [], user_id: adventureToEdit?.user_id || null, - collection: adventureToEdit?.collection || collection_id || null + collection: adventureToEdit?.collection || collection_id || null, + // visits: adventureToEdit?.visits || [] + visits: [] }; let markers: Point[] = []; @@ -369,18 +369,6 @@ } } - if (adventure.date && adventure.end_date) { - if (new Date(adventure.date) > new Date(adventure.end_date)) { - addToast('error', 'Start date must be before end date'); - return; - } - } - - if (adventure.end_date && !adventure.date) { - adventure.end_date = null; - adventure.date = null; - } - console.log(adventure); if (adventure.id === '') { let res = await fetch('/api/adventures', { @@ -449,84 +437,14 @@
-
- -
-
- -
- {#if is_collection} -
- -
-
- -
- {/if} +
+
- -
-
- -
- {#if adventure.date} -
-
- -
- {/if}
diff --git a/frontend/src/lib/index.ts b/frontend/src/lib/index.ts index 233dd3f..b7c563f 100644 --- a/frontend/src/lib/index.ts +++ b/frontend/src/lib/index.ts @@ -216,3 +216,37 @@ export function continentCodeToString(code: string) { return 'Unknown'; } } + +export let ADVENTURE_TYPES = [ + { type: 'general', label: 'General 🌍' }, + { type: 'Outdoor', label: 'Outdoor 🏞️' }, + { type: 'lodging', label: 'Lodging 🛌' }, + { type: 'dining', label: 'Dining 🍽️' }, + { type: 'activity', label: 'Activity 🏄' }, + { type: 'attraction', label: 'Attraction 🎢' }, + { type: 'shopping', label: 'Shopping 🛍️' }, + { type: 'nightlife', label: 'Nightlife 🌃' }, + { type: 'event', label: 'Event 🎉' }, + { type: 'transportation', label: 'Transportation 🚗' }, + { type: 'culture', label: 'Culture 🎭' }, + { type: 'water_sports', label: 'Water Sports 🚤' }, + { type: 'hiking', label: 'Hiking 🥾' }, + { type: 'wildlife', label: 'Wildlife 🦒' }, + { type: 'historical_sites', label: 'Historical Sites 🏛️' }, + { type: 'music_concerts', label: 'Music & Concerts 🎶' }, + { type: 'fitness', label: 'Fitness 🏋️' }, + { type: 'art_museums', label: 'Art & Museums 🎨' }, + { type: 'festivals', label: 'Festivals 🎪' }, + { type: 'spiritual_journeys', label: 'Spiritual Journeys 🧘‍♀️' }, + { type: 'volunteer_work', label: 'Volunteer Work 🤝' }, + { type: 'other', label: 'Other' } +]; + +export function typeToString(type: string) { + const typeObj = ADVENTURE_TYPES.find((t) => t.type === type); + if (typeObj) { + return typeObj.label; + } else { + return 'Unknown'; + } +} diff --git a/frontend/src/lib/types.ts b/frontend/src/lib/types.ts index 4b5bb15..03f96a2 100644 --- a/frontend/src/lib/types.ts +++ b/frontend/src/lib/types.ts @@ -25,8 +25,11 @@ export type Adventure = { id: string; image: string; }[]; - date?: string | null; // Assuming date is a string in 'YYYY-MM-DD' format - end_date?: string | null; // Assuming date is a string in 'YYYY-MM-DD' format + visits: { + start_date: string; + end_date: string; + notes: string; + }[]; collection?: string | null; latitude: number | null; longitude: number | null; diff --git a/frontend/src/routes/adventures/+page.server.ts b/frontend/src/routes/adventures/+page.server.ts index cf80bce..07cfa0d 100644 --- a/frontend/src/routes/adventures/+page.server.ts +++ b/frontend/src/routes/adventures/+page.server.ts @@ -30,7 +30,7 @@ export const load = (async (event) => { } typeString += 'planned'; } else if (!visited && !planned) { - typeString = 'visited,planned'; + typeString = 'general'; } const include_collections = event.url.searchParams.get('include_collections') || 'false';