Fix: entity type detection in selectProduct, handle offer in add-to-filter
All checks were successful
Build Docker Image / build (push) Successful in 3m47s

This commit is contained in:
Ruslan Bakiev
2026-01-26 15:29:17 +07:00
parent c76750a738
commit 1c298951b1
2 changed files with 17 additions and 11 deletions

View File

@@ -14,6 +14,7 @@ export function useCatalogInfo() {
// State
const entity = ref<any>(null)
const entityType = ref<InfoEntityType | null>(null) // Track entity type explicitly
const relatedProducts = ref<any[]>([])
const relatedHubs = ref<any[]>([])
const relatedSuppliers = ref<any[]>([])
@@ -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 = []

View File

@@ -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()
}