diff --git a/src/modules/market/components/MerchantStore.vue b/src/modules/market/components/MerchantStore.vue index 854ca9a..6bbcd80 100644 --- a/src/modules/market/components/MerchantStore.vue +++ b/src/modules/market/components/MerchantStore.vue @@ -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 = [] diff --git a/src/modules/market/composables/useMarket.ts b/src/modules/market/composables/useMarket.ts index 7365bc8..e4c8828 100644 --- a/src/modules/market/composables/useMarket.ts +++ b/src/modules/market/composables/useMarket.ts @@ -286,13 +286,19 @@ export function useMarket() { productGroups.forEach((productEvents, productId) => { // Sort by created_at and take the most recent const latestEvent = productEvents.sort((a: any, b: any) => b.created_at - a.created_at)[0] - + try { const productData = JSON.parse(latestEvent.content) + const stallId = productData.stall_id || 'unknown' + + // Look up the stall name from the stalls array + const stall = marketStore.stalls.find(s => s.id === stallId) + const stallName = stall?.name || 'Unknown Stall' + const product = { id: productId, - stall_id: productData.stall_id || 'unknown', - stallName: productData.stallName || 'Unknown Stall', + stall_id: stallId, + stallName: stallName, name: productData.name || 'Unnamed Product', description: productData.description || '', price: productData.price || 0, @@ -303,7 +309,7 @@ export function useMarket() { createdAt: latestEvent.created_at, updatedAt: latestEvent.created_at } - + marketStore.addProduct(product) } catch (err) { // Silently handle parse errors @@ -468,10 +474,16 @@ export function useMarket() { const productId = event.tags.find((tag: any) => tag[0] === 'd')?.[1] if (productId) { const productData = JSON.parse(event.content) + const stallId = productData.stall_id || 'unknown' + + // Look up the stall name from the stalls array + const stall = marketStore.stalls.find(s => s.id === stallId) + const stallName = stall?.name || 'Unknown Stall' + const product = { id: productId, - stall_id: productData.stall_id || 'unknown', - stallName: productData.stallName || 'Unknown Stall', + stall_id: stallId, + stallName: stallName, pubkey: event.pubkey, name: productData.name || 'Unnamed Product', description: productData.description || '', @@ -483,7 +495,7 @@ export function useMarket() { createdAt: event.created_at, updatedAt: event.created_at } - + marketStore.addProduct(product) } } catch (err) {