diff --git a/frontend/src/components/falukant/RevenueSection.vue b/frontend/src/components/falukant/RevenueSection.vue index e85832a..b2ddcbc 100644 --- a/frontend/src/components/falukant/RevenueSection.vue +++ b/frontend/src/components/falukant/RevenueSection.vue @@ -117,13 +117,11 @@ if (this.currentRegionId === null || this.currentRegionId === undefined) { return; } - for (const product of this.products) { - if (this.loadingPrices.has(product.id)) continue; + const requests = this.products.map(async (product) => { + if (this.loadingPrices.has(product.id)) return; this.loadingPrices.add(product.id); try { - // Verwende den gerundeten Preis aus calculateProductRevenue (wie gewollt) const currentPrice = parseFloat(this.calculateProductRevenue(product).absolute); - const { data } = await apiClient.get('/api/falukant/products/prices-in-cities', { params: { productId: product.id, @@ -131,8 +129,6 @@ currentRegionId: this.currentRegionId } }); - // Speichere betterPrices in einem separaten Map, nicht auf dem product Objekt - // In Vue 3 müssen wir ein neues Objekt erstellen, um die Reaktivität zu triggern this.betterPricesMap = { ...this.betterPricesMap, [product.id]: data || [] @@ -146,7 +142,8 @@ } finally { this.loadingPrices.delete(product.id); } - } + }); + await Promise.all(requests); }, getBetterPrices(productId) { return this.betterPricesMap[productId] || []; diff --git a/frontend/src/components/falukant/SaleSection.vue b/frontend/src/components/falukant/SaleSection.vue index 83dab7c..8555379 100644 --- a/frontend/src/components/falukant/SaleSection.vue +++ b/frontend/src/components/falukant/SaleSection.vue @@ -294,12 +294,11 @@ } }, async loadPricesForInventory() { - for (const item of this.inventory) { + const requests = this.inventory.map(async (item) => { const itemKey = `${item.region.id}-${item.product.id}-${item.quality}`; - if (this.loadingPrices.has(itemKey)) continue; + if (this.loadingPrices.has(itemKey)) return; this.loadingPrices.add(itemKey); try { - // Aktueller Preis basierend auf sellCost const currentPrice = item.product.sellCost || 0; const { data } = await apiClient.get('/api/falukant/products/prices-in-cities', { params: { @@ -314,7 +313,8 @@ } finally { this.loadingPrices.delete(itemKey); } - } + }); + await Promise.all(requests); }, getCityPriceClass(branchType) { if (branchType === 'store') return 'city-price-green';