feat: use filtered geo queries for catalog pages
All checks were successful
Build Docker Image / build (push) Successful in 4m57s

- /hubs/[id]: use findProductsForHub to show only deliverable products
- /offers/[productId]: use findHubsForProduct to show only reachable hubs
- /suppliers/[id]/[productId]: use findSupplierProductHubs for supplier-specific hubs
- Add new GraphQL operations for geo queries
This commit is contained in:
Ruslan Bakiev
2026-01-16 01:42:18 +07:00
parent 1e87a14065
commit 181dc4ea6b
8 changed files with 154 additions and 21 deletions

View File

@@ -86,7 +86,7 @@
</template>
<script setup lang="ts">
import { GetNodesDocument } from '~/composables/graphql/public/geo-generated'
import { FindSupplierProductHubsDocument } from '~/composables/graphql/public/geo-generated'
import {
GetSupplierProfileDocument,
GetSupplierOffersDocument,
@@ -215,20 +215,23 @@ try {
}
}
// Get hubs (destinations)
const { data: hubsData } = await useServerQuery(
'all-hubs',
GetNodesDocument,
{ limit: 100 },
'public',
'geo'
)
hubs.value = (hubsData.value?.nodes || [])
.filter((h): h is { uuid: string; name: string; country?: string; countryCode?: string } =>
h !== null && !!h.uuid && !!h.name
// Get hubs where this supplier can deliver this product
if (supplier.value && product.value) {
const supplierUuidForGeo = supplier.value?.teamUuid || supplier.value?.uuid || supplierId.value
const { data: hubsData } = await useServerQuery(
'supplier-product-hubs',
FindSupplierProductHubsDocument,
{ supplierUuid: supplierUuidForGeo, productUuid: productId.value },
'public',
'geo'
)
.map(h => ({ uuid: h.uuid!, name: h.name!, country: h.country || undefined, countryCode: h.countryCode || undefined }))
hubs.value = (hubsData.value?.findSupplierProductHubs || [])
.filter((h): h is { uuid: string; name: string; country?: string; countryCode?: string } =>
h !== null && !!h.uuid && !!h.name
)
.map(h => ({ uuid: h.uuid!, name: h.name!, country: h.country || undefined, countryCode: h.countryCode || undefined }))
}
} catch (error) {
console.error('Error loading data:', error)
} finally {