refactor: simplify LoadingErrorState and enhance MarketSearchBar functionality
- Removed unnecessary imports and streamlined the LoadingErrorState component by eliminating redundant props. - Improved keyboard handling in MarketSearchBar to support basic Escape key functionality and enhanced keyboard shortcuts. - Updated MerchantStore and MarketPage components to utilize the revised LoadingErrorState and MarketSearchBar, ensuring consistent loading/error handling and search capabilities. - Enhanced StallView to provide better category filtering and product search experience. These changes improve code clarity and maintainability while enhancing user interaction across the market module.
This commit is contained in:
parent
c8860dc937
commit
e68a7a9ed5
5 changed files with 109 additions and 81 deletions
|
|
@ -68,8 +68,9 @@
|
|||
<CategoryFilterBar
|
||||
v-if="stallCategories.length > 0"
|
||||
:categories="stallCategories"
|
||||
:selected-categories="selectedCategories"
|
||||
:selected-count="selectedCategories.length"
|
||||
:filter-mode="filterMode"
|
||||
:product-count="productCount"
|
||||
title="Categories"
|
||||
@toggle-category="toggleCategoryFilter"
|
||||
@set-filter-mode="setFilterMode"
|
||||
|
|
@ -81,7 +82,7 @@
|
|||
<div class="mb-4 sm:mb-6 flex flex-col sm:flex-row gap-2 sm:gap-4">
|
||||
<div class="flex-1">
|
||||
<MarketSearchBar
|
||||
:data="stallProducts"
|
||||
:data="stallProducts as Product[]"
|
||||
:options="searchOptions"
|
||||
placeholder="Search products in this stall..."
|
||||
:show-enhancements="false"
|
||||
|
|
@ -203,11 +204,20 @@ const stallProducts = computed(() => {
|
|||
|
||||
// Get unique categories for this stall
|
||||
const stallCategories = computed(() => {
|
||||
const categories = new Set<string>()
|
||||
const categoryCount = new Map<string, number>()
|
||||
stallProducts.value.forEach(product => {
|
||||
product.categories?.forEach(cat => categories.add(cat))
|
||||
product.categories?.forEach(cat => {
|
||||
categoryCount.set(cat, (categoryCount.get(cat) || 0) + 1)
|
||||
})
|
||||
})
|
||||
return Array.from(categories).sort()
|
||||
|
||||
return Array.from(categoryCount.entries())
|
||||
.sort((a, b) => a[0].localeCompare(b[0]))
|
||||
.map(([category, count]) => ({
|
||||
category,
|
||||
count,
|
||||
selected: selectedCategories.value.includes(category)
|
||||
}))
|
||||
})
|
||||
|
||||
// Product count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue