refactor: remove all any types, add strict GraphQL scalar typing
All checks were successful
Build Docker Image / build (push) Successful in 4m3s
All checks were successful
Build Docker Image / build (push) Successful in 4m3s
- Add strictScalars: true to codegen.ts with proper scalar mappings (Date, Decimal, JSONString, JSON, UUID, BigInt → string/Record) - Replace all ref<any[]> with proper GraphQL-derived types - Add type guards for null filtering in arrays - Fix bugs exposed by typing (locationLatitude vs latitude, etc.) - Add interfaces for external components (MapboxSearchBox) This enables end-to-end type safety from GraphQL schema to frontend.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { ProductsListQueryResult } from '~/composables/graphql/public/geo-generated'
|
||||
import type { ProductsListQueryResult, NearestOffersQueryResult } from '~/composables/graphql/public/geo-generated'
|
||||
import {
|
||||
ProductsListDocument,
|
||||
GetNodeDocument,
|
||||
@@ -10,6 +10,14 @@ import {
|
||||
|
||||
// Type from codegen
|
||||
type ProductItem = NonNullable<NonNullable<ProductsListQueryResult['productsList']>[number]>
|
||||
type OfferItem = NonNullable<NonNullable<NearestOffersQueryResult['nearestOffers']>[number]>
|
||||
|
||||
// Product aggregated from offers
|
||||
interface AggregatedProduct {
|
||||
uuid: string
|
||||
name: string | null | undefined
|
||||
offersCount: number
|
||||
}
|
||||
|
||||
// Shared state
|
||||
const items = ref<ProductItem[]>([])
|
||||
@@ -61,20 +69,19 @@ export function useCatalogProducts() {
|
||||
)
|
||||
|
||||
// Group offers by product
|
||||
const productsMap = new Map<string, any>()
|
||||
offersData?.nearestOffers?.forEach((offer: any) => {
|
||||
if (offer?.productUuid) {
|
||||
if (!productsMap.has(offer.productUuid)) {
|
||||
productsMap.set(offer.productUuid, {
|
||||
uuid: offer.productUuid,
|
||||
name: offer.productName,
|
||||
offersCount: 0
|
||||
})
|
||||
}
|
||||
productsMap.get(offer.productUuid)!.offersCount++
|
||||
const productsMap = new Map<string, AggregatedProduct>()
|
||||
offersData?.nearestOffers?.forEach((offer) => {
|
||||
if (!offer?.productUuid) return
|
||||
if (!productsMap.has(offer.productUuid)) {
|
||||
productsMap.set(offer.productUuid, {
|
||||
uuid: offer.productUuid,
|
||||
name: offer.productName,
|
||||
offersCount: 0
|
||||
})
|
||||
}
|
||||
productsMap.get(offer.productUuid)!.offersCount++
|
||||
})
|
||||
items.value = Array.from(productsMap.values())
|
||||
items.value = Array.from(productsMap.values()) as ProductItem[]
|
||||
}
|
||||
} else if (filterHubUuid.value) {
|
||||
// Products near hub - get hub coordinates first
|
||||
@@ -103,20 +110,19 @@ export function useCatalogProducts() {
|
||||
)
|
||||
|
||||
// Group offers by product
|
||||
const productsMap = new Map<string, any>()
|
||||
offersData?.nearestOffers?.forEach((offer: any) => {
|
||||
if (offer?.productUuid) {
|
||||
if (!productsMap.has(offer.productUuid)) {
|
||||
productsMap.set(offer.productUuid, {
|
||||
uuid: offer.productUuid,
|
||||
name: offer.productName,
|
||||
offersCount: 0
|
||||
})
|
||||
}
|
||||
productsMap.get(offer.productUuid)!.offersCount++
|
||||
const productsMap = new Map<string, AggregatedProduct>()
|
||||
offersData?.nearestOffers?.forEach((offer) => {
|
||||
if (!offer?.productUuid) return
|
||||
if (!productsMap.has(offer.productUuid)) {
|
||||
productsMap.set(offer.productUuid, {
|
||||
uuid: offer.productUuid,
|
||||
name: offer.productName,
|
||||
offersCount: 0
|
||||
})
|
||||
}
|
||||
productsMap.get(offer.productUuid)!.offersCount++
|
||||
})
|
||||
items.value = Array.from(productsMap.values())
|
||||
items.value = Array.from(productsMap.values()) as ProductItem[]
|
||||
}
|
||||
} else {
|
||||
// All products from graph
|
||||
|
||||
Reference in New Issue
Block a user