diff --git a/frontend/src/lib/components/AdventureCard.svelte b/frontend/src/lib/components/AdventureCard.svelte index 057137d..3aeb6bc 100644 --- a/frontend/src/lib/components/AdventureCard.svelte +++ b/frontend/src/lib/components/AdventureCard.svelte @@ -18,6 +18,10 @@ import DeleteWarning from './DeleteWarning.svelte'; import CardCarousel from './CardCarousel.svelte'; import { t } from 'svelte-i18n'; + import Star from '~icons/mdi/star'; + import StarOutline from '~icons/mdi/star-outline'; + import Eye from '~icons/mdi/eye'; + import EyeOff from '~icons/mdi/eye-off'; export let type: string | null = null; export let user: User | null; @@ -28,15 +32,18 @@ let isWarningModalOpen: boolean = false; export let adventure: Adventure; - let activityTypes: string[] = []; - // makes it reactivty to changes so it updates automatically + let displayActivityTypes: string[] = []; + let remainingCount = 0; + + // Process activity types for display $: { if (adventure.activity_types) { - activityTypes = adventure.activity_types; - if (activityTypes.length > 3) { - activityTypes = activityTypes.slice(0, 3); - let remaining = adventure.activity_types.length - 3; - activityTypes.push('+' + remaining); + if (adventure.activity_types.length <= 3) { + displayActivityTypes = adventure.activity_types; + remainingCount = 0; + } else { + displayActivityTypes = adventure.activity_types.slice(0, 3); + remainingCount = adventure.activity_types.length - 3; } } } @@ -47,18 +54,28 @@ $: { if (collection && collection?.start_date && collection.end_date) { unlinked = adventure.visits.every((visit) => { - // Check if visit dates exist - if (!visit.start_date || !visit.end_date) return true; // Consider "unlinked" for incomplete visit data - - // Check if collection dates are completely outside this visit's range + if (!visit.start_date || !visit.end_date) return true; const isBeforeVisit = collection.end_date && collection.end_date < visit.start_date; const isAfterVisit = collection.start_date && collection.start_date > visit.end_date; - return isBeforeVisit || isAfterVisit; }); } } + // Helper functions for display + function formatVisitCount() { + const count = adventure.visits.length; + return count > 1 ? `${count} ${$t('adventures.visits')}` : `${count} ${$t('adventures.visit')}`; + } + + function renderStars(rating: number) { + const stars = []; + for (let i = 1; i <= 5; i++) { + stars.push(i <= rating); + } + return stars; + } + async function deleteAdventure() { let res = await fetch(`/api/adventures/${adventure.id}`, { method: 'DELETE' @@ -131,119 +148,184 @@ {/if}
- + +
+ -
-
+ +
+
+ {adventure.is_visited ? $t('adventures.visited') : $t('adventures.planned')} +
+ {#if unlinked} +
{$t('adventures.out_of_range')}
+ {/if} +
+ + +
+
+
+ {#if adventure.is_public} + + {:else} + + {/if} +
+
+
+ + + {#if adventure.category} +
+
+ {adventure.category.display_name} + {adventure.category.icon} +
+
+ {/if} +
+ + +
+ +
-
-
-
- {adventure.category?.display_name + ' ' + adventure.category?.icon} -
-
- {adventure.is_visited ? $t('adventures.visited') : $t('adventures.planned')} -
-
- {adventure.is_public ? $t('adventures.public') : $t('adventures.private')} -
-
- {#if unlinked} -
{$t('adventures.out_of_range')}
- {/if} - {#if adventure.location && adventure.location !== ''} -
- -

{adventure.location}

-
- {/if} - {#if adventure.visits.length > 0} - -
- -

- {adventure.visits.length} - {adventure.visits.length > 1 ? $t('adventures.visits') : $t('adventures.visit')} -

-
- {/if} - {#if adventure.activity_types && adventure.activity_types.length > 0} -
    - {#each activityTypes as activity} -
    - {activity} + + + {#if adventure.location} +
    + + {adventure.location} +
    + {/if} + + + {#if adventure.rating} +
    +
    + {#each renderStars(adventure.rating) as filled} + {#if filled} + + {:else} + + {/if} + {/each}
    - {/each} -
+ ({adventure.rating}/5) +
+ {/if} +
+ + + {#if adventure.visits.length > 0} +
+ + {formatVisitCount()} +
{/if} + + {#if !readOnly} -
- - +
{#if type != 'link'} - {#if adventure.user_id == user?.uuid || (collection && user && collection.shared_with?.includes(user.uuid))} - - {:else} +
- {/if} - {/if} - {#if type == 'link'} - + + View Details + + + {#if adventure.user_id == user?.uuid || (collection && user && collection.shared_with?.includes(user.uuid))} + + {/if} +
+ {:else} + {/if}
{/if}
+ + diff --git a/frontend/src/lib/components/CardCarousel.svelte b/frontend/src/lib/components/CardCarousel.svelte index cb238d0..60f9b38 100644 --- a/frontend/src/lib/components/CardCarousel.svelte +++ b/frontend/src/lib/components/CardCarousel.svelte @@ -97,12 +97,12 @@ {:else}
- +
{/if}