fix: migrate geo GraphQL queries and frontend to camelCase
All checks were successful
Build Docker Image / build (push) Successful in 5m0s

Geo backend was migrated to camelCase but frontend .graphql files and
component code still used snake_case, causing 400 errors on all geo API calls.
This commit is contained in:
Ruslan Bakiev
2026-03-10 14:10:23 +07:00
parent 4467d20160
commit 29c34a048a
30 changed files with 349 additions and 349 deletions

View File

@@ -152,17 +152,17 @@ const fetchOffersByHub = async () => {
'geo'
)
const offers = offersResponse?.nearest_offers || []
const offers = offersResponse?.nearestOffers || []
// Offers already include routes from backend
const offersWithRoutes = offers
.filter((offer): offer is NonNullable<OfferWithRoute> => offer !== null)
.map((offer) => ({
sourceUuid: offer.uuid,
sourceName: offer.product_name,
sourceName: offer.productName,
sourceLat: offer.latitude,
sourceLon: offer.longitude,
distanceKm: offer.distance_km,
distanceKm: offer.distanceKm,
routes: offer.routes || []
}))
@@ -209,10 +209,10 @@ const getRouteStages = (option: ProductRouteOption) => {
return route.stages
.filter((stage): stage is NonNullable<RouteStage> => stage !== null)
.map((stage) => ({
transportType: stage.transport_type,
distanceKm: stage.distance_km,
travelTimeSeconds: stage.travel_time_seconds,
fromName: stage.from_name
transportType: stage.transportType,
distanceKm: stage.distanceKm,
travelTimeSeconds: stage.travelTimeSeconds,
fromName: stage.fromName
}))
}

View File

