Update catalog pages to use new geo queries
Some checks failed
Build Docker Image / build (push) Failing after 1m35s
Some checks failed
Build Docker Image / build (push) Failing after 1m35s
- Replace FindProductRoutesDocument with GetOffersToHubDocument - Replace FindSupplierProductHubsDocument with GetOffersBySupplierProductDocument + GetHubsNearOfferDocument - Update all catalog pages to use new query naming convention - Add new GraphQL operation files, remove deprecated ones
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { GetNodeConnectionsDocument, FindProductRoutesDocument } from '~/composables/graphql/public/geo-generated'
|
||||
import { GetNodeConnectionsDocument, GetOffersToHubDocument } from '~/composables/graphql/public/geo-generated'
|
||||
import { GetAvailableProductsDocument, GetOfferDocument } from '~/composables/graphql/public/exchange-generated'
|
||||
|
||||
definePageMeta({
|
||||
@@ -225,7 +225,7 @@ const loadOfferDetails = async () => {
|
||||
offersData.value = newOffersData
|
||||
}
|
||||
|
||||
// Load routes
|
||||
// Load offers with routes to this hub
|
||||
const loadRoutes = async () => {
|
||||
if (!productId.value || !hubId.value) {
|
||||
rawSources.value = []
|
||||
@@ -238,20 +238,19 @@ const loadRoutes = async () => {
|
||||
|
||||
try {
|
||||
const data = await execute(
|
||||
FindProductRoutesDocument,
|
||||
GetOffersToHubDocument,
|
||||
{
|
||||
hubUuid: hubId.value,
|
||||
productUuid: productId.value,
|
||||
toUuid: hubId.value,
|
||||
limitSources: 12,
|
||||
limitRoutes: 1
|
||||
limit: 12
|
||||
},
|
||||
'public',
|
||||
'geo'
|
||||
)
|
||||
rawSources.value = (data?.findProductRoutes || []).filter(Boolean)
|
||||
rawSources.value = (data?.offersToHub || []).filter(Boolean)
|
||||
await loadOfferDetails()
|
||||
} catch (error) {
|
||||
console.error('Error loading routes:', error)
|
||||
console.error('Error loading offers:', error)
|
||||
rawSources.value = []
|
||||
} finally {
|
||||
isLoadingRoutes.value = false
|
||||
|
||||
@@ -62,8 +62,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { GetNodeConnectionsDocument, FindProductsForHubDocument } from '~/composables/graphql/public/geo-generated'
|
||||
import { GetAvailableProductsDocument } from '~/composables/graphql/public/exchange-generated'
|
||||
import { GetNodeConnectionsDocument, GetProductsNearHubDocument } from '~/composables/graphql/public/geo-generated'
|
||||
|
||||
definePageMeta({
|
||||
layout: 'topnav'
|
||||
@@ -119,19 +118,17 @@ const getMockPriceHistory = (uuid: string): number[] => {
|
||||
|
||||
// Initial load
|
||||
try {
|
||||
const [{ data: connectionsData }, { data: productUuidsData }, { data: allProductsData }] = await Promise.all([
|
||||
const [{ data: connectionsData }, { data: productsData }] = 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')
|
||||
useServerQuery('products-near-hub', GetProductsNearHubDocument, { hubUuid: hubId.value, radiusKm: 500 }, 'public', 'geo')
|
||||
])
|
||||
|
||||
hub.value = connectionsData.value?.nodeConnections?.hub || null
|
||||
|
||||
// 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! }))
|
||||
// Get products near this hub (from geo)
|
||||
products.value = (productsData.value?.productsNearHub || [])
|
||||
.filter((p): p is { uuid: string; name?: string | null } => p !== null && !!p.uuid)
|
||||
.map(p => ({ uuid: p.uuid!, name: p.name || '' }))
|
||||
} catch (error) {
|
||||
console.error('Error loading hub:', error)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user