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:
padreug 2025-09-26 17:20:59 +02:00
parent d98dcc58d7
commit 478b83ddd3
4 changed files with 35 additions and 16 deletions

View file

@ -46,7 +46,7 @@
<!-- Enhanced Fuzzy Search Bar - Full Width on Mobile -->
<div class="w-full lg:flex-1 lg:max-w-md">
<MarketFuzzySearch
:data="marketStore.products"
:data="marketStore.products as Product[]"
:options="searchOptions"
@results="handleSearchResults"
@filter-category="handleCategoryFilter"
@ -193,7 +193,7 @@
<ProductCard
v-for="product in productsToDisplay"
:key="product.id"
:product="product"
:product="product as Product"
@add-to-cart="addToCart"
@view-details="viewProduct"
@view-stall="viewStall"
@ -222,7 +222,7 @@ import { config } from '@/lib/config'
import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar'
import { ShoppingCart, X, Check, Filter } from 'lucide-vue-next'
import { ShoppingCart, X, Check } from 'lucide-vue-next'
import MarketFuzzySearch from '../components/MarketFuzzySearch.vue'
import ProductCard from '../components/ProductCard.vue'
import type { Product } from '../types/market'
@ -237,22 +237,19 @@ const marketPreloader = useMarketPreloader()
const productsForCategoryFilter = computed(() => {
return searchResults.value.length > 0
? searchResults.value
: marketStore.products
: (marketStore.products as Product[])
})
// Category filtering with optimized composable
const {
allCategories,
filteredProducts: categoryFilteredProducts,
selectedCount: selectedCategoriesCount,
selectedCategoryNames: selectedCategories,
hasActiveFilters,
filterMode,
toggleCategory,
clearAllCategories: clearAllCategoryFilters,
setFilterMode,
toggleFilterMode,
categoryStats
setFilterMode
} = useCategoryFilter(productsForCategoryFilter)
let unsubscribe: (() => void) | null = null