Refactor SaleSection component to utilize direct property assignment for betterPrices, enhancing reactivity in Vue3. Update inventory mapping to ensure betterPrices is always an array.

This commit is contained in:
Torsten Schulz (local)
2025-12-20 21:28:01 +01:00
parent c6dfca7052
commit 91009f52cd

View File

@@ -290,6 +290,8 @@
this.inventory = response.data.map(item => ({
...item,
sellQuantity: item.totalQuantity,
// Vue3: besserPrices direkt als Property setzen (statt this.$set)
betterPrices: Array.isArray(item.betterPrices) ? item.betterPrices : [],
}));
await this.loadPricesForInventory();
} catch (error) {
@@ -310,10 +312,11 @@
currentPrice: currentPrice
}
});
this.$set(item, 'betterPrices', data || []);
// Vue3: direkte Zuweisung ist reaktiv
item.betterPrices = Array.isArray(data) ? data : [];
} catch (error) {
console.error(`Error loading prices for item ${itemKey}:`, error);
this.$set(item, 'betterPrices', []);
item.betterPrices = [];
} finally {
this.loadingPrices.delete(itemKey);
}