Refactor betterPricesMap handling in RevenueSection for Vue 3 compatibility
- Removed the use of $set for updating betterPricesMap, leveraging direct assignment instead, which is now the standard in Vue 3. - Simplified the getBetterPrices method by eliminating unnecessary logging, enhancing code clarity while maintaining functionality. - These changes aim to improve performance and align with Vue 3 best practices for state management.
This commit is contained in:
@@ -130,22 +130,19 @@
|
||||
currentRegionId: this.currentRegionId
|
||||
}
|
||||
});
|
||||
console.log(`[RevenueSection] Product ${product.id} (${product.labelTr}): received ${data?.length || 0} better prices:`, data);
|
||||
// Speichere betterPrices in einem separaten Map, nicht auf dem product Objekt
|
||||
this.$set(this.betterPricesMap, product.id, data || []);
|
||||
console.log(`[RevenueSection] betterPricesMap after update:`, JSON.parse(JSON.stringify(this.betterPricesMap)));
|
||||
// In Vue 3 ist $set nicht mehr nötig, direkte Zuweisung funktioniert
|
||||
this.betterPricesMap[product.id] = data || [];
|
||||
} catch (error) {
|
||||
console.error(`Error loading prices for product ${product.id}:`, error);
|
||||
this.$set(this.betterPricesMap, product.id, []);
|
||||
this.betterPricesMap[product.id] = [];
|
||||
} finally {
|
||||
this.loadingPrices.delete(product.id);
|
||||
}
|
||||
}
|
||||
},
|
||||
getBetterPrices(productId) {
|
||||
const prices = this.betterPricesMap[productId] || [];
|
||||
console.log(`[RevenueSection] getBetterPrices(${productId}): returning`, prices);
|
||||
return prices;
|
||||
return this.betterPricesMap[productId] || [];
|
||||
},
|
||||
getCityPriceClass(branchType) {
|
||||
if (branchType === 'store') return 'city-price-green';
|
||||
|
||||
Reference in New Issue
Block a user