Fix catalog UI: navbar alignment, selection panel, map search, infinite scroll
All checks were successful
Build Docker Image / build (push) Successful in 3m37s
All checks were successful
Build Docker Image / build (push) Successful in 3m37s
- Fix team selector alignment in navbar (use items-center, fixed height) - Fix SelectionPanel header padding to account for parent p-4 - Add map search input (white glass, positioned next to panel) - Add infinite scroll to SelectionPanel with IntersectionObserver - Products load all at once (no server-side pagination yet) - Hubs and Suppliers support pagination with loadMore
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col h-full">
|
<div class="flex flex-col h-full -m-4">
|
||||||
<!-- Header + Search (white glass, sticky) -->
|
<!-- Header + Search (white glass, sticky) -->
|
||||||
<div class="sticky top-0 z-10 -m-4 mb-0 p-3 rounded-t-xl bg-white/90 backdrop-blur-md border-b border-white/20">
|
<div class="sticky top-0 z-10 p-4 rounded-t-xl bg-white/90 backdrop-blur-md border-b border-white/20">
|
||||||
<div class="flex items-center justify-between mb-2">
|
<div class="flex items-center justify-between mb-2">
|
||||||
<h3 class="font-semibold text-base text-base-content">{{ title }}</h3>
|
<h3 class="font-semibold text-base text-base-content">{{ title }}</h3>
|
||||||
<button class="btn btn-ghost btn-xs btn-circle text-base-content/60 hover:text-base-content" @click="emit('close')">
|
<button class="btn btn-ghost btn-xs btn-circle text-base-content/60 hover:text-base-content" @click="emit('close')">
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- List -->
|
<!-- List -->
|
||||||
<div class="flex-1 pt-3">
|
<div class="flex-1 px-4 pt-3 pb-4 overflow-y-auto">
|
||||||
<div v-if="loading" class="flex items-center justify-center py-8">
|
<div v-if="loading" class="flex items-center justify-center py-8">
|
||||||
<span class="loading loading-spinner loading-md" />
|
<span class="loading loading-spinner loading-md" />
|
||||||
</div>
|
</div>
|
||||||
@@ -64,6 +64,15 @@
|
|||||||
@select="onSelect(item)"
|
@select="onSelect(item)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- Infinite scroll sentinel -->
|
||||||
|
<div
|
||||||
|
v-if="hasMore && !searchQuery"
|
||||||
|
ref="loadMoreSentinel"
|
||||||
|
class="flex items-center justify-center py-4"
|
||||||
|
>
|
||||||
|
<span v-if="loadingMore" class="loading loading-spinner loading-sm text-base-content/60" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -85,16 +94,48 @@ const props = defineProps<{
|
|||||||
suppliers?: Item[]
|
suppliers?: Item[]
|
||||||
selectedId?: string
|
selectedId?: string
|
||||||
loading?: boolean
|
loading?: boolean
|
||||||
|
loadingMore?: boolean
|
||||||
|
hasMore?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
'select': [type: string, item: Item]
|
'select': [type: string, item: Item]
|
||||||
'close': []
|
'close': []
|
||||||
|
'load-more': []
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const searchQuery = ref('')
|
const searchQuery = ref('')
|
||||||
|
const loadMoreSentinel = ref<HTMLElement | null>(null)
|
||||||
|
|
||||||
|
// Infinite scroll using IntersectionObserver
|
||||||
|
let observer: IntersectionObserver | null = null
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
observer = new IntersectionObserver(
|
||||||
|
(entries) => {
|
||||||
|
const entry = entries[0]
|
||||||
|
if (entry?.isIntersecting && props.hasMore && !props.loadingMore && !searchQuery.value) {
|
||||||
|
emit('load-more')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ threshold: 0.1 }
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(loadMoreSentinel, (el) => {
|
||||||
|
if (el && observer) {
|
||||||
|
observer.observe(el)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (observer) {
|
||||||
|
observer.disconnect()
|
||||||
|
observer = null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const title = computed(() => {
|
const title = computed(() => {
|
||||||
switch (props.selectMode) {
|
switch (props.selectMode) {
|
||||||
|
|||||||
@@ -143,8 +143,8 @@
|
|||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Right: AI + Globe + Team + User (top aligned) -->
|
<!-- Right: AI + Globe + Team + User (centered vertically) -->
|
||||||
<div class="flex items-start gap-1 flex-shrink-0 pt-3">
|
<div class="flex items-center gap-1 flex-shrink-0">
|
||||||
<!-- AI Assistant button -->
|
<!-- AI Assistant button -->
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
:to="localePath('/clientarea/ai')"
|
:to="localePath('/clientarea/ai')"
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
<div class="dropdown dropdown-end">
|
<div class="dropdown dropdown-end">
|
||||||
<button
|
<button
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
class="flex items-center gap-1 px-2 py-1 rounded-lg transition-colors"
|
class="h-8 flex items-center gap-1 px-2 rounded-lg transition-colors"
|
||||||
:class="glassStyle ? 'text-white/70 hover:text-white hover:bg-white/10' : 'text-base-content/70 hover:text-base-content hover:bg-base-200'"
|
:class="glassStyle ? 'text-white/70 hover:text-white hover:bg-white/10' : 'text-base-content/70 hover:text-base-content hover:bg-base-200'"
|
||||||
>
|
>
|
||||||
<Icon name="lucide:building-2" size="16" />
|
<Icon name="lucide:building-2" size="16" />
|
||||||
|
|||||||
@@ -38,6 +38,29 @@
|
|||||||
<span class="text-white text-sm">{{ $t('common.loading') }}</span>
|
<span class="text-white text-sm">{{ $t('common.loading') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Map search input (top LEFT, next to panel or at left edge) -->
|
||||||
|
<div
|
||||||
|
class="absolute top-[116px] z-20 hidden lg:block"
|
||||||
|
:class="showPanel ? 'left-[420px]' : 'left-4'"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2 bg-white/80 backdrop-blur-md rounded-full shadow-lg border border-white/40 px-4 py-2 w-64">
|
||||||
|
<Icon name="lucide:search" size="18" class="text-base-content/60 flex-shrink-0" />
|
||||||
|
<input
|
||||||
|
v-model="mapSearchQuery"
|
||||||
|
type="text"
|
||||||
|
:placeholder="$t('catalog.search.searchOnMap')"
|
||||||
|
class="flex-1 bg-transparent outline-none text-sm text-base-content placeholder:text-base-content/50"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
v-if="mapSearchQuery"
|
||||||
|
class="text-base-content/40 hover:text-base-content transition-colors"
|
||||||
|
@click="mapSearchQuery = ''"
|
||||||
|
>
|
||||||
|
<Icon name="lucide:x" size="16" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- View toggle (top RIGHT overlay, below header) - works in both modes -->
|
<!-- View toggle (top RIGHT overlay, below header) - works in both modes -->
|
||||||
<div class="absolute top-[116px] right-4 z-20 hidden lg:block">
|
<div class="absolute top-[116px] right-4 z-20 hidden lg:block">
|
||||||
<div class="flex gap-1 bg-black/30 backdrop-blur-md rounded-lg p-1 border border-white/10">
|
<div class="flex gap-1 bg-black/30 backdrop-blur-md rounded-lg p-1 border border-white/10">
|
||||||
@@ -229,6 +252,9 @@ const mapRef = ref<{ flyTo: (lat: number, lng: number, zoom?: number) => void }
|
|||||||
// Selected item from map click
|
// Selected item from map click
|
||||||
const selectedMapItem = ref<MapItem | null>(null)
|
const selectedMapItem = ref<MapItem | null>(null)
|
||||||
|
|
||||||
|
// Map search query
|
||||||
|
const mapSearchQuery = ref('')
|
||||||
|
|
||||||
// Mobile panel state
|
// Mobile panel state
|
||||||
const mobilePanelExpanded = ref(false)
|
const mobilePanelExpanded = ref(false)
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,15 @@ import { GetProductsDocument } from '~/composables/graphql/public/geo-generated'
|
|||||||
// Shared state
|
// Shared state
|
||||||
const items = ref<any[]>([])
|
const items = ref<any[]>([])
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
|
const isLoadingMore = ref(false)
|
||||||
const isInitialized = ref(false)
|
const isInitialized = ref(false)
|
||||||
|
|
||||||
export function useCatalogProducts() {
|
export function useCatalogProducts() {
|
||||||
const { execute } = useGraphQL()
|
const { execute } = useGraphQL()
|
||||||
|
|
||||||
|
// Products don't have server-side pagination yet, so we load all at once
|
||||||
|
const canLoadMore = computed(() => false)
|
||||||
|
|
||||||
const fetchProducts = async () => {
|
const fetchProducts = async () => {
|
||||||
if (isLoading.value) return
|
if (isLoading.value) return
|
||||||
isLoading.value = true
|
isLoading.value = true
|
||||||
@@ -25,6 +29,10 @@ export function useCatalogProducts() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const loadMore = async () => {
|
||||||
|
// No-op: products don't support pagination yet
|
||||||
|
}
|
||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
if (!isInitialized.value && items.value.length === 0) {
|
if (!isInitialized.value && items.value.length === 0) {
|
||||||
await fetchProducts()
|
await fetchProducts()
|
||||||
@@ -34,8 +42,11 @@ export function useCatalogProducts() {
|
|||||||
return {
|
return {
|
||||||
items,
|
items,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
isLoadingMore,
|
||||||
isInitialized,
|
isInitialized,
|
||||||
|
canLoadMore,
|
||||||
fetchProducts,
|
fetchProducts,
|
||||||
|
loadMore,
|
||||||
init
|
init
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,11 @@
|
|||||||
:hubs="hubs"
|
:hubs="hubs"
|
||||||
:suppliers="suppliers"
|
:suppliers="suppliers"
|
||||||
:loading="selectionLoading"
|
:loading="selectionLoading"
|
||||||
|
:loading-more="selectionLoadingMore"
|
||||||
|
:has-more="selectionHasMore"
|
||||||
@select="onSelectItem"
|
@select="onSelectItem"
|
||||||
@close="cancelSelect"
|
@close="cancelSelect"
|
||||||
|
@load-more="onLoadMore"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- Quote results: show offers after search -->
|
<!-- Quote results: show offers after search -->
|
||||||
@@ -62,9 +65,9 @@ const {
|
|||||||
} = useCatalogSearch()
|
} = useCatalogSearch()
|
||||||
|
|
||||||
// Composables for data (initialize immediately when selectMode changes)
|
// Composables for data (initialize immediately when selectMode changes)
|
||||||
const { items: products, isLoading: productsLoading, init: initProducts } = useCatalogProducts()
|
const { items: products, isLoading: productsLoading, isLoadingMore: productsLoadingMore, canLoadMore: productsCanLoadMore, loadMore: loadMoreProducts, init: initProducts } = useCatalogProducts()
|
||||||
const { items: hubs, isLoading: hubsLoading, init: initHubs } = useCatalogHubs()
|
const { items: hubs, isLoading: hubsLoading, isLoadingMore: hubsLoadingMore, canLoadMore: hubsCanLoadMore, loadMore: loadMoreHubs, init: initHubs } = useCatalogHubs()
|
||||||
const { items: suppliers, isLoading: suppliersLoading, init: initSuppliers } = useCatalogSuppliers()
|
const { items: suppliers, isLoading: suppliersLoading, isLoadingMore: suppliersLoadingMore, canLoadMore: suppliersCanLoadMore, loadMore: loadMoreSuppliers, init: initSuppliers } = useCatalogSuppliers()
|
||||||
|
|
||||||
// Selection loading state
|
// Selection loading state
|
||||||
const selectionLoading = computed(() => {
|
const selectionLoading = computed(() => {
|
||||||
@@ -74,6 +77,29 @@ const selectionLoading = computed(() => {
|
|||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Selection loading more state
|
||||||
|
const selectionLoadingMore = computed(() => {
|
||||||
|
if (selectMode.value === 'product') return productsLoadingMore.value
|
||||||
|
if (selectMode.value === 'hub') return hubsLoadingMore.value
|
||||||
|
if (selectMode.value === 'supplier') return suppliersLoadingMore.value
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
// Selection has more state
|
||||||
|
const selectionHasMore = computed(() => {
|
||||||
|
if (selectMode.value === 'product') return productsCanLoadMore.value
|
||||||
|
if (selectMode.value === 'hub') return hubsCanLoadMore.value
|
||||||
|
if (selectMode.value === 'supplier') return suppliersCanLoadMore.value
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
// Load more handler
|
||||||
|
const onLoadMore = () => {
|
||||||
|
if (selectMode.value === 'product') loadMoreProducts()
|
||||||
|
if (selectMode.value === 'hub') loadMoreHubs()
|
||||||
|
if (selectMode.value === 'supplier') loadMoreSuppliers()
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize data and sync map view when selectMode changes
|
// Initialize data and sync map view when selectMode changes
|
||||||
watch(selectMode, async (mode) => {
|
watch(selectMode, async (mode) => {
|
||||||
if (mode === 'product') {
|
if (mode === 'product') {
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
"refine": "Refine...",
|
"refine": "Refine...",
|
||||||
"searchProducts": "Search products...",
|
"searchProducts": "Search products...",
|
||||||
"searchSuppliers": "Search suppliers...",
|
"searchSuppliers": "Search suppliers...",
|
||||||
"searchHubs": "Search hubs..."
|
"searchHubs": "Search hubs...",
|
||||||
|
"searchOnMap": "Search on map..."
|
||||||
},
|
},
|
||||||
"hero": {
|
"hero": {
|
||||||
"title": "Find the best offer",
|
"title": "Find the best offer",
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
"refine": "Уточнить...",
|
"refine": "Уточнить...",
|
||||||
"searchProducts": "Поиск товаров...",
|
"searchProducts": "Поиск товаров...",
|
||||||
"searchSuppliers": "Поиск поставщиков...",
|
"searchSuppliers": "Поиск поставщиков...",
|
||||||
"searchHubs": "Поиск хабов..."
|
"searchHubs": "Поиск хабов...",
|
||||||
|
"searchOnMap": "Поиск на карте..."
|
||||||
},
|
},
|
||||||
"hero": {
|
"hero": {
|
||||||
"title": "Найдите лучшее предложение",
|
"title": "Найдите лучшее предложение",
|
||||||
|
|||||||
Reference in New Issue
Block a user