Fix navigation layout and search behavior
All checks were successful
Build Docker Image / build (push) Successful in 3m40s

- Reorder topnav components: search bar before submenu
- GlobalSearchBar: use page navigation instead of dropdowns
- Remove icons from MainNavigation and SubNavigation
- Create ListMapLayout universal component for list+map pages
- Migrate catalog pages (offers, suppliers, hubs) to ListMapLayout
This commit is contained in:
Ruslan Bakiev
2026-01-08 09:16:56 +07:00
parent 1a2693bcd6
commit f34c484561
8 changed files with 289 additions and 227 deletions

View File

@@ -0,0 +1,141 @@
<template>
<div class="flex flex-col flex-1 min-h-0">
<!-- Desktop: side-by-side layout -->
<div class="hidden lg:flex flex-1 gap-4 min-h-0">
<!-- Left side: List (scrollable) -->
<div class="w-2/5 overflow-y-auto pr-2">
<slot name="list" />
</div>
<!-- Right side: Map (sticky) -->
<div class="w-3/5 rounded-lg overflow-hidden">
<ClientOnly>
<CatalogMap
ref="mapRef"
:map-id="mapId"
:items="itemsWithCoords"
:point-color="pointColor"
@select-item="onMapSelectItem"
/>
</ClientOnly>
</div>
</div>
<!-- Mobile: toggle between list and map -->
<div class="lg:hidden flex-1 flex flex-col min-h-0">
<!-- Content area -->
<div class="flex-1 overflow-y-auto" v-show="mobileView === 'list'">
<slot name="list" />
</div>
<div class="flex-1" v-show="mobileView === 'map'">
<ClientOnly>
<CatalogMap
ref="mobileMapRef"
:map-id="`${mapId}-mobile`"
:items="itemsWithCoords"
:point-color="pointColor"
@select-item="onMapSelectItem"
/>
</ClientOnly>
</div>
<!-- Mobile toggle buttons -->
<div class="fixed bottom-4 left-1/2 -translate-x-1/2 z-30">
<div class="btn-group shadow-lg">
<button
class="btn btn-sm"
:class="{ 'btn-active': mobileView === 'list' }"
@click="mobileView = 'list'"
>
{{ $t('common.list') }}
</button>
<button
class="btn btn-sm"
:class="{ 'btn-active': mobileView === 'map' }"
@click="mobileView = 'map'"
>
{{ $t('common.map') }}
</button>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
interface MapItem {
uuid: string
latitude?: number | null
longitude?: number | null
name?: string
country?: string
[key: string]: any
}
const props = withDefaults(defineProps<{
items: MapItem[]
selectedItemId?: string
mapId: string
pointColor?: string
}>(), {
pointColor: '#3b82f6'
})
const emit = defineEmits<{
'select-item': [uuid: string]
'update:selectedItemId': [uuid: string]
}>()
// Filter items with valid coordinates
const itemsWithCoords = computed(() =>
props.items.filter(item =>
item.latitude != null &&
item.longitude != null &&
!isNaN(Number(item.latitude)) &&
!isNaN(Number(item.longitude))
).map(item => ({
uuid: item.uuid,
name: item.name || '',
latitude: Number(item.latitude),
longitude: Number(item.longitude),
country: item.country
}))
)
// Mobile view toggle
const mobileView = ref<'list' | 'map'>('list')
// Map refs
const mapRef = ref<{ flyTo: (lat: number, lng: number, zoom?: number) => void } | null>(null)
const mobileMapRef = ref<{ flyTo: (lat: number, lng: number, zoom?: number) => void } | null>(null)
// Handle map item selection
const onMapSelectItem = (uuid: string) => {
emit('select-item', uuid)
emit('update:selectedItemId', uuid)
}
// Fly to a specific item
const flyTo = (lat: number, lng: number, zoom = 8) => {
mapRef.value?.flyTo(lat, lng, zoom)
mobileMapRef.value?.flyTo(lat, lng, zoom)
}
// Fly to item by uuid
const flyToItem = (uuid: string) => {
const item = itemsWithCoords.value.find(i => i.uuid === uuid)
if (item) {
flyTo(item.latitude, item.longitude, 8)
}
}
// Watch selectedItemId and fly to it
watch(() => props.selectedItemId, (uuid) => {
if (uuid) {
flyToItem(uuid)
}
})
// Expose methods for parent components
defineExpose({ flyTo, flyToItem })
</script>

