Enhance product handling in MerchantStore and useMarket

- Enriched products with stall names in MerchantStore, ensuring each product displays the associated stall name or 'Unknown Stall' if not available.
- Updated product addition logic in useMarket to include stall names, improving clarity and consistency across the application.
- Enhanced error handling for product loading to maintain robust functionality.

These changes improve the user experience by providing clearer product information in the market interface.
This commit is contained in:
padreug 2025-09-25 22:44:38 +02:00
parent 2e12315a35
commit f2080abce5
2 changed files with 30 additions and 8 deletions

View file

@ -516,7 +516,17 @@ const loadStallProducts = async () => {
inkey,
activeStall.value.id!
)
stallProducts.value = products || []
// Enrich products with stall name
const enrichedProducts = (products || []).map(product => ({
...product,
stallName: activeStall.value?.name || 'Unknown Stall'
}))
stallProducts.value = enrichedProducts
// Also add them to the market store so they appear in the main market
enrichedProducts.forEach(product => {
marketStore.addProduct(product)
})
} catch (error) {
console.error('Failed to load products:', error)
stallProducts.value = []