fix: separate list items from map points in orders page
All checks were successful
Build Docker Image / build (push) Successful in 4m58s

- Add mapItems prop to CatalogPage for separate map data
- List shows one card per order, map shows source+dest points
- Fix hover to match by orderUuid pattern
This commit is contained in:
Ruslan Bakiev
2026-01-08 14:52:58 +07:00
parent 75ef38c8b2
commit 01e8eb2cfa
2 changed files with 31 additions and 11 deletions

View File

@@ -166,6 +166,7 @@ interface MapItem {
const props = withDefaults(defineProps<{
items: MapItem[]
mapItems?: MapItem[] // Optional separate items for map (if different from list items)
loading?: boolean
withMap?: boolean
mapId?: string
@@ -191,9 +192,12 @@ const emit = defineEmits<{
'update:hoveredId': [uuid: string | undefined]
}>()
// Use mapItems if provided, otherwise fall back to items
const itemsForMap = computed(() => props.mapItems || props.items)
// Filter items with valid coordinates for map
const itemsWithCoords = computed(() =>
props.items.filter(item =>
itemsForMap.value.filter(item =>
item.latitude != null &&
item.longitude != null &&
!isNaN(Number(item.latitude)) &&
@@ -203,7 +207,8 @@ const itemsWithCoords = computed(() =>
name: item.name || '',
latitude: Number(item.latitude),
longitude: Number(item.longitude),
country: item.country
country: item.country,
orderUuid: item.orderUuid // Preserve orderUuid for hover matching
}))
)
@@ -249,7 +254,12 @@ watch(() => props.selectedId, (uuid) => {
// Watch hoveredId and fly to it
watch(() => props.hoveredId, (uuid) => {
if (uuid && props.withMap) {
const item = itemsWithCoords.value.find(i => i.uuid === uuid)
// Try direct match first
let item = itemsWithCoords.value.find(i => i.uuid === uuid)
// If not found, try matching by orderUuid (for mapItems with separate source/dest points)
if (!item) {
item = itemsWithCoords.value.find(i => i.uuid === `${uuid}-source` || (i as any).orderUuid === uuid)
}
if (item) {
mapRef.value?.flyTo(item.latitude, item.longitude, 8)
mobileMapRef.value?.flyTo(item.latitude, item.longitude, 8)