View File

@@ -17,7 +17,6 @@
class="px-4 py-2 rounded-full font-medium text-sm transition-colors hover:bg-base-200" class="px-4 py-2 rounded-full font-medium text-sm transition-colors hover:bg-base-200"
:class="{ 'bg-base-200 text-primary': isActiveTab(tab.key) }" :class="{ 'bg-base-200 text-primary': isActiveTab(tab.key) }"
> >
<Icon v-if="tab.icon" :name="tab.icon" size="18" class="mr-1" />
{{ tab.label }} {{ tab.label }}
</NuxtLink> </NuxtLink>
</nav> </nav>
@@ -137,11 +136,10 @@
v-for="tab in visibleTabs" v-for="tab in visibleTabs"
:key="tab.key" :key="tab.key"
:to="localePath(tab.path)" :to="localePath(tab.path)"
class="flex flex-col items-center gap-1 px-4 py-2 rounded-lg hover:bg-base-200" class="px-4 py-2 rounded-full text-sm font-medium hover:bg-base-200"
:class="{ 'bg-base-200 text-primary': isActiveTab(tab.key) }" :class="{ 'bg-base-200 text-primary': isActiveTab(tab.key) }"
> >
<Icon v-if="tab.icon" :name="tab.icon" size="16" /> {{ tab.label }}
<span class="text-xs">{{ tab.label }}</span>
</NuxtLink> </NuxtLink>
</nav> </nav>
</header> </header>
@@ -173,9 +171,9 @@ const route = useRoute()
const { t } = useI18n() const { t } = useI18n()
const tabs = computed(() => [ const tabs = computed(() => [
{ key: 'catalog', label: t('cabinetNav.catalog'), path: '/catalog/offers', icon: 'lucide:search', auth: false }, { key: 'catalog', label: t('cabinetNav.catalog'), path: '/catalog/offers', auth: false },
{ key: 'orders', label: t('cabinetNav.orders'), path: '/clientarea/orders', icon: 'lucide:package', auth: true }, { key: 'orders', label: t('cabinetNav.orders'), path: '/clientarea/orders', auth: true },
{ key: 'seller', label: t('cabinetNav.seller'), path: '/clientarea/offers', icon: 'lucide:store', auth: true, seller: true }, { key: 'seller', label: t('cabinetNav.seller'), path: '/clientarea/offers', auth: true, seller: true },
]) ])
const visibleTabs = computed(() => { const visibleTabs = computed(() => {

View File

@@ -8,7 +8,6 @@
class="px-4 py-2 rounded-full text-sm font-medium transition-colors whitespace-nowrap text-base-content/70 hover:text-base-content hover:bg-base-200" class="px-4 py-2 rounded-full text-sm font-medium transition-colors whitespace-nowrap text-base-content/70 hover:text-base-content hover:bg-base-200"
:class="{ 'text-primary bg-primary/10': isActive(item.path) }" :class="{ 'text-primary bg-primary/10': isActive(item.path) }"
> >
<Icon v-if="item.icon" :name="item.icon" size="16" class="mr-1.5" />
{{ item.label }} {{ item.label }}
</NuxtLink> </NuxtLink>
</div> </div>
@@ -26,21 +25,21 @@ const { t } = useI18n()
const sectionItems = computed(() => ({ const sectionItems = computed(() => ({
catalog: [ catalog: [
{ label: t('cabinetNav.offers'), path: '/catalog/offers', icon: 'lucide:tag' }, { label: t('cabinetNav.offers'), path: '/catalog/offers' },
{ label: t('cabinetNav.suppliers'), path: '/catalog/suppliers', icon: 'lucide:users' }, { label: t('cabinetNav.suppliers'), path: '/catalog/suppliers' },
{ label: t('cabinetNav.hubs'), path: '/catalog/hubs', icon: 'lucide:warehouse' }, { label: t('cabinetNav.hubs'), path: '/catalog/hubs' },
], ],
orders: [ orders: [
{ label: t('cabinetNav.orders'), path: '/clientarea/orders', icon: 'lucide:package' }, { label: t('cabinetNav.orders'), path: '/clientarea/orders' },
{ label: t('cabinetNav.addresses'), path: '/clientarea/addresses', icon: 'lucide:map-pin' }, { label: t('cabinetNav.addresses'), path: '/clientarea/addresses' },
{ label: t('cabinetNav.billing'), path: '/clientarea/billing', icon: 'lucide:credit-card' }, { label: t('cabinetNav.billing'), path: '/clientarea/billing' },
], ],
seller: [ seller: [
{ label: t('cabinetNav.myOffers'), path: '/clientarea/offers', icon: 'lucide:tag' }, { label: t('cabinetNav.myOffers'), path: '/clientarea/offers' },
], ],
settings: [ settings: [
{ label: t('cabinetNav.profile'), path: '/clientarea/profile', icon: 'lucide:user' }, { label: t('cabinetNav.profile'), path: '/clientarea/profile' },
{ label: t('cabinetNav.team'), path: '/clientarea/team', icon: 'lucide:users' }, { label: t('cabinetNav.team'), path: '/clientarea/team' },
], ],
})) }))

View File

@@ -5,35 +5,20 @@
@submit.prevent="handleSearch" @submit.prevent="handleSearch"
class="flex items-center bg-base-100 rounded-full border border-base-300 shadow-sm hover:shadow-md transition-shadow" class="flex items-center bg-base-100 rounded-full border border-base-300 shadow-sm hover:shadow-md transition-shadow"
> >
<!-- Product field --> <!-- Product field (clickable, navigates to /goods) -->
<div class="flex flex-col px-4 py-2 min-w-32 pl-6 rounded-l-full hover:bg-base-200/50 border-r border-base-300"> <div
class="flex flex-col px-4 py-2 min-w-32 pl-6 rounded-l-full hover:bg-base-200/50 border-r border-base-300 cursor-pointer"
@click="goToProductSelection"
>
<label class="text-xs font-semibold text-base-content/60 mb-0.5"> <label class="text-xs font-semibold text-base-content/60 mb-0.5">
{{ $t('search.product') }} {{ $t('search.product') }}
</label> </label>
<div class="dropdown w-full"> <div class="text-sm" :class="productDisplay ? 'text-base-content' : 'text-base-content/50'">
<input {{ productDisplay || $t('search.product_placeholder') }}
v-model="productQuery"
type="text"
:placeholder="$t('search.product_placeholder')"
class="w-full bg-transparent outline-none text-sm"
@focus="showProductDropdown = true"
@input="filterProducts"
/>
<ul
v-if="showProductDropdown && filteredProducts.length > 0"
class="dropdown-content menu bg-base-100 rounded-box z-50 w-64 max-h-60 overflow-auto p-2 shadow-lg border border-base-300 mt-2"
>
<li v-for="product in filteredProducts" :key="product.uuid">
<a @click="selectProduct(product)">
{{ product.name }}
<span class="text-xs text-base-content/50">{{ product.categoryName }}</span>
</a>
</li>
</ul>
</div> </div>
</div> </div>
<!-- Quantity field --> <!-- Quantity field (editable) -->
<div class="flex flex-col px-4 py-2 min-w-32 hover:bg-base-200/50 border-r border-base-300"> <div class="flex flex-col px-4 py-2 min-w-32 hover:bg-base-200/50 border-r border-base-300">
<label class="text-xs font-semibold text-base-content/60 mb-0.5"> <label class="text-xs font-semibold text-base-content/60 mb-0.5">
{{ $t('search.quantity') }} {{ $t('search.quantity') }}
@@ -45,39 +30,25 @@
min="1" min="1"
:placeholder="$t('search.quantity_placeholder')" :placeholder="$t('search.quantity_placeholder')"
class="w-16 bg-transparent outline-none text-sm" class="w-16 bg-transparent outline-none text-sm"
@change="syncQuantityToStore"
/> />
<select v-model="unit" class="bg-transparent outline-none text-sm text-base-content/70"> <select v-model="unit" class="bg-transparent outline-none text-sm text-base-content/70" @change="syncQuantityToStore">
<option value="t">{{ $t('units.t') }}</option> <option value="t">{{ $t('units.t') }}</option>
<option value="kg">{{ $t('units.kg') }}</option> <option value="kg">{{ $t('units.kg') }}</option>
</select> </select>
</div> </div>
</div> </div>
<!-- Destination field --> <!-- Destination field (clickable, navigates to /select-location) -->
<div class="flex flex-col px-4 py-2 min-w-32 hover:bg-base-200/50"> <div
class="flex flex-col px-4 py-2 min-w-32 hover:bg-base-200/50 cursor-pointer"
@click="goToLocationSelection"
>
<label class="text-xs font-semibold text-base-content/60 mb-0.5"> <label class="text-xs font-semibold text-base-content/60 mb-0.5">
{{ $t('search.destination') }} {{ $t('search.destination') }}
</label> </label>
<div class="dropdown w-full"> <div class="text-sm" :class="locationDisplay ? 'text-base-content' : 'text-base-content/50'">
<input {{ locationDisplay || $t('search.destination_placeholder') }}
v-model="destinationQuery"
type="text"
:placeholder="$t('search.destination_placeholder')"
class="w-full bg-transparent outline-none text-sm"
@focus="showDestinationDropdown = true"
@input="searchDestinations"
/>
<ul
v-if="showDestinationDropdown && filteredDestinations.length > 0"
class="dropdown-content menu bg-base-100 rounded-box z-50 w-64 max-h-60 overflow-auto p-2 shadow-lg border border-base-300 mt-2"
>
<li v-for="dest in filteredDestinations" :key="dest.uuid">
<a @click="selectDestination(dest)">
{{ dest.name }}
<span class="text-xs text-base-content/50">{{ dest.country }}</span>
</a>
</li>
</ul>
</div> </div>
</div> </div>
@@ -96,100 +67,64 @@
<script setup lang="ts"> <script setup lang="ts">
const emit = defineEmits<{ const emit = defineEmits<{
search: [params: { productUuid?: string; quantity?: number; unit?: string; destinationUuid?: string }] search: [params: { productUuid?: string; quantity?: number; unit?: string; locationUuid?: string }]
}>() }>()
const router = useRouter() const router = useRouter()
const localePath = useLocalePath() const localePath = useLocalePath()
const searchStore = useSearchStore() const searchStore = useSearchStore()
const { execute } = useGraphQL()
// Product search // Read from searchStore
const productQuery = ref('') const productDisplay = computed(() => searchStore.searchForm.product || '')
const selectedProduct = ref<{ uuid: string; name: string; categoryName?: string } | null>(null) const productUuid = computed(() => searchStore.searchForm.productUuid || '')
const showProductDropdown = ref(false) const locationDisplay = computed(() => searchStore.searchForm.location || '')
const allProducts = ref<Array<{ uuid: string; name: string; categoryName?: string }>>([]) const locationUuid = computed(() => searchStore.searchForm.locationUuid || '')
const filteredProducts = computed(() => { // Quantity - local state synced with store
if (!productQuery.value) return allProducts.value.slice(0, 10) const quantity = ref<number | undefined>(
const q = productQuery.value.toLowerCase() searchStore.searchForm.quantity ? Number(searchStore.searchForm.quantity) : undefined
return allProducts.value.filter(p => )
p.name.toLowerCase().includes(q) || const unit = ref(searchStore.searchForm.unit || 't')
p.categoryName?.toLowerCase().includes(q)
).slice(0, 10)
})
const filterProducts = () => { const syncQuantityToStore = () => {
showProductDropdown.value = true if (quantity.value) {
searchStore.setQuantity(String(quantity.value))
}
searchStore.setUnit(unit.value)
} }
const selectProduct = (product: typeof selectedProduct.value) => { // Navigation to selection pages
selectedProduct.value = product const goToProductSelection = () => {
productQuery.value = product?.name || '' navigateTo(localePath('/goods'))
showProductDropdown.value = false
// Sync to searchStore
searchStore.setProduct(product?.name || '')
searchStore.setProductUuid(product?.uuid || '')
} }
// Quantity const goToLocationSelection = () => {
const quantity = ref<number | undefined>() navigateTo(localePath('/select-location'))
const unit = ref('t')
// Destination search (using hubs/nodes)
const destinationQuery = ref('')
const selectedDestination = ref<{ uuid: string; name: string; country?: string } | null>(null)
const showDestinationDropdown = ref(false)
const allDestinations = ref<Array<{ uuid: string; name: string; country?: string }>>([])
const filteredDestinations = computed(() => {
if (!destinationQuery.value) return allDestinations.value.slice(0, 10)
const q = destinationQuery.value.toLowerCase()
return allDestinations.value.filter(d =>
d.name?.toLowerCase().includes(q) ||
d.country?.toLowerCase().includes(q)
).slice(0, 10)
})
const searchDestinations = () => {
showDestinationDropdown.value = true
}
const selectDestination = (dest: typeof selectedDestination.value) => {
selectedDestination.value = dest
destinationQuery.value = dest?.name || ''
showDestinationDropdown.value = false
// Sync to searchStore
searchStore.setLocation(dest?.name || '')
searchStore.setLocationUuid(dest?.uuid || '')
} }
// Can search - need at least product selected // Can search - need at least product selected
const canSearch = computed(() => { const canSearch = computed(() => {
return !!selectedProduct.value return !!productUuid.value
}) })
// Search handler - navigate to /request like the old search form // Search handler - navigate to /request
const handleSearch = () => { const handleSearch = () => {
if (!canSearch.value) return if (!canSearch.value) return
// Sync quantity to store // Sync quantity to store
if (quantity.value) { syncQuantityToStore()
searchStore.setQuantity(String(quantity.value))
searchStore.setUnit(unit.value)
}
const query: Record<string, string | undefined> = { const query: Record<string, string | undefined> = {
productUuid: selectedProduct.value?.uuid, productUuid: productUuid.value || undefined,
product: selectedProduct.value?.name, product: productDisplay.value || undefined,
quantity: quantity.value ? String(quantity.value) : undefined, quantity: quantity.value ? String(quantity.value) : undefined,
locationUuid: selectedDestination.value?.uuid, locationUuid: locationUuid.value || undefined,
location: selectedDestination.value?.name location: locationDisplay.value || undefined
} }
// Remove undefined values // Remove undefined/empty values
Object.keys(query).forEach(key => { Object.keys(query).forEach(key => {
if (query[key] === undefined) delete query[key] if (!query[key]) delete query[key]
}) })
router.push({ router.push({
@@ -198,50 +133,23 @@ const handleSearch = () => {
}) })
emit('search', { emit('search', {
productUuid: selectedProduct.value?.uuid, productUuid: productUuid.value,
quantity: quantity.value, quantity: quantity.value,
unit: unit.value, unit: unit.value,
destinationUuid: selectedDestination.value?.uuid locationUuid: locationUuid.value
}) })
} }
// Load products on mount // Watch store changes to sync quantity
onMounted(async () => { watch(() => searchStore.searchForm.quantity, (val) => {
try { if (val) {
const { GetProductsDocument } = await import('~/composables/graphql/public/exchange-generated') quantity.value = Number(val)
const result = await execute(GetProductsDocument, {}, 'public', 'exchange')
allProducts.value = result?.getProducts || []
} catch (error) {
console.error('Failed to load products:', error)
} }
}) }, { immediate: true })
// Load destinations (hubs/nodes) on mount watch(() => searchStore.searchForm.unit, (val) => {
onMounted(async () => { if (val) {
try { unit.value = val
const { GetNodesDocument } = await import('~/composables/graphql/public/geo-generated')
const result = await execute(GetNodesDocument, { limit: 100, offset: 0 }, 'public', 'geo')
allDestinations.value = (result?.nodes || []).filter((n: any) => n?.uuid && n?.name).map((n: any) => ({
uuid: n.uuid,
name: n.name,
country: n.country
}))
} catch (error) {
console.error('Failed to load destinations:', error)
} }
}) }, { immediate: true })
// Close dropdowns on click outside
onMounted(() => {
const handler = (e: MouseEvent) => {
const target = e.target as HTMLElement
if (!target.closest('.dropdown')) {
showProductDropdown.value = false
showDestinationDropdown.value = false
}
}
document.addEventListener('click', handler)
onUnmounted(() => document.removeEventListener('click', handler))
})
</script> </script>

View File

@@ -16,12 +16,12 @@
@switch-team="switchToTeam" @switch-team="switchToTeam"
/> />
<!-- Sub Navigation (section-specific tabs) -->
<SubNavigation :section="currentSection" />
<!-- Global Search Bar --> <!-- Global Search Bar -->
<GlobalSearchBar v-if="showSearch" class="border-b border-base-300" /> <GlobalSearchBar v-if="showSearch" class="border-b border-base-300" />
<!-- Sub Navigation (section-specific tabs) -->
<SubNavigation :section="currentSection" />
<!-- Page content --> <!-- Page content -->
<main class="flex-1 flex flex-col min-h-0 px-3 lg:px-6"> <main class="flex-1 flex flex-col min-h-0 px-3 lg:px-6">
<slot /> <slot />

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="flex flex-col h-[calc(100vh-200px)]"> <div class="flex flex-col flex-1 min-h-0">
<!-- Header --> <!-- Header -->
<div class="py-4"> <div class="py-4">
<PageHeader :title="t('catalogHubsSection.header.title')" /> <PageHeader :title="t('catalogHubsSection.header.title')" />
@@ -15,10 +15,17 @@
</Card> </Card>
</div> </div>
<!-- Split Layout --> <!-- ListMapLayout -->
<div v-else class="flex-1 flex gap-4 min-h-0"> <ListMapLayout
<!-- Left side: Filters + Cards (scrollable) --> v-else
<div class="w-full lg:w-2/5 overflow-y-auto pr-2"> ref="listMapRef"
:items="items"
:selected-item-id="selectedHubId"
map-id="hubs-map"
point-color="#10b981"
@select-item="onSelectHub"
>
<template #list>
<Stack gap="4"> <Stack gap="4">
<CatalogFilters :filters="filters" v-model="selectedFilter" /> <CatalogFilters :filters="filters" v-model="selectedFilter" />
@@ -29,6 +36,8 @@
v-for="hub in country.hubs" v-for="hub in country.hubs"
:key="hub.uuid" :key="hub.uuid"
:hub="hub" :hub="hub"
:class="{ 'ring-2 ring-primary': hub.uuid === selectedHubId }"
@click="onSelectHub(hub.uuid)"
/> />
</Stack> </Stack>
</div> </div>
@@ -45,19 +54,8 @@
<Text tone="muted">{{ t('catalogHubsSection.empty.no_hubs') }}</Text> <Text tone="muted">{{ t('catalogHubsSection.empty.no_hubs') }}</Text>
</Stack> </Stack>
</Stack> </Stack>
</div> </template>
</ListMapLayout>
<!-- Right side: Map (sticky, hidden on mobile) -->
<div class="hidden lg:block lg:w-3/5 rounded-lg overflow-hidden">
<ClientOnly>
<MapboxGlobe
map-id="hubs-map"
:locations="itemsWithCoords"
class="h-full w-full"
/>
</ClientOnly>
</div>
</div>
</div> </div>
</template> </template>
@@ -75,13 +73,20 @@ const {
filters, filters,
isLoading, isLoading,
isLoadingMore, isLoadingMore,
itemsWithCoords,
itemsByCountry, itemsByCountry,
canLoadMore, canLoadMore,
loadMore, loadMore,
init init
} = useCatalogHubs() } = useCatalogHubs()
// Selected hub for map highlighting
const selectedHubId = ref<string>()
const listMapRef = ref<{ flyToItem: (uuid: string) => void } | null>(null)
const onSelectHub = (uuid: string) => {
selectedHubId.value = uuid
}
await init() await init()
useHead(() => ({ useHead(() => ({

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="flex flex-col h-[calc(100vh-200px)]"> <div class="flex flex-col flex-1 min-h-0">
<!-- Header --> <!-- Header -->
<div class="py-4"> <div class="py-4">
<PageHeader :title="pageTitle"> <PageHeader :title="pageTitle">
@@ -46,10 +46,17 @@
</Stack> </Stack>
</div> </div>
<!-- Offers for selected product - Split Layout --> <!-- Offers for selected product - ListMapLayout -->
<div v-else class="flex-1 flex gap-4 min-h-0"> <ListMapLayout
<!-- Left side: Filters + Cards (scrollable) --> v-else
<div class="w-full lg:w-2/5 overflow-y-auto pr-2"> ref="listMapRef"
:items="items"
:selected-item-id="selectedOfferId"
map-id="offers-map"
point-color="#f59e0b"
@select-item="onSelectOffer"
>
<template #list>
<Stack gap="4"> <Stack gap="4">
<CatalogFilters :filters="filters" v-model="selectedFilter" /> <CatalogFilters :filters="filters" v-model="selectedFilter" />
@@ -58,6 +65,8 @@
v-for="offer in items" v-for="offer in items"
:key="offer.uuid" :key="offer.uuid"
:offer="offer" :offer="offer"
:class="{ 'ring-2 ring-primary': offer.uuid === selectedOfferId }"
@click="onSelectOffer(offer.uuid)"
/> />
</Stack> </Stack>
@@ -73,19 +82,8 @@
<Text tone="muted">{{ t('catalogOffersSection.empty.no_offers') }}</Text> <Text tone="muted">{{ t('catalogOffersSection.empty.no_offers') }}</Text>
</Stack> </Stack>
</Stack> </Stack>
</div> </template>
</ListMapLayout>
<!-- Right side: Map (sticky, hidden on mobile) -->
<div class="hidden lg:block lg:w-3/5 rounded-lg overflow-hidden">
<ClientOnly>
<MapboxGlobe
map-id="offers-map"
:locations="itemsWithCoords"
class="h-full w-full"
/>
</ClientOnly>
</div>
</div>
</div> </div>
</template> </template>
@@ -114,7 +112,6 @@ const {
filters, filters,
isLoading, isLoading,
isLoadingMore, isLoadingMore,
itemsWithCoords,
canLoadMore, canLoadMore,
loadMore, loadMore,
init: initOffers, init: initOffers,
@@ -144,6 +141,15 @@ const selectProduct = (product: any) => {
}) })
} }
// Selected offer for map highlighting
const selectedOfferId = ref<string>()
const listMapRef = ref<{ flyToItem: (uuid: string) => void } | null>(null)
const onSelectOffer = (uuid: string) => {
selectedOfferId.value = uuid
// flyToItem will be triggered by ListMapLayout watch
}
// Initialize // Initialize
await initProducts() await initProducts()

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="flex flex-col h-[calc(100vh-200px)]"> <div class="flex flex-col flex-1 min-h-0">
<!-- Header --> <!-- Header -->
<div class="py-4"> <div class="py-4">
<PageHeader :title="t('catalogSuppliersSection.header.title')" /> <PageHeader :title="t('catalogSuppliersSection.header.title')" />
@@ -15,10 +15,17 @@
</Card> </Card>
</div> </div>
<!-- Split Layout --> <!-- ListMapLayout -->
<div v-else class="flex-1 flex gap-4 min-h-0"> <ListMapLayout
<!-- Left side: Filters + Cards (scrollable) --> v-else
<div class="w-full lg:w-2/5 overflow-y-auto pr-2"> ref="listMapRef"
:items="items"
:selected-item-id="selectedSupplierId"
map-id="suppliers-map"
point-color="#3b82f6"
@select-item="onSelectSupplier"
>
<template #list>
<Stack gap="4"> <Stack gap="4">
<CatalogFilters :filters="filters" v-model="selectedFilter" /> <CatalogFilters :filters="filters" v-model="selectedFilter" />
@@ -27,6 +34,8 @@
v-for="supplier in items" v-for="supplier in items"
:key="supplier.uuid || supplier.teamUuid" :key="supplier.uuid || supplier.teamUuid"
:supplier="supplier" :supplier="supplier"
:class="{ 'ring-2 ring-primary': (supplier.uuid || supplier.teamUuid) === selectedSupplierId }"
@click="onSelectSupplier(supplier.uuid || supplier.teamUuid)"
/> />
</Stack> </Stack>
@@ -42,19 +51,8 @@
<Text tone="muted">{{ t('catalogSuppliersSection.empty.no_suppliers') }}</Text> <Text tone="muted">{{ t('catalogSuppliersSection.empty.no_suppliers') }}</Text>
</Stack> </Stack>
</Stack> </Stack>
</div> </template>
</ListMapLayout>
<!-- Right side: Map (sticky, hidden on mobile) -->
<div class="hidden lg:block lg:w-3/5 rounded-lg overflow-hidden">
<ClientOnly>
<MapboxGlobe
map-id="suppliers-map"
:locations="itemsWithCoords"
class="h-full w-full"
/>
</ClientOnly>
</div>
</div>
</div> </div>
</template> </template>
@@ -72,12 +70,19 @@ const {
filters, filters,
isLoading, isLoading,
isLoadingMore, isLoadingMore,
itemsWithCoords,
canLoadMore, canLoadMore,
loadMore, loadMore,
init init
} = useCatalogSuppliers() } = useCatalogSuppliers()
// Selected supplier for map highlighting
const selectedSupplierId = ref<string>()
const listMapRef = ref<{ flyToItem: (uuid: string) => void } | null>(null)
const onSelectSupplier = (uuid: string) => {
selectedSupplierId.value = uuid
}
await init() await init()
useHead(() => ({ useHead(() => ({