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:
@@ -4,7 +4,7 @@
|
||||
<MapboxMap
|
||||
:key="mapId"
|
||||
:map-id="mapId"
|
||||
:style="`height: ${height}px; width: 100%;`"
|
||||
:style="`height: ${heightValue}px; width: 100%;`"
|
||||
class="rounded-lg border border-base-300"
|
||||
:options="mapOptions"
|
||||
@load="onMapCreated"
|
||||
@@ -26,16 +26,46 @@ import type { Map as MapboxMapType } from 'mapbox-gl'
|
||||
import { LngLatBounds, Popup } from 'mapbox-gl'
|
||||
import { getCurrentInstance } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
stages: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
height: {
|
||||
type: Number,
|
||||
default: 400
|
||||
}
|
||||
})
|
||||
interface StageCompany {
|
||||
uuid?: string | null
|
||||
name?: string | null
|
||||
}
|
||||
|
||||
interface StageTrip {
|
||||
uuid?: string | null
|
||||
company?: StageCompany | null
|
||||
}
|
||||
|
||||
interface RouteStage {
|
||||
uuid?: string | null
|
||||
stageType?: string | null
|
||||
sourceLatitude?: number | null
|
||||
sourceLongitude?: number | null
|
||||
sourceLocationName?: string | null
|
||||
destinationLatitude?: number | null
|
||||
destinationLongitude?: number | null
|
||||
destinationLocationName?: string | null
|
||||
locationLatitude?: number | null
|
||||
locationLongitude?: number | null
|
||||
locationName?: string | null
|
||||
selectedCompany?: StageCompany | null
|
||||
trips?: StageTrip[] | null
|
||||
}
|
||||
|
||||
interface RoutePoint {
|
||||
id: string
|
||||
name: string
|
||||
lat: number
|
||||
lng: number
|
||||
companies: StageCompany[]
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
stages?: RouteStage[]
|
||||
height?: number
|
||||
}>()
|
||||
|
||||
const defaultHeight = 400
|
||||
|
||||
const { t } = useI18n()
|
||||
const mapRef = ref<MapboxMapType | null>(null)
|
||||
@@ -44,10 +74,12 @@ const didFitBounds = ref(false)
|
||||
const instanceId = getCurrentInstance()?.uid || Math.floor(Math.random() * 100000)
|
||||
const mapId = computed(() => `route-map-${instanceId}`)
|
||||
|
||||
const routePoints = computed(() => {
|
||||
const points: Array<{ id: string; name: string; lat: number; lng: number; companies: any[] }> = []
|
||||
const heightValue = computed(() => props.height ?? defaultHeight)
|
||||
|
||||
props.stages.forEach((stage: any) => {
|
||||
const routePoints = computed(() => {
|
||||
const points: RoutePoint[] = []
|
||||
|
||||
props.stages?.forEach((stage: RouteStage) => {
|
||||
if (stage.stageType === 'transport') {
|
||||
if (stage.sourceLatitude && stage.sourceLongitude) {
|
||||
const existingPoint = points.find(p => p.lat === stage.sourceLatitude && p.lng === stage.sourceLongitude)
|
||||
@@ -263,16 +295,16 @@ watch(
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const getStageCompanies = (stage: any) => {
|
||||
const companies: any[] = []
|
||||
const getStageCompanies = (stage: RouteStage): StageCompany[] => {
|
||||
const companies: StageCompany[] = []
|
||||
|
||||
if (stage.selectedCompany) {
|
||||
companies.push(stage.selectedCompany)
|
||||
}
|
||||
|
||||
const uniqueCompanies = new Set()
|
||||
stage.trips?.forEach((trip: any) => {
|
||||
if (trip.company && !uniqueCompanies.has(trip.company.uuid)) {
|
||||
const uniqueCompanies = new Set<string>()
|
||||
stage.trips?.forEach((trip: StageTrip) => {
|
||||
if (trip.company && trip.company.uuid && !uniqueCompanies.has(trip.company.uuid)) {
|
||||
uniqueCompanies.add(trip.company.uuid)
|
||||
companies.push(trip.company)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user