Update catalog pages to use new geo queries
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:
Ruslan Bakiev
2026-01-16 15:40:06 +07:00
parent e869c2065f
commit 2253cd20b0
19 changed files with 232 additions and 188 deletions

View File

@@ -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

View File

@@ -77,8 +77,7 @@
</template>
<script setup lang="ts">
import { GetAvailableProductsDocument } from '~/composables/graphql/public/exchange-generated'
import { FindHubsForProductDocument } from '~/composables/graphql/public/geo-generated'
import { GetOffersByProductDocument, GetHubsNearOfferDocument } from '~/composables/graphql/public/geo-generated'
definePageMeta({
layout: 'topnav'
@@ -155,29 +154,46 @@ const chartSeries = computed(() => [{
// Initial load
try {
const [{ data: productsData }, { data: hubsData }] = await Promise.all([
useServerQuery('product-info', GetAvailableProductsDocument, {}, 'public', 'exchange'),
useServerQuery('hubs-for-product', FindHubsForProductDocument, { productUuid: productId.value }, 'public', 'geo')
])
// Get offers for this product from geo
const { data: offersData } = await useServerQuery(
'offers-for-product',
GetOffersByProductDocument,
{ productUuid: productId.value },
'public',
'geo'
)
const foundProduct = (productsData.value?.getAvailableProducts || [])
.find(p => p?.uuid === productId.value)
const offers = offersData.value?.offersByProduct || []
if (foundProduct) {
product.value = { uuid: foundProduct.uuid!, name: foundProduct.name || '' }
if (offers.length > 0) {
const firstOffer = offers[0]
product.value = {
uuid: productId.value,
name: firstOffer?.productName || ''
}
// Get hubs near the first offer's location
if (firstOffer?.uuid) {
const { data: hubsData } = await useServerQuery(
'hubs-near-offer',
GetHubsNearOfferDocument,
{ offerUuid: firstOffer.uuid, limit: 12 },
'public',
'geo'
)
hubs.value = (hubsData.value?.hubsNearOffer || [])
.filter((h): h is NonNullable<typeof h> => h !== null && !!h.uuid && !!h.name)
.map(h => ({
uuid: h.uuid!,
name: h.name!,
latitude: h.latitude ?? undefined,
longitude: h.longitude ?? undefined,
country: h.country || undefined,
countryCode: h.countryCode || undefined
}))
}
}
// Get only hubs where this product can be delivered
hubs.value = (hubsData.value?.findHubsForProduct || [])
.filter((h): h is NonNullable<typeof h> => h !== null && !!h.uuid && !!h.name)
.map(h => ({
uuid: h.uuid!,
name: h.name!,
latitude: h.latitude ?? undefined,
longitude: h.longitude ?? undefined,
country: h.country || undefined,
countryCode: h.countryCode || undefined
}))
} catch (error) {
console.error('Error loading product hubs:', error)
} finally {