fix: migrate geo GraphQL queries and frontend to camelCase
All checks were successful
Build Docker Image / build (push) Successful in 5m0s
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:
@@ -152,12 +152,12 @@ try {
|
||||
|
||||
// Group offers by product
|
||||
const productsMap = new Map<string, { uuid: string; name: string }>()
|
||||
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 || ''
|
||||
offersData.value?.nearestOffers?.forEach((offer) => {
|
||||
if (offer?.productUuid) {
|
||||
if (!productsMap.has(offer.productUuid)) {
|
||||
productsMap.set(offer.productUuid, {
|
||||
uuid: offer.productUuid,
|
||||
name: offer.productName || ''
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ import { GetOffersDocument, type GetOffersQueryVariables } from '~/composables/g
|
||||
import { GetNodeDocument, NearestOffersDocument, type NearestOffersQueryResult } from '~/composables/graphql/public/geo-generated'
|
||||
import type { MapBounds } from '~/components/catalog/CatalogMap.vue'
|
||||
|
||||
type NearestOffer = NonNullable<NearestOffersQueryResult['nearest_offers'][number]>
|
||||
type NearestOffer = NonNullable<NearestOffersQueryResult['nearestOffers'][number]>
|
||||
|
||||
definePageMeta({
|
||||
layout: 'topnav'
|
||||
@@ -433,7 +433,7 @@ const searchOfferPoints = computed(() =>
|
||||
.filter((offer) => offer.latitude != null && offer.longitude != null)
|
||||
.map((offer) => ({
|
||||
uuid: offer.uuid,
|
||||
name: offer.product_name || '',
|
||||
name: offer.productName || '',
|
||||
latitude: Number(offer.latitude),
|
||||
longitude: Number(offer.longitude),
|
||||
type: 'offer' as const
|
||||
@@ -548,7 +548,7 @@ const loadExploreOffers = async () => {
|
||||
'public',
|
||||
'geo'
|
||||
)
|
||||
exploreOffers.value = (geoData?.nearest_offers || []).filter((o): o is NearestOffer => o !== null)
|
||||
exploreOffers.value = (geoData?.nearestOffers || []).filter((o): o is NearestOffer => o !== null)
|
||||
} finally {
|
||||
exploreOffersLoading.value = false
|
||||
}
|
||||
@@ -570,7 +570,7 @@ const mapItems = computed((): MapItemWithCoords[] => {
|
||||
.filter((offer) => offer.uuid && offer.latitude != null && offer.longitude != null)
|
||||
.map((offer) => ({
|
||||
uuid: offer.uuid,
|
||||
name: offer.product_name || '',
|
||||
name: offer.productName || '',
|
||||
latitude: Number(offer.latitude),
|
||||
longitude: Number(offer.longitude)
|
||||
}))
|
||||
@@ -718,17 +718,17 @@ const onSearch = async () => {
|
||||
'geo'
|
||||
)
|
||||
|
||||
let nearest = (geoData?.nearest_offers || []).filter((o): o is NearestOffer => o !== null)
|
||||
let nearest = (geoData?.nearestOffers || []).filter((o): o is NearestOffer => o !== null)
|
||||
if (supplierId.value) {
|
||||
nearest = nearest.filter(o => o?.supplier_uuid === supplierId.value)
|
||||
nearest = nearest.filter(o => o?.supplierUuid === supplierId.value)
|
||||
}
|
||||
|
||||
offers.value = nearest
|
||||
quoteCalculations.value = buildCalculationsFromOffers(nearest)
|
||||
|
||||
const first = offers.value[0]
|
||||
if (first?.product_name) {
|
||||
setLabel('product', productId.value, first.product_name)
|
||||
if (first?.productName) {
|
||||
setLabel('product', productId.value, first.productName)
|
||||
}
|
||||
} else {
|
||||
offers.value = []
|
||||
@@ -774,8 +774,8 @@ const onSearch = async () => {
|
||||
}
|
||||
|
||||
// Select offer - navigate to detail page
|
||||
const onSelectOffer = (offer: { uuid: string; product_uuid?: string | null; productUuid?: string | null }) => {
|
||||
const productUuid = offer.product_uuid || offer.productUuid
|
||||
const onSelectOffer = (offer: { uuid: string; productUuid?: string | null }) => {
|
||||
const productUuid = offer.productUuid
|
||||
if (offer.uuid && productUuid) {
|
||||
router.push(localePath(`/catalog/offers/${productUuid}?offer=${offer.uuid}`))
|
||||
}
|
||||
|
||||
@@ -78,15 +78,15 @@
|
||||
@click="onSelectOffer(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>
|
||||
@@ -107,7 +107,7 @@
|
||||
<script setup lang="ts">
|
||||
import { GetNodeDocument, NearestOffersDocument, type NearestOffersQueryResult } from '~/composables/graphql/public/geo-generated'
|
||||
|
||||
type NearestOffer = NonNullable<NearestOffersQueryResult['nearest_offers'][number]>
|
||||
type NearestOffer = NonNullable<NearestOffersQueryResult['nearestOffers'][number]>
|
||||
|
||||
definePageMeta({ layout: 'topnav' })
|
||||
|
||||
@@ -151,7 +151,7 @@ const relatedPoints = computed(() => {
|
||||
.forEach(o => {
|
||||
points.push({
|
||||
uuid: o.uuid,
|
||||
name: o.product_name || '',
|
||||
name: o.productName || '',
|
||||
latitude: Number(o.latitude),
|
||||
longitude: Number(o.longitude),
|
||||
type: 'offer',
|
||||
@@ -167,7 +167,7 @@ const onMapSelect = (uuid: string) => {
|
||||
}
|
||||
|
||||
const onSelectOffer = (offer: NearestOffer) => {
|
||||
const productUuid = offer.product_uuid || offer.productUuid
|
||||
const productUuid = offer.productUuid
|
||||
if (offer.uuid && productUuid) {
|
||||
router.push(localePath(`/catalog/offers/${productUuid}?offer=${offer.uuid}`))
|
||||
}
|
||||
@@ -179,10 +179,10 @@ const getOfferStages = (offer: NearestOffer) => {
|
||||
return r.stages
|
||||
.filter((s): s is NonNullable<typeof s> => s !== null)
|
||||
.map(s => ({
|
||||
transportType: s.transport_type,
|
||||
distanceKm: s.distance_km,
|
||||
travelTimeSeconds: s.travel_time_seconds,
|
||||
fromName: s.from_name,
|
||||
transportType: s.transportType,
|
||||
distanceKm: s.distanceKm,
|
||||
travelTimeSeconds: s.travelTimeSeconds,
|
||||
fromName: s.fromName,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ const searchOffers = async () => {
|
||||
'geo'
|
||||
)
|
||||
|
||||
offers.value = (data?.nearest_offers || []).filter((o): o is NearestOffer => o !== null)
|
||||
offers.value = (data?.nearestOffers || []).filter((o): o is NearestOffer => o !== null)
|
||||
} finally {
|
||||
offersLoading.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user