Fix product selection from map offer click
All checks were successful
Build Docker Image / build (push) Successful in 3m22s
All checks were successful
Build Docker Image / build (push) Successful in 3m22s
- Use GetOffer to fetch productUuid (not in cluster data) - Handle both uuid and id properties from clusters - Skip cluster items (id starts with 'cluster-')
This commit is contained in:
@@ -44,7 +44,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { GetOffersDocument } from '~/composables/graphql/public/exchange-generated'
|
import { GetOffersDocument, GetOfferDocument } from '~/composables/graphql/public/exchange-generated'
|
||||||
import type { MapBounds } from '~/components/catalog/CatalogMap.vue'
|
import type { MapBounds } from '~/components/catalog/CatalogMap.vue'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
@@ -234,14 +234,18 @@ const mapPointColor = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Handle map item selection
|
// Handle map item selection
|
||||||
const onMapSelect = (item: any) => {
|
const onMapSelect = async (item: any) => {
|
||||||
// If in selection mode, use map click to fill the selector
|
// Get uuid from item - clusters use 'id', regular items use 'uuid'
|
||||||
if (selectMode.value && item.uuid) {
|
const itemId = item.uuid || item.id
|
||||||
const itemName = item.name || item.uuid.slice(0, 8) + '...'
|
if (!itemId || itemId.startsWith('cluster-')) return
|
||||||
|
|
||||||
|
const itemName = item.name || itemId.slice(0, 8) + '...'
|
||||||
|
|
||||||
|
// If in selection mode, use map click to fill the selector
|
||||||
|
if (selectMode.value) {
|
||||||
// For hubs selection - click on hub fills hub selector
|
// For hubs selection - click on hub fills hub selector
|
||||||
if (selectMode.value === 'hub' && mapViewMode.value === 'hubs') {
|
if (selectMode.value === 'hub' && mapViewMode.value === 'hubs') {
|
||||||
selectItem('hub', item.uuid, itemName)
|
selectItem('hub', itemId, itemName)
|
||||||
showQuoteResults.value = false
|
showQuoteResults.value = false
|
||||||
offers.value = []
|
offers.value = []
|
||||||
return
|
return
|
||||||
@@ -249,30 +253,28 @@ const onMapSelect = (item: any) => {
|
|||||||
|
|
||||||
// For supplier selection - click on supplier fills supplier selector
|
// For supplier selection - click on supplier fills supplier selector
|
||||||
if (selectMode.value === 'supplier' && mapViewMode.value === 'suppliers') {
|
if (selectMode.value === 'supplier' && mapViewMode.value === 'suppliers') {
|
||||||
selectItem('supplier', item.uuid, itemName)
|
selectItem('supplier', itemId, itemName)
|
||||||
showQuoteResults.value = false
|
showQuoteResults.value = false
|
||||||
offers.value = []
|
offers.value = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// For product selection viewing offers - try to find product in loaded list
|
// For product selection viewing offers - fetch offer to get productUuid
|
||||||
if (selectMode.value === 'product' && mapViewMode.value === 'offers') {
|
if (selectMode.value === 'product' && mapViewMode.value === 'offers') {
|
||||||
// The offer has product info - we'll look it up from the products list if loaded
|
// Fetch offer details to get productUuid (not available in cluster data)
|
||||||
// or just use the offer's product_uuid if available
|
const data = await execute(GetOfferDocument, { uuid: itemId }, 'public', 'exchange')
|
||||||
const product = products.value.find((p: any) => p.uuid === item.productUuid)
|
const offer = data?.getOffer
|
||||||
if (product) {
|
if (offer?.productUuid) {
|
||||||
selectItem('product', product.uuid, product.name || itemName)
|
selectItem('product', offer.productUuid, offer.productName || itemName)
|
||||||
} else if (item.productUuid) {
|
showQuoteResults.value = false
|
||||||
selectItem('product', item.productUuid, item.productName || itemName)
|
offers.value = []
|
||||||
}
|
}
|
||||||
showQuoteResults.value = false
|
|
||||||
offers.value = []
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default behavior for quote mode etc
|
// Default behavior for quote mode etc
|
||||||
if (catalogMode.value === 'quote' && item.uuid) {
|
if (catalogMode.value === 'quote') {
|
||||||
console.log('Selected from map:', item)
|
console.log('Selected from map:', item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user