FIX BUILD ERRORS & AVOID INFINITE RECURSION: Enhance product enrichment and type definitions in MerchantStore component
- Updated the product enrichment logic in MerchantStore.vue to ensure all necessary properties match the Product interface, improving data consistency. - Added optional properties for active status, pending state, and configuration in the Product interface within market.ts, enhancing flexibility for merchant store management. - Improved type assertions in MarketPage.vue and StallView.vue to ensure proper type handling for product data, enhancing type safety and clarity. These changes improve the robustness and reliability of product data handling across the market components, enhancing the overall user experience.
This commit is contained in:
parent
d98dcc58d7
commit
478b83ddd3
4 changed files with 35 additions and 16 deletions
|
|
@ -516,10 +516,25 @@ const loadStallProducts = async () => {
|
|||
inkey,
|
||||
activeStall.value.id!
|
||||
)
|
||||
// Enrich products with stall name
|
||||
// Enrich products with stall name and missing properties to match Product interface
|
||||
const enrichedProducts = (products || []).map(product => ({
|
||||
...product,
|
||||
stallName: activeStall.value?.name || 'Unknown Stall'
|
||||
id: product.id || `${product.stall_id}-${Date.now()}`, // Ensure id is always string
|
||||
stall_id: product.stall_id,
|
||||
stallName: activeStall.value?.name || 'Unknown Stall',
|
||||
name: product.name,
|
||||
description: product.config?.description || '',
|
||||
price: product.price,
|
||||
currency: activeStall.value?.currency || 'sats', // Use stall currency
|
||||
quantity: product.quantity,
|
||||
images: product.images,
|
||||
categories: product.categories,
|
||||
createdAt: product.event_created_at || Date.now(),
|
||||
updatedAt: Date.now(),
|
||||
nostrEventId: product.event_id,
|
||||
// API-specific properties that are expected by the template
|
||||
active: product.active ?? true,
|
||||
pending: product.pending ?? false,
|
||||
config: product.config || { currency: activeStall.value?.currency || 'sats' }
|
||||
}))
|
||||
stallProducts.value = enrichedProducts
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue