diff --git a/app/composables/useCatalogInfo.ts b/app/composables/useCatalogInfo.ts index e08dd83..9984c59 100644 --- a/app/composables/useCatalogInfo.ts +++ b/app/composables/useCatalogInfo.ts @@ -14,6 +14,7 @@ export function useCatalogInfo() { // State const entity = ref(null) + const entityType = ref(null) // Track entity type explicitly const relatedProducts = ref([]) const relatedHubs = ref([]) const relatedSuppliers = ref([]) @@ -319,16 +320,11 @@ export function useCatalogInfo() { if (!entity.value) return - const entityType = entity.value.uuid - if (!entityType) return - - // Load offers based on entity type - if (entity.value.transportTypes) { - // This is a hub (has transportTypes) + // Use stored entity type instead of inferring from properties + if (entityType.value === 'hub') { await loadOffersForHub(entity.value.uuid, productUuid) activeTab.value = 'offers' - } else if (entity.value.teamUuid || entity.value.onTimeRate !== undefined) { - // This is a supplier + } else if (entityType.value === 'supplier') { await loadOffersForSupplier(entity.value.uuid, productUuid) activeTab.value = 'offers' } @@ -343,6 +339,7 @@ export function useCatalogInfo() { const loadInfo = async (type: InfoEntityType, uuid: string) => { isLoading.value = true clearInfo() // Clear previous data + entityType.value = type // Store entity type try { if (type === 'hub') { @@ -360,6 +357,7 @@ export function useCatalogInfo() { // Clear all info data const clearInfo = () => { entity.value = null + entityType.value = null relatedProducts.value = [] relatedHubs.value = [] relatedSuppliers.value = [] diff --git a/app/pages/catalog/index.vue b/app/pages/catalog/index.vue index a18f7d9..8f419dc 100644 --- a/app/pages/catalog/index.vue +++ b/app/pages/catalog/index.vue @@ -399,9 +399,17 @@ const onInfoClose = () => { const onInfoAddToFilter = () => { if (!infoId.value || !entity.value) return const { type, uuid } = infoId.value - // Fallback for name - offer entities might use productName - const name = entity.value.name || entity.value.productName || uuid.slice(0, 8) + '...' - selectItem(type, uuid, name) + + // For offers, add the product to filter (not the offer itself) + if (type === 'offer' && entity.value.productUuid) { + const productName = entity.value.productName || entity.value.name || uuid.slice(0, 8) + '...' + selectItem('product', entity.value.productUuid, productName) + } else { + // For hubs and suppliers, add directly + const name = entity.value.name || uuid.slice(0, 8) + '...' + selectItem(type, uuid, name) + } + closeInfo() clearInfo() }