Fix: entity type detection in selectProduct, handle offer in add-to-filter
All checks were successful
Build Docker Image / build (push) Successful in 3m47s
All checks were successful
Build Docker Image / build (push) Successful in 3m47s
This commit is contained in:
@@ -14,6 +14,7 @@ export function useCatalogInfo() {
|
|||||||
|
|
||||||
// State
|
// State
|
||||||
const entity = ref<any>(null)
|
const entity = ref<any>(null)
|
||||||
|
const entityType = ref<InfoEntityType | null>(null) // Track entity type explicitly
|
||||||
const relatedProducts = ref<any[]>([])
|
const relatedProducts = ref<any[]>([])
|
||||||
const relatedHubs = ref<any[]>([])
|
const relatedHubs = ref<any[]>([])
|
||||||
const relatedSuppliers = ref<any[]>([])
|
const relatedSuppliers = ref<any[]>([])
|
||||||
@@ -319,16 +320,11 @@ export function useCatalogInfo() {
|
|||||||
|
|
||||||
if (!entity.value) return
|
if (!entity.value) return
|
||||||
|
|
||||||
const entityType = entity.value.uuid
|
// Use stored entity type instead of inferring from properties
|
||||||
if (!entityType) return
|
if (entityType.value === 'hub') {
|
||||||
|
|
||||||
// Load offers based on entity type
|
|
||||||
if (entity.value.transportTypes) {
|
|
||||||
// This is a hub (has transportTypes)
|
|
||||||
await loadOffersForHub(entity.value.uuid, productUuid)
|
await loadOffersForHub(entity.value.uuid, productUuid)
|
||||||
activeTab.value = 'offers'
|
activeTab.value = 'offers'
|
||||||
} else if (entity.value.teamUuid || entity.value.onTimeRate !== undefined) {
|
} else if (entityType.value === 'supplier') {
|
||||||
// This is a supplier
|
|
||||||
await loadOffersForSupplier(entity.value.uuid, productUuid)
|
await loadOffersForSupplier(entity.value.uuid, productUuid)
|
||||||
activeTab.value = 'offers'
|
activeTab.value = 'offers'
|
||||||
}
|
}
|
||||||
@@ -343,6 +339,7 @@ export function useCatalogInfo() {
|
|||||||
const loadInfo = async (type: InfoEntityType, uuid: string) => {
|
const loadInfo = async (type: InfoEntityType, uuid: string) => {
|
||||||
isLoading.value = true
|
isLoading.value = true
|
||||||
clearInfo() // Clear previous data
|
clearInfo() // Clear previous data
|
||||||
|
entityType.value = type // Store entity type
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (type === 'hub') {
|
if (type === 'hub') {
|
||||||
@@ -360,6 +357,7 @@ export function useCatalogInfo() {
|
|||||||
// Clear all info data
|
// Clear all info data
|
||||||
const clearInfo = () => {
|
const clearInfo = () => {
|
||||||
entity.value = null
|
entity.value = null
|
||||||
|
entityType.value = null
|
||||||
relatedProducts.value = []
|
relatedProducts.value = []
|
||||||
relatedHubs.value = []
|
relatedHubs.value = []
|
||||||
relatedSuppliers.value = []
|
relatedSuppliers.value = []
|
||||||
|
|||||||
@@ -399,9 +399,17 @@ const onInfoClose = () => {
|
|||||||
const onInfoAddToFilter = () => {
|
const onInfoAddToFilter = () => {
|
||||||
if (!infoId.value || !entity.value) return
|
if (!infoId.value || !entity.value) return
|
||||||
const { type, uuid } = infoId.value
|
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) + '...'
|
// For offers, add the product to filter (not the offer itself)
|
||||||
selectItem(type, uuid, name)
|
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()
|
closeInfo()
|
||||||
clearInfo()
|
clearInfo()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user