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:
@@ -78,6 +78,8 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useLocationStore } from '~/stores/location'
|
||||
import type { CatalogHubItem, CatalogNearestHubItem } from '~/composables/useCatalogHubs'
|
||||
import type { TeamAddress } from '~/composables/graphql/team/teams-generated'
|
||||
|
||||
definePageMeta({
|
||||
layout: 'topnav'
|
||||
@@ -107,20 +109,20 @@ const {
|
||||
} = useCatalogHubs()
|
||||
|
||||
// Selected/hovered hub for map
|
||||
const selectedHubId = ref<string>()
|
||||
const hoveredHubId = ref<string>()
|
||||
const selectedHubId = ref<string | undefined>()
|
||||
const hoveredHubId = ref<string | undefined>()
|
||||
|
||||
await init()
|
||||
|
||||
// Load team addresses
|
||||
const teamAddresses = ref<any[]>([])
|
||||
const teamAddresses = ref<TeamAddress[]>([])
|
||||
|
||||
if (isAuthenticated.value) {
|
||||
try {
|
||||
const { execute } = useGraphQL()
|
||||
const { GetTeamAddressesDocument } = await import('~/composables/graphql/team/teams-generated')
|
||||
const data = await execute(GetTeamAddressesDocument, {}, 'team', 'teams')
|
||||
teamAddresses.value = data?.teamAddresses || []
|
||||
teamAddresses.value = (data?.teamAddresses || []).filter((a): a is TeamAddress => a != null)
|
||||
} catch {
|
||||
// Not critical
|
||||
}
|
||||
@@ -147,11 +149,12 @@ const goToRequestIfReady = () => {
|
||||
return false
|
||||
}
|
||||
|
||||
const selectHub = async (hub: any) => {
|
||||
const selectHub = async (hub: CatalogHubItem | CatalogNearestHubItem) => {
|
||||
if (!hub.uuid) return
|
||||
selectedHubId.value = hub.uuid
|
||||
|
||||
if (isSearchMode.value) {
|
||||
searchStore.setLocation(hub.name)
|
||||
searchStore.setLocation(hub.name ?? '')
|
||||
searchStore.setLocationUuid(hub.uuid)
|
||||
if (goToRequestIfReady()) return
|
||||
router.back()
|
||||
@@ -159,7 +162,7 @@ const selectHub = async (hub: any) => {
|
||||
}
|
||||
|
||||
try {
|
||||
const success = await locationStore.select('hub', hub.uuid, hub.name, hub.latitude, hub.longitude)
|
||||
const success = await locationStore.select('hub', hub.uuid, hub.name ?? '', hub.latitude ?? 0, hub.longitude ?? 0)
|
||||
if (success) {
|
||||
router.back()
|
||||
}
|
||||
@@ -168,7 +171,7 @@ const selectHub = async (hub: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
const selectAddress = async (addr: any) => {
|
||||
const selectAddress = async (addr: TeamAddress) => {
|
||||
if (isSearchMode.value) {
|
||||
searchStore.setLocation(addr.address || addr.name)
|
||||
searchStore.setLocationUuid(addr.uuid)
|
||||
@@ -178,7 +181,7 @@ const selectAddress = async (addr: any) => {
|
||||
}
|
||||
|
||||
try {
|
||||
const success = await locationStore.select('address', addr.uuid, addr.name, addr.latitude, addr.longitude)
|
||||
const success = await locationStore.select('address', addr.uuid, addr.name, addr.latitude ?? 0, addr.longitude ?? 0)
|
||||
if (success) {
|
||||
router.back()
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
>
|
||||
<template #cards>
|
||||
<HubCard
|
||||
v-for="hub in items"
|
||||
:key="hub.uuid"
|
||||
v-for="(hub, index) in items"
|
||||
:key="hub.uuid ?? index"
|
||||
:hub="hub"
|
||||
selectable
|
||||
:is-selected="selectedItemId === hub.uuid"
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useLocationStore } from '~/stores/location'
|
||||
import type { CatalogHubItem, CatalogNearestHubItem } from '~/composables/useCatalogHubs'
|
||||
|
||||
definePageMeta({
|
||||
layout: false
|
||||
@@ -64,7 +65,8 @@ await init()
|
||||
const mapRef = ref<{ flyTo: (lat: number, lng: number, zoom?: number) => void } | null>(null)
|
||||
const selectedItemId = ref<string | null>(null)
|
||||
|
||||
const selectItem = async (item: any) => {
|
||||
const selectItem = async (item: CatalogHubItem | CatalogNearestHubItem) => {
|
||||
if (!item.uuid) return
|
||||
selectedItemId.value = item.uuid
|
||||
|
||||
if (item.latitude && item.longitude) {
|
||||
@@ -73,7 +75,7 @@ const selectItem = async (item: any) => {
|
||||
|
||||
// Selection logic
|
||||
if (isSearchMode.value) {
|
||||
searchStore.setLocation(item.name)
|
||||
searchStore.setLocation(item.name ?? '')
|
||||
searchStore.setLocationUuid(item.uuid)
|
||||
if (route.query.after === 'request' && searchStore.searchForm.productUuid && searchStore.searchForm.locationUuid) {
|
||||
const query: Record<string, string> = {
|
||||
@@ -92,7 +94,7 @@ const selectItem = async (item: any) => {
|
||||
return
|
||||
}
|
||||
|
||||
const success = await locationStore.select('hub', item.uuid, item.name, item.latitude, item.longitude)
|
||||
const success = await locationStore.select('hub', item.uuid, item.name ?? '', item.latitude ?? 0, item.longitude ?? 0)
|
||||
if (success) router.push(localePath('/select-location'))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user