Fix geo GraphQL schema mismatch: camelCase → snake_case
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:
Ruslan Bakiev
2026-03-09 21:45:57 +07:00
parent 15563991df
commit 25f946b293
34 changed files with 504 additions and 744 deletions

View File

@@ -17,7 +17,7 @@
<script setup lang="ts">
import type { Map as MapboxMapType } from 'mapbox-gl'
import { LngLatBounds } from 'mapbox-gl'
import type { ClusterPointType } from '~/composables/graphql/public/geo-generated'
import type { ClusterPoint } from '~/composables/graphql/public/geo-generated'
interface MapItem {
uuid?: string | null
@@ -43,8 +43,8 @@ interface HoveredItem {
const props = withDefaults(defineProps<{
mapId: string
items?: MapItem[]
clusteredPoints?: ClusterPointType[]
clusteredPointsByType?: Partial<Record<'offer' | 'hub' | 'supplier', ClusterPointType[]>>
clusteredPoints?: ClusterPoint[]
clusteredPointsByType?: Partial<Record<'offer' | 'hub' | 'supplier', ClusterPoint[]>>
useServerClustering?: boolean
hoveredItemId?: string | null
hoveredItem?: HoveredItem | null
@@ -227,7 +227,7 @@ const serverClusteredGeoJson = computed(() => ({
id: point!.id,
name: point!.name,
count: point!.count ?? 1,
expansionZoom: point!.expansionZoom,
expansionZoom: point!.expansion_zoom,
isCluster: (point!.count ?? 1) > 1
},
geometry: {
@@ -238,7 +238,7 @@ const serverClusteredGeoJson = computed(() => ({
}))
const serverClusteredGeoJsonByType = computed(() => {
const build = (points: ClusterPointType[] | undefined, type: 'offer' | 'hub' | 'supplier') => ({
const build = (points: ClusterPoint[] | undefined, type: 'offer' | 'hub' | 'supplier') => ({
type: 'FeatureCollection' as const,
features: (points || []).filter(Boolean).map(point => ({
type: 'Feature' as const,
@@ -246,7 +246,7 @@ const serverClusteredGeoJsonByType = computed(() => {
id: point!.id,
name: point!.name,
count: point!.count ?? 1,
expansionZoom: point!.expansionZoom,
expansionZoom: point!.expansion_zoom,
isCluster: (point!.count ?? 1) > 1,
type
},

View File

@@ -40,7 +40,7 @@
</Text>
</div>
<!-- Transport icons bottom -->
<div v-if="hub.transportTypes?.length" class="flex items-center gap-1 pt-1">
<div v-if="hub.transport_types?.length" class="flex items-center gap-1 pt-1">
<Icon v-if="hasTransport('auto')" name="lucide:truck" size="14" class="text-base-content/50" />
<Icon v-if="hasTransport('rail')" name="lucide:train-front" size="14" class="text-base-content/50" />
<Icon v-if="hasTransport('sea')" name="lucide:ship" size="14" class="text-base-content/50" />
@@ -58,12 +58,12 @@ interface Hub {
uuid?: string | null
name?: string | null
country?: string | null
countryCode?: string | null
country_code?: string | null
latitude?: number | null
longitude?: number | null
distance?: string
distanceKm?: number | null
transportTypes?: (string | null)[] | null
distance_km?: number | null
transport_types?: (string | null)[] | null
}
const props = defineProps<{
@@ -91,16 +91,16 @@ const isoToEmoji = (code: string): string => {
}
const countryFlag = computed(() => {
if (props.hub.countryCode) {
return isoToEmoji(props.hub.countryCode)
if (props.hub.country_code) {
return isoToEmoji(props.hub.country_code)
}
return '🌍'
})
const hasTransport = (type: string) => props.hub.transportTypes?.some(t => t === type)
const hasTransport = (type: string) => props.hub.transport_types?.some(t => t === type)
const distanceLabel = computed(() => {
if (props.hub.distance) return props.hub.distance
if (props.hub.distanceKm != null) return `${Math.round(props.hub.distanceKm)} km`
if (props.hub.distance_km != null) return `${Math.round(props.hub.distance_km)} km`
return ''
})

View File

@@ -172,14 +172,14 @@
v-for="(offer, index) in offersWithPrice"
:key="offer.uuid ?? index"
:supplier-name="getOfferSupplierName(offer)"
:location-name="offer.locationName || offer.locationCountry || offer.country || offer.locationName"
:product-name="offer.productName"
:price-per-unit="offer.pricePerUnit ? Number(offer.pricePerUnit) : null"
:location-name="offer.country || ''"
:product-name="offer.product_name"
:price-per-unit="offer.price_per_unit ? Number(offer.price_per_unit) : null"
:quantity="offer.quantity"
:currency="offer.currency"
:unit="offer.unit"
:stages="getOfferStages(offer)"
:total-time-seconds="offer.routes?.[0]?.totalTimeSeconds ?? null"
:total-time-seconds="offer.routes?.[0]?.total_time_seconds ?? null"
@select="onOfferSelect(offer)"
/>
</div>
@@ -315,7 +315,7 @@ import type {
InfoSupplierItem,
InfoOfferItem
} from '~/composables/useCatalogInfo'
import type { RouteStageType } from '~/composables/graphql/public/geo-generated'
import type { RouteStage } from '~/composables/graphql/public/geo-generated'
const props = defineProps<{
entityType: InfoEntityType
@@ -353,7 +353,7 @@ const relatedHubs = computed(() => props.relatedHubs ?? [])
const relatedSuppliers = computed(() => props.relatedSuppliers ?? [])
const relatedOffers = computed(() => props.relatedOffers ?? [])
const offersWithPrice = computed(() =>
relatedOffers.value.filter(o => o?.pricePerUnit != null)
relatedOffers.value.filter(o => o?.price_per_unit != null)
)
const suppliersByUuid = computed(() => {
@@ -370,9 +370,9 @@ const suppliersByUuid = computed(() => {
})
const getOfferSupplierName = (offer: InfoOfferItem) => {
if (offer.supplierName) return offer.supplierName
if (offer.supplierUuid && suppliersByUuid.value.has(offer.supplierUuid)) {
return suppliersByUuid.value.get(offer.supplierUuid)
if (offer.supplier_name) return offer.supplier_name
if (offer.supplier_uuid && suppliersByUuid.value.has(offer.supplier_uuid)) {
return suppliersByUuid.value.get(offer.supplier_uuid)
}
return null
}
@@ -441,11 +441,11 @@ const formatPrice = (price: number | string) => {
}
const railHubs = computed(() =>
relatedHubs.value.filter(h => h.transportTypes?.includes('rail'))
relatedHubs.value.filter(h => h.transport_types?.includes('rail'))
)
const seaHubs = computed(() =>
relatedHubs.value.filter(h => h.transportTypes?.includes('sea'))
relatedHubs.value.filter(h => h.transport_types?.includes('sea'))
)
// Mock KYC teaser data (will be replaced with real data later)
@@ -473,7 +473,7 @@ const onProductSelect = (product: InfoProductItem) => {
const onOfferSelect = (offer: InfoOfferItem) => {
if (offer.uuid) {
emit('select-offer', { uuid: offer.uuid, productUuid: offer.productUuid })
emit('select-offer', { uuid: offer.uuid, productUuid: offer.product_uuid })
}
}
@@ -493,12 +493,12 @@ const getOfferStages = (offer: InfoOfferItem) => {
const route = offer.routes?.[0]
if (!route?.stages) return []
return route.stages
.filter((stage): stage is NonNullable<RouteStageType> => stage !== null)
.filter((stage): stage is NonNullable<RouteStage> => stage !== null)
.map(stage => ({
transportType: stage.transportType,
distanceKm: stage.distanceKm,
travelTimeSeconds: stage.travelTimeSeconds,
fromName: stage.fromName
transportType: stage.transport_type,
distanceKm: stage.distance_km,
travelTimeSeconds: stage.travel_time_seconds,
fromName: stage.from_name
}))
}
</script>

View File

@@ -37,15 +37,15 @@
>
<OfferResultCard
grouped
:supplier-name="offer.supplierName"
:location-name="offer.locationName || offer.locationCountry"
:product-name="offer.productName"
:price-per-unit="offer.pricePerUnit ? Number(offer.pricePerUnit) : null"
:supplier-name="offer.supplier_name"
:location-name="offer.country || ''"
:product-name="offer.product_name"
:price-per-unit="offer.price_per_unit ? Number(offer.price_per_unit) : null"
:quantity="offer.quantity"
:currency="offer.currency"
:unit="offer.unit"
:stages="getOfferStages(offer)"
:total-time-seconds="offer.routes?.[0]?.totalTimeSeconds ?? null"
:total-time-seconds="offer.routes?.[0]?.total_time_seconds ?? null"
/>
</div>
</div>
@@ -58,15 +58,15 @@
@click="emit('select-offer', offer)"
>
<OfferResultCard
:supplier-name="offer.supplierName"
:location-name="offer.locationName || offer.locationCountry"
:product-name="offer.productName"
:price-per-unit="offer.pricePerUnit ? Number(offer.pricePerUnit) : null"
:supplier-name="offer.supplier_name"
:location-name="offer.country || ''"
:product-name="offer.product_name"
:price-per-unit="offer.price_per_unit ? Number(offer.price_per_unit) : null"
:quantity="offer.quantity"
:currency="offer.currency"
:unit="offer.unit"
:stages="getOfferStages(offer)"
:total-time-seconds="offer.routes?.[0]?.totalTimeSeconds ?? null"
:total-time-seconds="offer.routes?.[0]?.total_time_seconds ?? null"
/>
</div>
</div>
@@ -78,24 +78,23 @@
<script setup lang="ts">
interface Offer {
uuid: string
productName?: string | null
productUuid?: string | null
supplierName?: string | null
supplierUuid?: string | null
product_name?: string | null
product_uuid?: string | null
supplier_name?: string | null
supplier_uuid?: string | null
quantity?: number | string | null
unit?: string | null
pricePerUnit?: number | string | null
price_per_unit?: number | string | null
currency?: string | null
locationName?: string | null
locationCountry?: string | null
locationCountryCode?: string | null
country?: string | null
country_code?: string | null
routes?: Array<{
totalTimeSeconds?: number | null
total_time_seconds?: number | null
stages?: Array<{
transportType?: string | null
distanceKm?: number | null
travelTimeSeconds?: number | null
fromName?: string | null
transport_type?: string | null
distance_km?: number | null
travel_time_seconds?: number | null
from_name?: string | null
} | null> | null
} | null> | null
}
@@ -116,7 +115,7 @@ const props = defineProps<{
}>()
const offersWithPrice = computed(() =>
(props.offers || []).filter(o => o?.pricePerUnit != null)
(props.offers || []).filter(o => o?.price_per_unit != null)
)
const totalOffers = computed(() => {
@@ -140,10 +139,10 @@ const getOfferStages = (offer: Offer) => {
return route.stages
.filter((stage): stage is NonNullable<typeof stage> => stage !== null)
.map((stage) => ({
transportType: stage.transportType,
distanceKm: stage.distanceKm,
travelTimeSeconds: stage.travelTimeSeconds,
fromName: stage.fromName
transportType: stage.transport_type,
distanceKm: stage.distance_km,
travelTimeSeconds: stage.travel_time_seconds,
fromName: stage.from_name
}))
}
</script>