Simplify GEO API - use new list endpoints and routes in nearestOffers
All checks were successful
Build Docker Image / build (push) Successful in 4m11s

- Replace GetNodesDocument with HubsListDocument in useCatalogHubs.ts
- Replace GetSupplierProfilesDocument with SuppliersListDocument in useCatalogSuppliers.ts
- Replace manual grouping with ProductsListDocument in useCatalogProducts.ts
- Update nearestOffers to pass hubUuid for server-side route calculation
- Remove RouteToCoordinate calls - routes now included in nearestOffers response
- Delete 15 obsolete GraphQL files
- Add 3 new list endpoints: HubsList, SuppliersList, ProductsList
- Fix TypeScript errors in CalcResultContent, LocationsContent, hubs page, location store
This commit is contained in:
Ruslan Bakiev
2026-01-26 14:08:21 +07:00
parent 6d916d65a0
commit 65b07271d9
28 changed files with 190 additions and 504 deletions

View File

@@ -2,8 +2,7 @@ import type { InfoEntityType } from './useCatalogSearch'
import {
GetNodeDocument,
NearestOffersDocument,
NearestHubsDocument,
RouteToCoordinateDocument
NearestHubsDocument
} from '~/composables/graphql/public/geo-generated'
import {
GetOfferDocument,
@@ -205,13 +204,14 @@ export function useCatalogInfo() {
return
}
// 1. Find offers near hub for this product
// Find offers near hub for this product WITH routes calculated on backend
const offersData = await execute(
NearestOffersDocument,
{
lat: hub.latitude,
lon: hub.longitude,
productUuid,
hubUuid, // Pass hubUuid to get routes calculated on backend
radius: 500,
limit: 12
},
@@ -219,51 +219,12 @@ export function useCatalogInfo() {
'geo'
)
const offers = offersData?.nearestOffers || []
// 2. For each offer, get route to hub
const offersWithRoutes = await Promise.all(
offers.map(async (offer: any) => {
try {
const routeData = await execute(
RouteToCoordinateDocument,
{
offerUuid: offer.uuid,
lat: hub.latitude,
lon: hub.longitude
},
'public',
'geo'
)
return {
...offer,
sourceUuid: offer.uuid,
sourceName: offer.productName,
sourceLat: offer.latitude,
sourceLon: offer.longitude,
distanceKm: routeData?.routeToCoordinate?.distanceKm,
routes: routeData?.routeToCoordinate?.routes || []
}
} catch (e) {
// Route might not exist
console.warn('No route found for offer:', offer.uuid, e)
return {
...offer,
sourceUuid: offer.uuid,
sourceName: offer.productName,
sourceLat: offer.latitude,
sourceLon: offer.longitude,
routes: []
}
}
})
)
relatedOffers.value = offersWithRoutes
// Offers already include routes from backend
relatedOffers.value = offersData?.nearestOffers || []
// Extract unique suppliers from offers (use supplierUuid from offers)
const supplierUuids = new Set<string>()
offersWithRoutes.forEach((offer: any) => {
relatedOffers.value.forEach((offer: any) => {
if (offer.supplierUuid) {
supplierUuids.add(offer.supplierUuid)
}