Files
webapp/app/composables/useCatalogProducts.ts
Ruslan Bakiev 404375248b
All checks were successful
Build Docker Image / build (push) Successful in 3m37s
Fix catalog UI: navbar alignment, selection panel, map search, infinite scroll
- 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
2026-01-24 10:09:55 +07:00

53 lines
1.1 KiB
TypeScript

import { GetProductsDocument } from '~/composables/graphql/public/geo-generated'
// Shared state
const items = ref<any[]>([])
const isLoading = ref(false)
const isLoadingMore = ref(false)
const isInitialized = ref(false)
export function useCatalogProducts() {
const { execute } = useGraphQL()
// Products don't have server-side pagination yet, so we load all at once
const canLoadMore = computed(() => false)
const fetchProducts = async () => {
if (isLoading.value) return
isLoading.value = true
try {
const data = await execute(
GetProductsDocument,
{},
'public',
'geo'
)
items.value = data?.products || []
isInitialized.value = true
} finally {
isLoading.value = false
}
}
const loadMore = async () => {
// No-op: products don't support pagination yet
}
const init = async () => {
if (!isInitialized.value && items.value.length === 0) {
await fetchProducts()
}
}
return {
items,
isLoading,
isLoadingMore,
isInitialized,
canLoadMore,
fetchProducts,
loadMore,
init
}
}