Fix type safety in catalog composables + 3 InfoPanel bugs
All checks were successful
Build Docker Image / build (push) Successful in 3m42s
All checks were successful
Build Docker Image / build (push) Successful in 3m42s
- Add proper codegen types to all catalog composables: - useCatalogHubs: HubItem, NearestHubItem - useCatalogSuppliers: SupplierItem, NearestSupplierItem - useCatalogProducts: ProductItem - useCatalogOffers: OfferItem - useCatalogInfo: InfoEntity, ProductItem, HubItem, OfferItem - Fix InfoPanel bugs for offers: - Use locationLatitude/locationLongitude for offer coordinates - Enrich entity with supplierName after loading profile - Apply-to-filter now adds both product AND hub for offers - Filter null values from GraphQL array responses - Add type-safe coordinate helper (getEntityCoords) - Fix urlBounds type inference in useCatalogSearch
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import type { HubsListQueryResult, NearestHubsQueryResult } from '~/composables/graphql/public/geo-generated'
|
||||
import { HubsListDocument, GetHubCountriesDocument, NearestHubsDocument } from '~/composables/graphql/public/geo-generated'
|
||||
|
||||
const PAGE_SIZE = 24
|
||||
|
||||
// Type from codegen
|
||||
type HubItem = NonNullable<NonNullable<HubsListQueryResult['hubsList']>[number]>
|
||||
type NearestHubItem = NonNullable<NonNullable<NearestHubsQueryResult['nearestHubs']>[number]>
|
||||
|
||||
// Shared state across list and map views
|
||||
const items = ref<any[]>([])
|
||||
const items = ref<Array<HubItem | NearestHubItem>>([])
|
||||
const total = ref(0)
|
||||
const selectedFilter = ref('all')
|
||||
const selectedCountry = ref('all')
|
||||
@@ -67,7 +72,7 @@ export function useCatalogHubs() {
|
||||
'public',
|
||||
'geo'
|
||||
)
|
||||
const next = data?.nearestHubs || []
|
||||
const next = (data?.nearestHubs || []).filter((h): h is NearestHubItem => h !== null)
|
||||
items.value = next
|
||||
total.value = next.length
|
||||
isInitialized.value = true
|
||||
@@ -95,7 +100,7 @@ export function useCatalogHubs() {
|
||||
'public',
|
||||
'geo'
|
||||
)
|
||||
const next = data?.hubsList || []
|
||||
const next = (data?.hubsList || []).filter((h): h is HubItem => h !== null)
|
||||
items.value = replace ? next : items.value.concat(next)
|
||||
// hubsList doesn't return total count, estimate from fetched items
|
||||
if (replace) {
|
||||
|
||||
Reference in New Issue
Block a user