Implement dynamic category filtering in MarketPage
- Added a computed property to dynamically filter products based on search results, enhancing the user experience by displaying relevant products when available. - Updated the `useCategoryFilter` integration to utilize the new computed property, streamlining the filtering logic and improving overall performance. These changes provide users with a more responsive and relevant product display in the MarketPage, improving the effectiveness of category filtering.
This commit is contained in:
parent
0e6a4a7451
commit
522d159628
1 changed files with 8 additions and 1 deletions
|
|
@ -233,6 +233,13 @@ const marketStore = useMarketStore()
|
|||
const market = useMarket()
|
||||
const marketPreloader = useMarketPreloader()
|
||||
|
||||
// Dynamic category filtering: use search results when available, otherwise all products
|
||||
const productsForCategoryFilter = computed(() => {
|
||||
return searchResults.value.length > 0
|
||||
? searchResults.value
|
||||
: marketStore.products
|
||||
})
|
||||
|
||||
// Category filtering with optimized composable
|
||||
const {
|
||||
allCategories,
|
||||
|
|
@ -246,7 +253,7 @@ const {
|
|||
setFilterMode,
|
||||
toggleFilterMode,
|
||||
categoryStats
|
||||
} = useCategoryFilter(computed(() => marketStore.products))
|
||||
} = useCategoryFilter(productsForCategoryFilter)
|
||||
|
||||
let unsubscribe: (() => void) | null = null
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue