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

@@ -64,7 +64,7 @@
</template>
<script setup lang="ts">
import { GetNodeDocument, NearestOffersDocument, RouteToCoordinateDocument } from '~/composables/graphql/public/geo-generated'
import { GetNodeDocument, NearestOffersDocument } from '~/composables/graphql/public/geo-generated'
import type { RouteStageItem } from '~/components/RouteStagesList.vue'
interface RouteStage {
@@ -131,13 +131,14 @@ const fetchOffersByHub = async () => {
return null
}
// 2. Find offers near hub for this product
const offersData = await execute(
// 2. Find offers near hub for this product WITH routes calculated on backend
const offersResponse = await execute(
NearestOffersDocument,
{
lat: hub.latitude,
lon: hub.longitude,
productUuid: productUuid.value,
hubUuid: destinationUuid.value, // Pass hubUuid to get routes calculated on backend
radius: 500,
limit: 5
},
@@ -145,42 +146,17 @@ const fetchOffersByHub = async () => {
'geo'
)
const offers = offersData?.nearestOffers || []
const offers = offersResponse?.nearestOffers || []
// 3. For each offer, get route to hub coordinates
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 {
sourceUuid: offer.uuid,
sourceName: offer.productName,
sourceLat: offer.latitude,
sourceLon: offer.longitude,
distanceKm: routeData?.routeToCoordinate?.distanceKm,
routes: routeData?.routeToCoordinate?.routes || []
}
} catch (e) {
console.warn('No route found for offer:', offer.uuid, e)
return {
sourceUuid: offer.uuid,
sourceName: offer.productName,
sourceLat: offer.latitude,
sourceLon: offer.longitude,
routes: []
}
}
})
)
// Offers already include routes from backend
const offersWithRoutes = offers.map((offer: any) => ({
sourceUuid: offer.uuid,
sourceName: offer.productName,
sourceLat: offer.latitude,
sourceLon: offer.longitude,
distanceKm: offer.distanceKm,
routes: offer.routes || []
}))
return { offersByHub: offersWithRoutes }
}