diff --git a/app/composables/useCatalogHubs.ts b/app/composables/useCatalogHubs.ts index e98a8b5..486285a 100644 --- a/app/composables/useCatalogHubs.ts +++ b/app/composables/useCatalogHubs.ts @@ -84,7 +84,13 @@ export function useCatalogHubs() { limit: PAGE_SIZE, offset, transportType, - country + country, + ...(filterBounds.value && { + west: filterBounds.value.west, + south: filterBounds.value.south, + east: filterBounds.value.east, + north: filterBounds.value.north + }) }, 'public', 'geo' diff --git a/app/composables/useCatalogProducts.ts b/app/composables/useCatalogProducts.ts index b264e09..65087ec 100644 --- a/app/composables/useCatalogProducts.ts +++ b/app/composables/useCatalogProducts.ts @@ -16,6 +16,7 @@ const isInitialized = ref(false) // Filter state const filterSupplierUuid = ref(null) const filterHubUuid = ref(null) +const filterBounds = ref<{ west: number; south: number; east: number; north: number } | null>(null) export function useCatalogProducts() { const { execute } = useGraphQL() @@ -117,7 +118,15 @@ export function useCatalogProducts() { // All products from graph data = await execute( ProductsListDocument, - { limit: 500 }, + { + limit: 500, + ...(filterBounds.value && { + west: filterBounds.value.west, + south: filterBounds.value.south, + east: filterBounds.value.east, + north: filterBounds.value.north + }) + }, 'public', 'geo' ) @@ -168,11 +177,12 @@ export function useCatalogProducts() { } } - // Products don't have coordinates directly (they're an aggregation of offers) - // Bounds filtering would require a new backend query that filters by offer locations - // For now, this is a no-op - products show all regardless of map bounds - const setBoundsFilter = (_bounds: { west: number; south: number; east: number; north: number } | null) => { - // No-op: products are not filterable by map bounds in current implementation + // Products are filtered by offer locations within bounds + const setBoundsFilter = (bounds: { west: number; south: number; east: number; north: number } | null) => { + filterBounds.value = bounds + if (isInitialized.value) { + fetchProducts() + } } return { diff --git a/app/composables/useCatalogSuppliers.ts b/app/composables/useCatalogSuppliers.ts index c228c6e..56a4165 100644 --- a/app/composables/useCatalogSuppliers.ts +++ b/app/composables/useCatalogSuppliers.ts @@ -47,7 +47,16 @@ export function useCatalogSuppliers() { // Default: fetch all suppliers from GEO (graph-based) const data = await execute( SuppliersListDocument, - { limit: PAGE_SIZE, offset }, + { + limit: PAGE_SIZE, + offset, + ...(filterBounds.value && { + west: filterBounds.value.west, + south: filterBounds.value.south, + east: filterBounds.value.east, + north: filterBounds.value.north + }) + }, 'public', 'geo' ) diff --git a/graphql/operations/public/geo/HubsList.graphql b/graphql/operations/public/geo/HubsList.graphql index bcb1cec..d174a47 100644 --- a/graphql/operations/public/geo/HubsList.graphql +++ b/graphql/operations/public/geo/HubsList.graphql @@ -1,5 +1,5 @@ -query HubsList($limit: Int, $offset: Int, $country: String, $transportType: String) { - hubsList(limit: $limit, offset: $offset, country: $country, transportType: $transportType) { +query HubsList($limit: Int, $offset: Int, $country: String, $transportType: String, $west: Float, $south: Float, $east: Float, $north: Float) { + hubsList(limit: $limit, offset: $offset, country: $country, transportType: $transportType, west: $west, south: $south, east: $east, north: $north) { uuid name latitude diff --git a/graphql/operations/public/geo/ProductsList.graphql b/graphql/operations/public/geo/ProductsList.graphql index f2bb4d2..7e52851 100644 --- a/graphql/operations/public/geo/ProductsList.graphql +++ b/graphql/operations/public/geo/ProductsList.graphql @@ -1,5 +1,5 @@ -query ProductsList($limit: Int, $offset: Int) { - productsList(limit: $limit, offset: $offset) { +query ProductsList($limit: Int, $offset: Int, $west: Float, $south: Float, $east: Float, $north: Float) { + productsList(limit: $limit, offset: $offset, west: $west, south: $south, east: $east, north: $north) { uuid name offersCount diff --git a/graphql/operations/public/geo/SuppliersList.graphql b/graphql/operations/public/geo/SuppliersList.graphql index 731ab7e..3fe74fb 100644 --- a/graphql/operations/public/geo/SuppliersList.graphql +++ b/graphql/operations/public/geo/SuppliersList.graphql @@ -1,5 +1,5 @@ -query SuppliersList($limit: Int, $offset: Int, $country: String) { - suppliersList(limit: $limit, offset: $offset, country: $country) { +query SuppliersList($limit: Int, $offset: Int, $country: String, $west: Float, $south: Float, $east: Float, $north: Float) { + suppliersList(limit: $limit, offset: $offset, country: $country, west: $west, south: $south, east: $east, north: $north) { uuid name latitude