feat: use filtered geo queries for catalog pages
All checks were successful
Build Docker Image / build (push) Successful in 4m57s
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:
@@ -58,7 +58,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { GetNodeConnectionsDocument } from '~/composables/graphql/public/geo-generated'
|
||||
import { GetNodeConnectionsDocument, FindProductsForHubDocument } from '~/composables/graphql/public/geo-generated'
|
||||
import { GetAvailableProductsDocument } from '~/composables/graphql/public/exchange-generated'
|
||||
|
||||
definePageMeta({
|
||||
@@ -92,14 +92,18 @@ const getMockPriceHistory = (uuid: string): number[] => {
|
||||
|
||||
// Initial load
|
||||
try {
|
||||
const [{ data: connectionsData }, { data: productsData }] = await Promise.all([
|
||||
const [{ data: connectionsData }, { data: productUuidsData }, { data: allProductsData }] = await Promise.all([
|
||||
useServerQuery('hub-connections', GetNodeConnectionsDocument, { uuid: hubId.value }, 'public', 'geo'),
|
||||
useServerQuery('hub-product-uuids', FindProductsForHubDocument, { hubUuid: hubId.value }, 'public', 'geo'),
|
||||
useServerQuery('available-products', GetAvailableProductsDocument, {}, 'public', 'exchange')
|
||||
])
|
||||
|
||||
hub.value = connectionsData.value?.nodeConnections?.hub || null
|
||||
products.value = (productsData.value?.getAvailableProducts || [])
|
||||
.filter((p): p is { uuid: string; name: string } => p !== null && !!p.uuid && !!p.name)
|
||||
|
||||
// Filter products by UUIDs that can be delivered to this hub
|
||||
const relevantUuids = new Set(productUuidsData.value?.findProductsForHub?.filter(Boolean) || [])
|
||||
products.value = (allProductsData.value?.getAvailableProducts || [])
|
||||
.filter((p): p is { uuid: string; name: string } => p !== null && !!p.uuid && !!p.name && relevantUuids.has(p.uuid))
|
||||
.map(p => ({ uuid: p.uuid!, name: p.name! }))
|
||||
} catch (error) {
|
||||
console.error('Error loading hub:', error)
|
||||
|
||||
Reference in New Issue
Block a user