Fix geo GraphQL schema mismatch: camelCase → snake_case
All checks were successful
Build Docker Image / build (push) Successful in 5m46s
All checks were successful
Build Docker Image / build (push) Successful in 5m46s
All geo .graphql operations and consuming code updated to match server schema which uses snake_case field/argument names. Removed non-existent QuoteCalculations query, using NearestOffers instead.
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { GetNodeDocument, NearestOffersDocument, type OfferWithRouteType, type GetNodeQueryResult } from '~/composables/graphql/public/geo-generated'
|
||||
import { GetNodeDocument, NearestOffersDocument, type OfferWithRoute, type GetNodeQueryResult } from '~/composables/graphql/public/geo-generated'
|
||||
|
||||
type Hub = NonNullable<GetNodeQueryResult['node']>
|
||||
|
||||
@@ -152,12 +152,12 @@ try {
|
||||
|
||||
// Group offers by product
|
||||
const productsMap = new Map<string, { uuid: string; name: string }>()
|
||||
offersData.value?.nearestOffers?.forEach((offer) => {
|
||||
if (offer?.productUuid) {
|
||||
if (!productsMap.has(offer.productUuid)) {
|
||||
productsMap.set(offer.productUuid, {
|
||||
uuid: offer.productUuid,
|
||||
name: offer.productName || ''
|
||||
offersData.value?.nearest_offers?.forEach((offer) => {
|
||||
if (offer?.product_uuid) {
|
||||
if (!productsMap.has(offer.product_uuid)) {
|
||||
productsMap.set(offer.product_uuid, {
|
||||
uuid: offer.product_uuid,
|
||||
name: offer.product_name || ''
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,11 +92,10 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { GetOffersDocument, type GetOffersQueryVariables } from '~/composables/graphql/public/exchange-generated'
|
||||
import { GetNodeDocument, NearestOffersDocument, QuoteCalculationsDocument, type QuoteCalculationsQueryResult } from '~/composables/graphql/public/geo-generated'
|
||||
import { GetNodeDocument, NearestOffersDocument, type NearestOffersQueryResult } from '~/composables/graphql/public/geo-generated'
|
||||
import type { MapBounds } from '~/components/catalog/CatalogMap.vue'
|
||||
|
||||
type QuoteCalculation = NonNullable<NonNullable<QuoteCalculationsQueryResult['quoteCalculations']>[number]>
|
||||
type QuoteOffer = NonNullable<NonNullable<QuoteCalculation['offers']>[number]>
|
||||
type NearestOffer = NonNullable<NearestOffersQueryResult['nearest_offers'][number]>
|
||||
|
||||
definePageMeta({
|
||||
layout: 'topnav'
|
||||
@@ -434,7 +433,7 @@ const searchOfferPoints = computed(() =>
|
||||
.filter((offer) => offer.latitude != null && offer.longitude != null)
|
||||
.map((offer) => ({
|
||||
uuid: offer.uuid,
|
||||
name: offer.productName || '',
|
||||
name: offer.product_name || '',
|
||||
latitude: Number(offer.latitude),
|
||||
longitude: Number(offer.longitude),
|
||||
type: 'offer' as const
|
||||
@@ -471,11 +470,11 @@ const relatedPoints = computed(() => {
|
||||
})
|
||||
|
||||
// Offers data for quote results
|
||||
const offers = ref<QuoteOffer[]>([])
|
||||
const quoteCalculations = ref<QuoteCalculation[]>([])
|
||||
const offers = ref<NearestOffer[]>([])
|
||||
const quoteCalculations = ref<{ offers: NearestOffer[] }[]>([])
|
||||
|
||||
const buildCalculationsFromOffers = (list: QuoteOffer[]) =>
|
||||
list.map((offer) => ({ offers: [offer] })) as QuoteCalculation[]
|
||||
const buildCalculationsFromOffers = (list: NearestOffer[]) =>
|
||||
list.map((offer) => ({ offers: [offer] }))
|
||||
const offersLoading = ref(false)
|
||||
const showQuoteResults = ref(false)
|
||||
|
||||
@@ -520,7 +519,7 @@ const useServerClustering = computed(() => {
|
||||
})
|
||||
|
||||
// Offers for Explore map when hub filter is active (graph-based)
|
||||
const exploreOffers = ref<QuoteOffer[]>([])
|
||||
const exploreOffers = ref<NearestOffer[]>([])
|
||||
const exploreOffersLoading = ref(false)
|
||||
|
||||
const shouldLoadExploreOffers = computed(() =>
|
||||
@@ -549,7 +548,7 @@ const loadExploreOffers = async () => {
|
||||
'public',
|
||||
'geo'
|
||||
)
|
||||
exploreOffers.value = (geoData?.nearestOffers || []).filter((o): o is QuoteOffer => o !== null)
|
||||
exploreOffers.value = (geoData?.nearest_offers || []).filter((o): o is NearestOffer => o !== null)
|
||||
} finally {
|
||||
exploreOffersLoading.value = false
|
||||
}
|
||||
@@ -571,7 +570,7 @@ const mapItems = computed((): MapItemWithCoords[] => {
|
||||
.filter((offer) => offer.uuid && offer.latitude != null && offer.longitude != null)
|
||||
.map((offer) => ({
|
||||
uuid: offer.uuid,
|
||||
name: offer.productName || '',
|
||||
name: offer.product_name || '',
|
||||
latitude: Number(offer.latitude),
|
||||
longitude: Number(offer.longitude)
|
||||
}))
|
||||
@@ -706,57 +705,30 @@ const onSearch = async () => {
|
||||
latitude: Number(hub.latitude),
|
||||
longitude: Number(hub.longitude)
|
||||
}
|
||||
try {
|
||||
const calcData = await execute(
|
||||
QuoteCalculationsDocument,
|
||||
{
|
||||
lat: hub.latitude,
|
||||
lon: hub.longitude,
|
||||
productUuid: productId.value,
|
||||
hubUuid: hubId.value,
|
||||
quantity: quantity.value ? Number(quantity.value) : null,
|
||||
limit: 10
|
||||
},
|
||||
'public',
|
||||
'geo'
|
||||
)
|
||||
const geoData = await execute(
|
||||
NearestOffersDocument,
|
||||
{
|
||||
lat: hub.latitude,
|
||||
lon: hub.longitude,
|
||||
productUuid: productId.value,
|
||||
hubUuid: hubId.value,
|
||||
limit: 12
|
||||
},
|
||||
'public',
|
||||
'geo'
|
||||
)
|
||||
|
||||
let calculations = (calcData?.quoteCalculations || []).filter((c): c is QuoteCalculation => c !== null)
|
||||
if (supplierId.value) {
|
||||
calculations = calculations.map((calc) => ({
|
||||
...calc,
|
||||
offers: (calc.offers || []).filter((offer): offer is QuoteOffer => offer !== null).filter(offer => offer.supplierUuid === supplierId.value)
|
||||
})).filter(calc => calc.offers.length > 0)
|
||||
}
|
||||
|
||||
quoteCalculations.value = calculations
|
||||
offers.value = calculations.flatMap(calc => (calc.offers || []).filter((offer): offer is QuoteOffer => offer !== null))
|
||||
} catch (error) {
|
||||
const geoData = await execute(
|
||||
NearestOffersDocument,
|
||||
{
|
||||
lat: hub.latitude,
|
||||
lon: hub.longitude,
|
||||
productUuid: productId.value,
|
||||
hubUuid: hubId.value,
|
||||
limit: 12
|
||||
},
|
||||
'public',
|
||||
'geo'
|
||||
)
|
||||
|
||||
let nearest = (geoData?.nearestOffers || []).filter((o): o is QuoteOffer => o !== null)
|
||||
if (supplierId.value) {
|
||||
nearest = nearest.filter(o => o?.supplierUuid === supplierId.value)
|
||||
}
|
||||
|
||||
offers.value = nearest
|
||||
quoteCalculations.value = buildCalculationsFromOffers(nearest)
|
||||
let nearest = (geoData?.nearest_offers || []).filter((o): o is NearestOffer => o !== null)
|
||||
if (supplierId.value) {
|
||||
nearest = nearest.filter(o => o?.supplier_uuid === supplierId.value)
|
||||
}
|
||||
|
||||
offers.value = nearest
|
||||
quoteCalculations.value = buildCalculationsFromOffers(nearest)
|
||||
|
||||
const first = offers.value[0]
|
||||
if (first?.productName) {
|
||||
setLabel('product', productId.value, first.productName)
|
||||
if (first?.product_name) {
|
||||
setLabel('product', productId.value, first.product_name)
|
||||
}
|
||||
} else {
|
||||
offers.value = []
|
||||
@@ -802,9 +774,10 @@ const onSearch = async () => {
|
||||
}
|
||||
|
||||
// Select offer - navigate to detail page
|
||||
const onSelectOffer = (offer: { uuid: string; productUuid?: string | null }) => {
|
||||
if (offer.uuid && offer.productUuid) {
|
||||
router.push(localePath(`/catalog/offers/${offer.productUuid}?offer=${offer.uuid}`))
|
||||
const onSelectOffer = (offer: { uuid: string; product_uuid?: string | null; productUuid?: string | null }) => {
|
||||
const productUuid = offer.product_uuid || offer.productUuid
|
||||
if (offer.uuid && productUuid) {
|
||||
router.push(localePath(`/catalog/offers/${productUuid}?offer=${offer.uuid}`))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user