fix: make itinerary lodging cards compact and remove duplicate overnight summary

This commit is contained in:
2026-03-07 17:47:22 +00:00
parent 3af4f06944
commit 2579cd46ce
2 changed files with 108 additions and 80 deletions

View File

@@ -101,6 +101,7 @@
export let readOnly: boolean = false;
export let itineraryItem: CollectionItineraryItem | null = null;
export let showImage: boolean = true;
export let compact: boolean = false;
let isWarningModalOpen: boolean = false;
@@ -154,13 +155,17 @@
{/if}
<div
class="card w-full max-w-md bg-base-300 shadow hover:shadow-md transition-all duration-200 border border-base-300 group"
class="card w-full bg-base-300 shadow hover:shadow-md transition-all duration-200 border border-base-300 group"
aria-label="lodging-card"
>
{#if showImage}
<!-- Image Section with Overlay -->
<div class="relative overflow-hidden rounded-t-2xl">
<CardCarousel images={lodging.images} icon={getLodgingIcon(lodging.type)} name={lodging.name} />
<CardCarousel
images={lodging.images}
icon={getLodgingIcon(lodging.type)}
name={lodging.name}
/>
<!-- Privacy Indicator -->
<div class="absolute top-2 right-4">
@@ -193,12 +198,22 @@
{/if}
</div>
{/if}
<div class="card-body p-4 space-y-3 min-w-0">
<div
class="card-body min-w-0"
class:p-3={compact}
class:p-4={!compact}
class:space-y-2={compact}
class:space-y-3={!compact}
>
<!-- Header -->
<div class="flex items-start justify-between gap-3">
<a
href="/lodging/{lodging.id}"
class="hover:text-primary transition-colors duration-200 line-clamp-2 text-lg font-semibold"
class="hover:text-primary transition-colors duration-200 line-clamp-2"
class:text-base={compact}
class:text-lg={!compact}
class:font-medium={compact}
class:font-semibold={!compact}
>
{lodging.name}
</a>

View File

@@ -576,6 +576,10 @@
return day.items.filter((item) => item.id !== day.boundaryLodgingItem?.id);
}
function shouldShowOvernightSummary(day: DayGroup): boolean {
return day.overnightLodging.length > 0 && !day.boundaryLodgingItem?.resolvedObject;
}
function reinsertBoundaryLodgingItem(
day: DayGroup,
timelineItems: ResolvedItineraryItem[]
@@ -1111,18 +1115,18 @@
targetPendingDate &&
!addedToItinerary.has(lodgingBeingUpdated.id)
) {
// Normalize check_in to date-only (YYYY-MM-DD) if present
const lodgingCheckInDate = lodgingBeingUpdated.check_in
? String(lodgingBeingUpdated.check_in).split('T')[0]
: null;
const targetDate = lodgingCheckInDate || targetPendingDate;
// Normalize check_in to date-only (YYYY-MM-DD) if present
const lodgingCheckInDate = lodgingBeingUpdated.check_in
? String(lodgingBeingUpdated.check_in).split('T')[0]
: null;
const targetDate = lodgingCheckInDate || targetPendingDate;
addItineraryItemForObject('lodging', lodgingBeingUpdated.id, targetDate);
// Mark this lodging as added to prevent duplicates
addedToItinerary.add(lodgingBeingUpdated.id);
addedToItinerary = addedToItinerary; // trigger reactivity
pendingAddDate = null;
pendingLodgingAddDate = null;
addItineraryItemForObject('lodging', lodgingBeingUpdated.id, targetDate);
// Mark this lodging as added to prevent duplicates
addedToItinerary.add(lodgingBeingUpdated.id);
addedToItinerary = addedToItinerary; // trigger reactivity
pendingAddDate = null;
pendingLodgingAddDate = null;
}
}
@@ -2330,11 +2334,12 @@
lodging={resolvedObj}
{user}
{collection}
itineraryItem={item}
showImage={false}
on:delete={handleItemDelete}
on:removeFromItinerary={handleRemoveItineraryItem}
on:edit={handleEditLodging}
itineraryItem={item}
showImage={false}
compact={true}
on:delete={handleItemDelete}
on:removeFromItinerary={handleRemoveItineraryItem}
on:edit={handleEditLodging}
on:moveToGlobal={(e) => moveItemToGlobal(e.detail.type, e.detail.id)}
/>
{:else if objectType === 'note'}
@@ -2555,6 +2560,7 @@
{collection}
itineraryItem={boundaryLodgingItem}
showImage={false}
compact={true}
on:delete={handleItemDelete}
on:removeFromItinerary={handleRemoveItineraryItem}
on:edit={handleEditLodging}
@@ -2821,11 +2827,12 @@
lodging={resolvedObj}
{user}
{collection}
itineraryItem={item}
showImage={false}
on:delete={handleItemDelete}
on:removeFromItinerary={handleRemoveItineraryItem}
on:edit={handleEditLodging}
itineraryItem={item}
showImage={false}
compact={true}
on:delete={handleItemDelete}
on:removeFromItinerary={handleRemoveItineraryItem}
on:edit={handleEditLodging}
on:moveToGlobal={(e) =>
moveItemToGlobal(e.detail.type, e.detail.id)}
on:changeDay={(e) =>
@@ -2887,26 +2894,28 @@
<LocationMarker class="w-3.5 h-3.5" />
{locationConnector.durationLabel}
</span>
<span class="text-base-content/40">•</span>
{#if directionsUrl}
<a
href={directionsUrl}
target="_blank"
rel="noopener noreferrer"
class="inline-flex items-center gap-1 text-primary/80 font-medium underline underline-offset-2"
>
<LocationMarker class="w-3.5 h-3.5" />
{getI18nText('itinerary.directions', 'Directions')}
</a>
{:else}
<span class="inline-flex items-center gap-1 text-primary/80 font-medium underline underline-offset-2">
<LocationMarker class="w-3.5 h-3.5" />
{getI18nText('itinerary.directions', 'Directions')}
</span>
{/if}
</div>
{:else}
<div class="flex items-center gap-2 flex-wrap text-base-content">
<span class="text-base-content/40">•</span>
{#if directionsUrl}
<a
href={directionsUrl}
target="_blank"
rel="noopener noreferrer"
class="inline-flex items-center gap-1 text-primary/80 font-medium underline underline-offset-2"
>
<LocationMarker class="w-3.5 h-3.5" />
{getI18nText('itinerary.directions', 'Directions')}
</a>
{:else}
<span
class="inline-flex items-center gap-1 text-primary/80 font-medium underline underline-offset-2"
>
<LocationMarker class="w-3.5 h-3.5" />
{getI18nText('itinerary.directions', 'Directions')}
</span>
{/if}
</div>
{:else}
<div class="flex items-center gap-2 flex-wrap text-base-content">
<span class="inline-flex items-center gap-1 font-medium">
{#if locationConnector.mode === 'driving'}
<Car class="w-3.5 h-3.5" />
@@ -2917,26 +2926,28 @@
</span>
<span class="text-base-content/50">•</span>
<span class="font-medium">{locationConnector.distanceLabel}</span>
<span class="text-base-content/50">•</span>
{#if directionsUrl}
<a
href={directionsUrl}
target="_blank"
rel="noopener noreferrer"
class="inline-flex items-center gap-1 text-primary font-medium underline underline-offset-2"
>
<LocationMarker class="w-3.5 h-3.5" />
{getI18nText('itinerary.directions', 'Directions')}
</a>
{:else}
<span class="inline-flex items-center gap-1 text-primary font-medium underline underline-offset-2">
<LocationMarker class="w-3.5 h-3.5" />
{getI18nText('itinerary.directions', 'Directions')}
</span>
{/if}
</div>
{/if}
</div>
<span class="text-base-content/50">•</span>
{#if directionsUrl}
<a
href={directionsUrl}
target="_blank"
rel="noopener noreferrer"
class="inline-flex items-center gap-1 text-primary font-medium underline underline-offset-2"
>
<LocationMarker class="w-3.5 h-3.5" />
{getI18nText('itinerary.directions', 'Directions')}
</a>
{:else}
<span
class="inline-flex items-center gap-1 text-primary font-medium underline underline-offset-2"
>
<LocationMarker class="w-3.5 h-3.5" />
{getI18nText('itinerary.directions', 'Directions')}
</span>
{/if}
</div>
{/if}
</div>
{/if}
</div>
</div>
@@ -3011,6 +3022,7 @@
{collection}
itineraryItem={boundaryLodgingItem}
showImage={false}
compact={true}
on:delete={handleItemDelete}
on:removeFromItinerary={handleRemoveItineraryItem}
on:edit={handleEditLodging}
@@ -3075,13 +3087,13 @@
<button
type="button"
role="menuitem"
on:click={() => {
pendingAddDate = day.date;
pendingLodgingAddDate = day.date;
lodgingToEdit = null;
lodgingBeingUpdated = null;
isLodgingModalOpen = true;
}}
on:click={() => {
pendingAddDate = day.date;
pendingLodgingAddDate = day.date;
lodgingToEdit = null;
lodgingBeingUpdated = null;
isLodgingModalOpen = true;
}}
>
{$t('adventures.lodging')}
</button>
@@ -3130,10 +3142,10 @@
</div>
<!-- Overnight Lodging + Dated Trip-wide Indicators (share row to save space) -->
{#if day.overnightLodging.length > 0 || day.globalDatedItems.length > 0}
{#if shouldShowOvernightSummary(day) || day.globalDatedItems.length > 0}
<div class="mt-4 pt-4 border-t border-base-300 border-dashed">
<div class="flex flex-wrap gap-6 items-start">
{#if day.overnightLodging.length > 0}
{#if shouldShowOvernightSummary(day)}
<div class="space-y-2 min-w-[240px] flex-1">
<div class="flex items-center gap-2 mb-1 opacity-70">
<Bed class="w-4 h-4" />
@@ -3352,12 +3364,13 @@
/>
{:else if type === 'lodging'}
<LodgingCard
lodging={item}
{user}
{collection}
showImage={false}
on:delete={handleItemDelete}
on:edit={handleEditLodging}
lodging={item}
{user}
{collection}
showImage={false}
compact={true}
on:delete={handleItemDelete}
on:edit={handleEditLodging}
/>
{:else if type === 'note'}
<NoteCard