refactor: remove any types and fix TypeScript errors
All checks were successful
Build Docker Image / build (push) Successful in 3m59s
All checks were successful
Build Docker Image / build (push) Successful in 3m59s
- Export InfoProductItem, InfoHubItem, InfoSupplierItem, InfoOfferItem types - Update InfoEntity interface to have explicit fields (no index signature) - Export CatalogHubItem, CatalogNearestHubItem from useCatalogHubs - Fix MapItem interfaces to accept nullable GraphQL types - Fix v-for :key bindings to handle null uuid - Add null guards in select-location pages - Update HubCard to accept nullable transportTypes - Add shims.d.ts for missing module declarations
This commit is contained in:
@@ -3,9 +3,13 @@ import { HubsListDocument, GetHubCountriesDocument, NearestHubsDocument } from '
|
||||
|
||||
const PAGE_SIZE = 24
|
||||
|
||||
// Type from codegen
|
||||
type HubItem = NonNullable<NonNullable<HubsListQueryResult['hubsList']>[number]>
|
||||
type NearestHubItem = NonNullable<NonNullable<NearestHubsQueryResult['nearestHubs']>[number]>
|
||||
// Type from codegen - exported for use in pages
|
||||
export type CatalogHubItem = NonNullable<NonNullable<HubsListQueryResult['hubsList']>[number]>
|
||||
export type CatalogNearestHubItem = NonNullable<NonNullable<NearestHubsQueryResult['nearestHubs']>[number]>
|
||||
|
||||
// Internal aliases
|
||||
type HubItem = CatalogHubItem
|
||||
type NearestHubItem = CatalogNearestHubItem
|
||||
|
||||
// Shared state across list and map views
|
||||
const items = ref<Array<HubItem | NearestHubItem>>([])
|
||||
|
||||
@@ -26,33 +26,43 @@ type HubItem = NonNullable<NonNullable<NearestHubsQueryResult['nearestHubs']>[nu
|
||||
type OfferItem = NonNullable<NonNullable<NearestOffersQueryResult['nearestOffers']>[number]>
|
||||
|
||||
// Product type (aggregated from offers)
|
||||
interface ProductItem {
|
||||
export interface InfoProductItem {
|
||||
uuid: string
|
||||
name: string
|
||||
offersCount?: number
|
||||
}
|
||||
|
||||
// Extended entity type with optional supplierName
|
||||
// Using intersection to allow both coordinate patterns (node vs offer)
|
||||
interface InfoEntity {
|
||||
// Re-export types for InfoPanel
|
||||
export type InfoHubItem = HubItem
|
||||
export type InfoSupplierItem = SupplierProfile
|
||||
export type InfoOfferItem = OfferItem
|
||||
|
||||
// Extended entity type with all known fields (NO index signature!)
|
||||
export interface InfoEntity {
|
||||
uuid?: string | null
|
||||
name?: string | null
|
||||
// Node coordinates
|
||||
latitude?: number | null
|
||||
longitude?: number | null
|
||||
// Location fields
|
||||
address?: string | null
|
||||
city?: string | null
|
||||
country?: string | null
|
||||
// Offer coordinates (different field names)
|
||||
locationLatitude?: number | null
|
||||
locationLongitude?: number | null
|
||||
locationUuid?: string
|
||||
locationName?: string
|
||||
locationUuid?: string | null
|
||||
locationName?: string | null
|
||||
// Offer fields
|
||||
productUuid?: string
|
||||
productName?: string
|
||||
teamUuid?: string
|
||||
// Enriched field
|
||||
supplierName?: string
|
||||
// Allow any other fields
|
||||
[key: string]: unknown
|
||||
productUuid?: string | null
|
||||
productName?: string | null
|
||||
teamUuid?: string | null
|
||||
teamName?: string | null
|
||||
pricePerUnit?: number | string | null
|
||||
currency?: string | null
|
||||
unit?: string | null
|
||||
// Enriched field from supplier profile
|
||||
supplierName?: string | null
|
||||
}
|
||||
|
||||
// Helper to get coordinates from entity (handles both node and offer patterns)
|
||||
@@ -73,7 +83,7 @@ export function useCatalogInfo() {
|
||||
// State with proper types
|
||||
const entity = ref<InfoEntity | null>(null)
|
||||
const entityType = ref<InfoEntityType | null>(null)
|
||||
const relatedProducts = ref<ProductItem[]>([])
|
||||
const relatedProducts = ref<InfoProductItem[]>([])
|
||||
const relatedHubs = ref<HubItem[]>([])
|
||||
const relatedSuppliers = ref<SupplierProfile[]>([])
|
||||
const relatedOffers = ref<OfferItem[]>([])
|
||||
@@ -119,7 +129,7 @@ export function useCatalogInfo() {
|
||||
'geo'
|
||||
).then(offersData => {
|
||||
// Group offers by product
|
||||
const productsMap = new Map<string, ProductItem>()
|
||||
const productsMap = new Map<string, InfoProductItem>()
|
||||
const suppliersMap = new Map<string, { uuid: string; name: string; latitude?: number | null; longitude?: number | null }>()
|
||||
|
||||
offersData?.nearestOffers?.forEach(offer => {
|
||||
@@ -224,7 +234,7 @@ export function useCatalogInfo() {
|
||||
'geo'
|
||||
).then(offersData => {
|
||||
// Group offers by product
|
||||
const productsMap = new Map<string, ProductItem>()
|
||||
const productsMap = new Map<string, InfoProductItem>()
|
||||
offersData?.nearestOffers?.forEach(offer => {
|
||||
if (!offer || !offer.productUuid || !offer.productName) return
|
||||
const existing = productsMap.get(offer.productUuid)
|
||||
|
||||
Reference in New Issue
Block a user