@@ -71,7 +71,7 @@
<script setup lang="ts">
import { HubsListDocument, type HubsListQueryResult } from '~/composables/graphql/public/geo-generated'
type HubItem = NonNullable<NonNullable<HubsListQueryResult['hubs_list']>[number]>
type HubItem = NonNullable<NonNullable<HubsListQueryResult['hubsList']>[number]>
type HubWithDistance = HubItem & { distance?: string }
interface TeamAddress {
@@ -96,7 +96,7 @@ const calculateDistance = (lat: number, lng: number) => {
// Load logistics hubs
const { data: locationsDataRaw, pending, error, refresh } = await useServerQuery('locations', HubsListDocument, { limit: 100 }, 'public', 'geo')
const locationsData = computed<HubWithDistance[]>(() => {
return (locationsDataRaw.value?.hubs_list || [])
return (locationsDataRaw.value?.hubsList || [])
.filter((location): location is HubItem => location !== null)
.map((location) => ({
...location,

View File

@@ -39,8 +39,8 @@
<Stack v-if="autoEdges.length > 0" gap="2">
<NuxtLink
v-for="(edge, index) in autoEdges"
:key="edge.to_uuid ?? index"
:to="localePath(`/catalog/hubs/${edge.to_uuid}`)"
:key="edge.toUuid ?? index"
:to="localePath(`/catalog/hubs/${edge.toUuid}`)"
class="flex flex-col gap-2 p-3 rounded-lg border border-base-300 hover:bg-base-200 transition-colors"
>
<div class="flex items-center justify-between">
@@ -49,11 +49,11 @@
<Icon name="lucide:map-pin" size="16" class="text-primary" />
</div>
<div>
<div class="font-medium">{{ edge.to_name }}</div>
<div class="font-medium">{{ edge.toName }}</div>
</div>
</div>
<div class="text-right">
<div class="font-semibold text-primary">{{ edge.distance_km }} km</div>
<div class="font-semibold text-primary">{{ edge.distanceKm }} km</div>
</div>
</div>
</NuxtLink>
@@ -71,8 +71,8 @@
<Stack v-if="railEdges.length > 0" gap="2">
<NuxtLink
v-for="(edge, index) in railEdges"
:key="edge.to_uuid ?? index"
:to="localePath(`/catalog/hubs/${edge.to_uuid}`)"
:key="edge.toUuid ?? index"
:to="localePath(`/catalog/hubs/${edge.toUuid}`)"
class="flex flex-col gap-2 p-3 rounded-lg border border-base-300 hover:bg-base-200 transition-colors"
>
<div class="flex items-center justify-between">
@@ -81,11 +81,11 @@
<Icon name="lucide:map-pin" size="16" class="text-emerald-500" />
</div>
<div>
<div class="font-medium">{{ edge.to_name }}</div>
<div class="font-medium">{{ edge.toName }}</div>
</div>
</div>
<div class="text-right">
<div class="font-semibold text-emerald-600">{{ edge.distance_km }} km</div>
<div class="font-semibold text-emerald-600">{{ edge.distanceKm }} km</div>
</div>
</div>
</NuxtLink>
@@ -147,8 +147,8 @@ const mapCenter = computed<[number, number]>(() => {
const allEdges = [...props.autoEdges, ...props.railEdges]
allEdges.forEach((edge) => {
if (edge.to_latitude && edge.to_longitude) {
points.push([edge.to_longitude, edge.to_latitude])
if (edge.toLatitude && edge.toLongitude) {
points.push([edge.toLongitude, edge.toLatitude])
}
})
@@ -161,7 +161,7 @@ const mapCenter = computed<[number, number]>(() => {
})
const mapZoom = computed(() => {
const distances = [...props.autoEdges, ...props.railEdges].map(e => e.distance_km || 0)
const distances = [...props.autoEdges, ...props.railEdges].map(e => e.distanceKm || 0)
if (distances.length === 0) return 5
const maxDistance = Math.max(...distances)
@@ -193,18 +193,18 @@ const buildRouteFeatureCollection = (routes: RouteGeometry[], transportType: 'au
const buildNeighborsFeatureCollection = (edges: Edge[], transportType: 'auto' | 'rail') => ({
type: 'FeatureCollection' as const,
features: edges
.filter(e => e.to_latitude && e.to_longitude)
.filter(e => e.toLatitude && e.toLongitude)
.map(edge => ({
type: 'Feature' as const,
properties: {
uuid: edge.to_uuid,
name: edge.to_name,
distanceKm: edge.distance_km,
uuid: edge.toUuid,
name: edge.toName,
distanceKm: edge.distanceKm,
transportType
},
geometry: {
type: 'Point' as const,
coordinates: [edge.to_longitude!, edge.to_latitude!]
coordinates: [edge.toLongitude!, edge.toLatitude!]
}
}))
})

View File

@@ -38,8 +38,8 @@
<Stack gap="2">
<NuxtLink
v-for="(edge, index) in edges"
:key="edge.to_uuid ?? index"
:to="localePath(`/catalog/hubs/${edge.to_uuid}`)"
:key="edge.toUuid ?? index"
:to="localePath(`/catalog/hubs/${edge.toUuid}`)"
class="flex flex-col gap-2 p-3 rounded-lg border border-base-300 hover:bg-base-200 transition-colors"
>
<div class="flex items-center justify-between">
@@ -48,11 +48,11 @@
<Icon name="lucide:map-pin" size="16" class="text-primary" />
</div>
<div>
<div class="font-medium">{{ edge.to_name }}</div>
<div class="font-medium">{{ edge.toName }}</div>
</div>
</div>
<div class="text-right">
<div class="font-semibold text-primary">{{ edge.distance_km }} km</div>
<div class="font-semibold text-primary">{{ edge.distanceKm }} km</div>
</div>
</div>
</NuxtLink>
@@ -124,8 +124,8 @@ const mapCenter = computed<[number, number]>(() => {
return [0, 0]
}
const allLats = [props.currentHub.latitude, ...props.edges.map(e => e.to_latitude!).filter(Boolean)]
const allLngs = [props.currentHub.longitude, ...props.edges.map(e => e.to_longitude!).filter(Boolean)]
const allLats = [props.currentHub.latitude, ...props.edges.map(e => e.toLatitude!).filter(Boolean)]
const allLngs = [props.currentHub.longitude, ...props.edges.map(e => e.toLongitude!).filter(Boolean)]
const avgLng = allLngs.reduce((a, b) => a + b, 0) / allLngs.length
const avgLat = allLats.reduce((a, b) => a + b, 0) / allLats.length
@@ -166,16 +166,16 @@ const buildRouteFeatureCollection = () => ({
const buildNeighborsFeatureCollection = () => ({
type: 'FeatureCollection' as const,
features: props.edges.filter(e => e.to_latitude && e.to_longitude).map(edge => ({
features: props.edges.filter(e => e.toLatitude && e.toLongitude).map(edge => ({
type: 'Feature' as const,
properties: {
uuid: edge.to_uuid,
name: edge.to_name,
distanceKm: edge.distance_km
uuid: edge.toUuid,
name: edge.toName,
distanceKm: edge.distanceKm
},
geometry: {
type: 'Point' as const,
coordinates: [edge.to_longitude!, edge.to_latitude!]
coordinates: [edge.toLongitude!, edge.toLatitude!]
}
}))
})

View File

@@ -113,7 +113,7 @@ const fetchRouteGeometry = async (stage: RouteStage): Promise<[number, number][]
if (stage.transportType === 'auto' || stage.transportType === 'rail') {
try {
const RouteDocument = stage.transportType === 'auto' ? GetAutoRouteDocument : GetRailRouteDocument
const routeField = stage.transportType === 'auto' ? 'auto_route' : 'rail_route'
const routeField = stage.transportType === 'auto' ? 'autoRoute' : 'railRoute'
const routeData = await execute(RouteDocument, {
fromLat: stage.fromLat,

View File

@@ -182,7 +182,7 @@ const fetchStageGeometry = async (stage: RouteStage, routeIndex: number, stageIn
if (stage.transportType === 'auto' || stage.transportType === 'rail') {
try {
const RouteDocument = stage.transportType === 'auto' ? GetAutoRouteDocument : GetRailRouteDocument
const routeField = stage.transportType === 'auto' ? 'auto_route' : 'rail_route'
const routeField = stage.transportType === 'auto' ? 'autoRoute' : 'railRoute'
const routeData = await execute(RouteDocument, { fromLat, fromLon, toLat, toLon }, 'public', 'geo') as Record<string, any>
const geometry = routeData?.[routeField]?.geometry

View File

@@ -227,7 +227,7 @@ const serverClusteredGeoJson = computed(() => ({
id: point!.id,
name: point!.name,
count: point!.count ?? 1,
expansionZoom: point!.expansion_zoom,
expansionZoom: point!.expansionZoom,
isCluster: (point!.count ?? 1) > 1
},
geometry: {
@@ -246,7 +246,7 @@ const serverClusteredGeoJsonByType = computed(() => {
id: point!.id,
name: point!.name,
count: point!.count ?? 1,
expansionZoom: point!.expansion_zoom,
expansionZoom: point!.expansionZoom,
isCluster: (point!.count ?? 1) > 1,
type
},

View File

@@ -40,7 +40,7 @@
</Text>
</div>
<!-- Transport icons bottom -->
<div v-if="hub.transport_types?.length" class="flex items-center gap-1 pt-1">
<div v-if="hub.transportTypes?.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
country_code?: string | null
countryCode?: string | null
latitude?: number | null
longitude?: number | null
distance?: string
distance_km?: number | null
transport_types?: (string | null)[] | null
distanceKm?: number | null
transportTypes?: (string | null)[] | null
}
const props = defineProps<{
@@ -91,16 +91,16 @@ const isoToEmoji = (code: string): string => {
}
const countryFlag = computed(() => {
if (props.hub.country_code) {
return isoToEmoji(props.hub.country_code)
if (props.hub.countryCode) {
return isoToEmoji(props.hub.countryCode)
}
return '🌍'
})
const hasTransport = (type: string) => props.hub.transport_types?.some(t => t === type)
const hasTransport = (type: string) => props.hub.transportTypes?.some(t => t === type)
const distanceLabel = computed(() => {
if (props.hub.distance) return props.hub.distance
if (props.hub.distance_km != null) return `${Math.round(props.hub.distance_km)} km`
if (props.hub.distanceKm != null) return `${Math.round(props.hub.distanceKm)} km`
return ''
})

View File

@@ -173,13 +173,13 @@
:key="offer.uuid ?? index"
:supplier-name="getOfferSupplierName(offer)"
:location-name="offer.country || ''"
:product-name="offer.product_name"
:price-per-unit="offer.price_per_unit ? Number(offer.price_per_unit) : null"
:product-name="offer.productName"
:price-per-unit="offer.pricePerUnit ? Number(offer.pricePerUnit) : null"
:quantity="offer.quantity"
:currency="offer.currency"
:unit="offer.unit"
:stages="getOfferStages(offer)"
:total-time-seconds="offer.routes?.[0]?.total_time_seconds ?? null"
:total-time-seconds="offer.routes?.[0]?.totalTimeSeconds ?? null"
@select="onOfferSelect(offer)"
/>
</div>
@@ -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?.price_per_unit != null)
relatedOffers.value.filter(o => o?.pricePerUnit != null)
)
const suppliersByUuid = computed(() => {
@@ -370,9 +370,9 @@ const suppliersByUuid = computed(() => {
})
const getOfferSupplierName = (offer: InfoOfferItem) => {
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)
if (offer.supplierName) return offer.supplierName
if (offer.supplierUuid && suppliersByUuid.value.has(offer.supplierUuid)) {
return suppliersByUuid.value.get(offer.supplierUuid)
}
return null
}
@@ -441,11 +441,11 @@ const formatPrice = (price: number | string) => {
}
const railHubs = computed(() =>
relatedHubs.value.filter(h => h.transport_types?.includes('rail'))
relatedHubs.value.filter(h => h.transportTypes?.includes('rail'))
)
const seaHubs = computed(() =>
relatedHubs.value.filter(h => h.transport_types?.includes('sea'))
relatedHubs.value.filter(h => h.transportTypes?.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.product_uuid })
emit('select-offer', { uuid: offer.uuid, productUuid: offer.productUuid })
}
}
@@ -495,10 +495,10 @@ const getOfferStages = (offer: InfoOfferItem) => {
return route.stages
.filter((stage): stage is NonNullable<RouteStage> => stage !== null)
.map(stage => ({
transportType: stage.transport_type,
distanceKm: stage.distance_km,
travelTimeSeconds: stage.travel_time_seconds,
fromName: stage.from_name
transportType: stage.transportType,
distanceKm: stage.distanceKm,
travelTimeSeconds: stage.travelTimeSeconds,
fromName: stage.fromName
}))
}
</script>

View File

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