Simplify GEO API - use new list endpoints and routes in nearestOffers
All checks were successful
Build Docker Image / build (push) Successful in 4m11s
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:
@@ -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 }
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { GetNodesDocument } from '~/composables/graphql/public/geo-generated'
|
||||
import { HubsListDocument } from '~/composables/graphql/public/geo-generated'
|
||||
|
||||
const { t } = useI18n()
|
||||
const searchStore = useSearchStore()
|
||||
@@ -84,9 +84,9 @@ const calculateDistance = (lat: number, lng: number) => {
|
||||
}
|
||||
|
||||
// Load logistics hubs
|
||||
const { data: locationsDataRaw, pending, error, refresh } = await useServerQuery('locations', GetNodesDocument, {}, 'public', 'geo')
|
||||
const { data: locationsDataRaw, pending, error, refresh } = await useServerQuery('locations', HubsListDocument, { limit: 100 }, 'public', 'geo')
|
||||
const locationsData = computed(() => {
|
||||
return (locationsDataRaw.value?.nodes || []).map((location: any) => ({
|
||||
return (locationsDataRaw.value?.hubsList || []).map((location: any) => ({
|
||||
...location,
|
||||
distance: location?.latitude && location?.longitude
|
||||
? calculateDistance(location.latitude, location.longitude)
|
||||
|
||||
Reference in New Issue
Block a user